Merge Chromium + Blink git repositories
[chromium-blink-merge.git] / third_party / WebKit / LayoutTests / http / tests / security / local-video-source-from-remote.html
blobed531c378ddc8855d03a29a1e9a69bb2057e76ac
1 <html lang="en">
2 <head>
3 <meta http-equiv="Content-Type" content="text/html; charset=utf-8">
4 <title>remote &lt;video&gt; with local &lt;source&gt;</title>
6 <script>
8 var video = null;
9 var console = null;
10 var testEnded = false;
12 function endTest()
14 consoleWrite("<br>END OF TEST");
15 testEnded = true;
16 if (window.testRunner)
17 testRunner.notifyDone();
19 function hanged()
21 consoleWrite("FAIL: timed out");
22 if (window.testRunner)
23 testRunner.notifyDone();
26 function logConsole()
28 if (!console && document.body) {
29 console = document.createElement('div');
30 document.body.appendChild(console);
32 return console;
35 function consoleWrite(text)
37 if (testEnded)
38 return;
39 logConsole().innerHTML += text + "<br>";
42 function logEvent(evt)
44 consoleWrite("EVENT(" + evt.type + ")");
47 function logResult(msg, success)
49 if (success)
50 consoleWrite("<span style='color:green'>SUCCESS: " + msg + "</span>");
51 else
52 consoleWrite("<span style='color:red'>FAIL: " + msg + "</span>");
55 function error(evt)
57 logEvent(evt)
58 consoleWrite("");
59 logResult("failed trying to load " + video.currentSrc, false);
60 endTest();
63 var localMovie = "file:///tmp/LayoutTests/media/content/test.mp4";
64 var remoteUrl = "http://localhost:8000/resources/test";
66 function loadedmetadata(evt)
68 var src = video.currentSrc;
69 var localFile = localMovie.substring(localMovie.lastIndexOf("/")+1, localMovie.length)
70 var remoteFile = remoteUrl.substring(remoteUrl.lastIndexOf("/")+1, remoteUrl.length)
72 logEvent(evt);
73 if (src.indexOf(localFile) > 0)
74 logResult("local movie loaded", false);
75 else if (src.indexOf(remoteFile) > 0)
76 logResult("remote movie loaded, local movie failed to load", true);
77 endTest();
80 if (window.testRunner)
82 localMovie = testRunner.pathToLocalResource(localMovie);
83 testRunner.dumpAsText();
84 testRunner.waitUntilDone();
86 setTimeout(hanged, 10000);
88 function test()
90 video = document.getElementById("vid");
92 video.addEventListener("error", error);
93 video.addEventListener('loadedmetadata', loadedmetadata);
95 // Create two <source> children, the first with a local url and the second
96 // with a remote url. The element should load the second.
97 var src1 = document.createElement("source");
98 src1.setAttribute("src", localMovie);
100 if (video.canPlayType("video/mp4"))
101 remoteUrl += ".mp4";
102 else if (video.canPlayType("video/ogg"))
103 remoteUrl += ".ogv";
104 else {
105 logResult("Missing test movie for this platform???", false);
106 endTest();
109 var src2 = document.createElement("source");
110 src2.setAttribute("src", remoteUrl);
112 video.appendChild(src1);
113 video.appendChild(src2);
115 </script>
117 </head>
119 <body onLoad="test()">
121 <video id='vid' controls></video>
123 <p>Test that a remote video element will not use a local &lt;source&gt;, and will
124 use another remote &lt;source&gt;</p>
126 <p>This test only behaves correctly in DRT</p>
128 </body>
129 </html>