Bug 1839170 - Refactor Snap pulling, Add Firefox Snap Core22 and GNOME 42 SDK symbols...
[gecko.git] / dom / media / test / test_delay_load.html
blob05877aa911f043f083ba46bc8b3b396860b38833
1 <!DOCTYPE HTML>
2 <html>
3 <!--
4 https://bugzilla.mozilla.org/show_bug.cgi?id=479711
5 -->
6 <head>
7 <title>Test for Bug 479711</title>
8 <script src="/tests/SimpleTest/SimpleTest.js"></script>
9 <link rel="stylesheet" type="text/css" href="/tests/SimpleTest/test.css"/>
10 <script type="text/javascript" src="manifest.js"></script>
11 <script>
13 var gRegisteredElements = [];
14 var testWindows = [];
16 function register(v) {
17 gRegisteredElements.push(v);
20 function loaded() {
21 info("onload fired!");
23 for (var i = 0; i < gRegisteredElements.length; ++i) {
24 var v = gRegisteredElements[i];
25 ok(v.readyState >= v.HAVE_CURRENT_DATA,
26 v._name + ":" + v.id + " is not ready before onload fired (" + v.readyState + ")");
29 for (i=0; i<testWindows.length; ++i) {
30 testWindows[i].close();
33 mediaTestCleanup();
35 SimpleTest.finish();
38 addLoadEvent(loaded);
40 </script>
41 </head>
42 <body>
43 <a target="_blank" href="https://bugzilla.mozilla.org/show_bug.cgi?id=479711">Mozilla Bug 479711</a>
44 <p id="display"></p>
45 <div id="content" style="display: none"></div>
46 <pre id="test">
47 <script type="application/javascript">
49 /** Test for Bug 479711 **/
51 function createVideo(name, type, id) {
52 var v = document.createElement("video");
53 v.preload = "metadata";
54 // Make sure each video is a unique resource
55 v.src = name + "?" + id;
56 v._name = name;
57 v.id = id;
58 register(v);
59 return v;
62 var test = getPlayableVideo(gSmallTests);
64 // Straightforward add, causing a load.
65 var v = createVideo(test.name, test.type, "1");
66 document.body.appendChild(v);
68 // Load, add, then remove.
69 v = createVideo(test.name, test.type, "1");
70 v.load();
71 document.body.appendChild(v);
72 v.remove();
74 // Load and add.
75 v = createVideo(test.name, test.type, "2");
76 v.load();
77 document.body.appendChild(v);
79 // Load outside of doc.
80 v = createVideo(test.name, test.type, "3");
81 v.load();
83 // Open a new window for the following test. We open it here instead of in
84 // the event handler to ensure that our document load event doesn't fire while
85 // window.open is spinning the event loop.
86 var w = window.open("", "testWindow", "width=400,height=400");
87 testWindows.push(w);
89 v = createVideo(test.name, test.type, "4");
90 v.onloadstart = function(e) {
91 // Using a new window to do this is a bit annoying, but if we use an iframe here,
92 // delaying of the iframe's load event might interfere with the firing of our load event
93 // in some confusing way. So it's simpler just to use another window.
94 w.document.body.appendChild(v);
96 v.load(); // load started while in this document, this doc's load will block until
97 // the video's finished loading (in the other document).
99 if (gRegisteredElements.length) {
100 SimpleTest.waitForExplicitFinish();
101 } else {
102 todo(false, "No types supported");
105 </script>
106 </pre>
107 </body>
108 </html>