• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1<!DOCTYPE html>
2<html>
3<head>
4    <meta charset="utf-8">
5    <title>Blob and File reference URL Test(2)</title>
6    <link rel=help href="http://dev.w3.org/2006/webapi/FileAPI/#convenienceAPI">
7    <link rel=author title="Breezewish" href="mailto:me@breeswish.org">
8    <script src="/resources/testharness.js"></script>
9    <script src="/resources/testharnessreport.js"></script>
10</head>
11<body>
12    <form name="upload">
13        <input type="file" id="fileChooser"><br><input type="button" id="start" value="start">
14    </form>
15
16    <div>
17        <p>Test steps:</p>
18        <ol>
19            <li>Download the <a href="support/file_test2.txt">file</a>.</li>
20            <li>Select the file in the file inputbox.</li>
21            <li>Delete the file.</li>
22            <li>Click the 'start' button.</li>
23        </ol>
24    </div>
25
26    <div id="log"></div>
27
28    <script>
29
30        var fileChooser = document.querySelector('#fileChooser');
31
32        setup({explicit_done: true});
33        setup({explicit_timeout: true});
34
35        on_event(document.querySelector('#start'), 'click', function() {
36
37            async_test(function(t) {
38
39                var url = URL.createObjectURL(fileChooser.files[0]);
40
41                var xhr = new XMLHttpRequest();
42                xhr.open('GET', url, true);
43                xhr.onreadystatechange = t.step_func(function() {
44                    switch (xhr.readyState) {
45                    case xhr.DONE:
46                        assert_equals(xhr.status, 500, 'status code should be 500.');
47                        t.done();
48                        return;
49                    }
50                });
51
52                xhr.send();
53
54            }, 'Check whether the browser response 500 in XHR if the selected file which File/Blob URL refered is not found');
55
56            done();
57
58        });
59
60    </script>
61</body>
62</html>
63