summaryrefslogtreecommitdiffstats
path: root/third_party/WebKit/LayoutTests/fast/files/script-tests/xhr-response-blob.js
blob: 7759e39e2cb9115fe8551f0c3cc05ba202bba8a3 (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
description("Test that XHR.responseType = 'blob' gives you back a Blob.");

if (window.testRunner)
    testRunner.waitUntilDone();

function testBlob(blobURL, blobType, doneFunction) {
    window.xhr = new XMLHttpRequest();
    xhr.open("GET", blobURL);
    xhr.responseType = "blob";
    shouldBeEqualToString("xhr.responseType", "blob");
    xhr.send();
    xhr.onreadystatechange = function() {
        if (xhr.readyState != 4) {
            shouldBeNull("xhr.response");
            return;
        }
        shouldBeTrue("xhr.response instanceof Blob");
        shouldBeEqualToString("xhr.response.type", blobType);
        doneFunction();
    }
}

testBlob("resources/UTF8.txt", "text/plain", function() {
    testBlob("resources/does_not_exist.txt", "", function() {
        testBlob("resources/empty-file", "", function() {
            if (window.testRunner)
                testRunner.notifyDone();
        })
    })
});