upload tizen1.0 source
[framework/web/webkit-efl.git] / LayoutTests / media / media-blocked-by-willsendrequest.html
1 <!doctype html>
2 <html>
3 <head>
4     <script src=media-file.js></script>
5     <script src=video-test.js></script>
6 </head>
7 <body>
8     <video controls></video>
9     <p>Test to ensure that a media file blocked by the resource load delegate generates an error
10     and does not block the document's 'load' event.</p>
11
12     <script>
13         var events = [];
14
15         if (window.layoutTestController) {
16             layoutTestController.dumpAsText();
17             layoutTestController.setWillSendRequestReturnsNull(true);
18         } else
19             consoleWrite("<b><em>This test can only be run in DumpRenderTree!</em></b><br><br>");
20
21         function finish() 
22         {
23             consoleWrite("EVENT(loadstart)");
24             consoleWrite("EVENT(error)");
25             testExpected("video.error", null, "!=");
26             testExpected("video.error.code", MediaError.MEDIA_ERR_SRC_NOT_SUPPORTED);
27             testExpected("video.networkState", HTMLMediaElement.NETWORK_NO_SOURCE);
28             consoleWrite("");
29             endTest();
30         };
31
32         function handleEvent(evt)
33         {
34             // Wait until all three events we listen for have been received before testing.
35             // Media events are dispatched asynchronously so we can't assume they will fire
36             // before window.onload.
37             if (events.indexOf(evt.type) == -1)
38                 events.push(evt.type);
39             if (events.length == 3)
40                 finish();
41         }
42
43         findMediaElement();
44
45         window.addEventListener('load', handleEvent);
46         video.addEventListener('loadstart', handleEvent);
47         video.addEventListener('error', handleEvent);
48
49         testExpected("video.networkState", HTMLMediaElement.NETWORK_EMPTY);
50         consoleWrite("");
51         var mediaFile = findMediaFile("video", "content/test");
52         video.src = mediaFile;
53     </script>
54
55 </body>
56 </html>