summaryrefslogtreecommitdiffstats
path: root/third_party/WebKit/LayoutTests/fast/xmlhttprequest/xmlhttprequest-missing-file-exception.html
blob: be20215531f5bd30019141d6fe5745ba67a834c1 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
<p>This test checks for rdar://problem/4962298 REGRESSION: Synchronous XHR for missing local file throws exception -- breaks Wikipedia widget</p>
<hr>

<pre id="console"></pre>

<script>
function log(s)
{
    document.getElementById("console").appendChild(document.createTextNode(s + "\n"));
}

function logProperty(object, propertyName)
{
    var property;
    try {
        property = object[propertyName];
    } catch(e) {
        property = e;
    }
    log(propertyName + ": " + property + " (" + typeof property + ")");
}

function sendRequest() 
{
    var request = new XMLHttpRequest();
    request.open("GET", "file:///iamthewalrus", false);
    request.send(null);
    return request;
}

if (window.testRunner)
    testRunner.dumpAsText();

try {
    var request = sendRequest();

    var properties = [
        "readyState",
        "responseText",
        "responseXML",
        /* "status", -- excluded because it differs on tiger and leopard */
        "statusText",
    ];
    
    log("PASS: No exception.");
    for (var i = 0; i < properties.length; i++) //>
        logProperty(request, properties[i]);
} catch(e) {
    log("FAIL: Caught exception " + e + ".");
}
</script>