tizen beta release
[framework/web/webkit-efl.git] / LayoutTests / fast / xmlhttprequest / xmlhttprequest-responsetype-abort.html
1 <html>
2 <head>
3 <script src="../js/resources/js-test-pre.js"></script>
4 </head>
5 <body>
6
7 <div id="description"></div>
8 <div id="console"></div>
9
10 <script>
11 description("Tests aborting XMLHttpRequest 'arraybuffer' loading with the .responseType and .response attributes.");
12
13 var xhr = 0;
14
15 function abort() {
16     testPassed("abort() was called.");
17
18     // For aborted 'arraybuffer' the .response should not yet exist.
19     if (!xhr.response)
20         testPassed("'arraybuffer' .response does not exist after aborted load.");
21     else
22         testFailed("'arraybuffer' .response should not exist after aborted load.");
23
24     xhr = null;
25     finishJSTest();
26 }
27
28 function load() {
29     testFailed("onload() should not be called since loading was aborted.");
30
31     xhr = null;
32     finishJSTest();
33 }
34
35 function runTest() {
36     if (window.layoutTestController) {
37         layoutTestController.dumpAsText();
38         layoutTestController.waitUntilDone();
39     }
40
41     xhr = new XMLHttpRequest();
42     xhr.onload = load;
43     xhr.onabort = abort;
44     xhr.open("GET", "../../http/tests/resources/balls-of-the-orient.aif", true);
45         
46     try {
47         if ("responseType" in xhr)
48             testPassed("responseType property exists.");
49
50         if ("response" in xhr)
51             testPassed("response property exists.");
52
53         // Make sure we can set responseType to "arraybuffer" before send() is called.
54         try {
55             xhr.responseType = "arraybuffer";
56             if (xhr.responseType == "arraybuffer")
57                 testPassed("xhr.responseType has been correctly set to 'arraybuffer'.");
58         } catch(e) {
59             testFailed("unable to set xhr.responseType to 'arraybuffer' " + e + ".");
60         }
61     } catch(e) {
62         testFailed("Caught exception " + e + ".");
63     }
64
65     xhr.send(null);
66     xhr.abort();
67     window.jsTestIsAsync = true;
68 }
69
70 runTest();
71
72 </script>
73
74 <script src="../js/resources/js-test-post.js"></script>
75
76 </body>
77 </html>