|
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 type="application/javascript" 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> |
|
12 |
|
13 var gRegisteredElements = []; |
|
14 var gLog = false; |
|
15 var testWindows = []; |
|
16 |
|
17 function log(msg) { |
|
18 if (gLog) { |
|
19 document.getElementById('log').innerHTML += "<p>"+msg+"</p>"; |
|
20 dump(msg + "\n"); |
|
21 } |
|
22 } |
|
23 |
|
24 function register(v) { |
|
25 gRegisteredElements.push(v); |
|
26 } |
|
27 |
|
28 function loaded() { |
|
29 log("onload fired!"); |
|
30 |
|
31 for (var i = 0; i < gRegisteredElements.length; ++i) { |
|
32 var v = gRegisteredElements[i]; |
|
33 ok(v.readyState >= v.HAVE_CURRENT_DATA, |
|
34 v._name + ":" + v.id + " is not ready before onload fired (" + v.readyState + ")"); |
|
35 } |
|
36 |
|
37 for (i=0; i<testWindows.length; ++i) { |
|
38 testWindows[i].close(); |
|
39 } |
|
40 |
|
41 mediaTestCleanup(); |
|
42 |
|
43 SimpleTest.finish(); |
|
44 } |
|
45 |
|
46 addLoadEvent(loaded); |
|
47 |
|
48 |
|
49 </script> |
|
50 </head> |
|
51 <body> |
|
52 <a target="_blank" href="https://bugzilla.mozilla.org/show_bug.cgi?id=479711">Mozilla Bug 479711</a> |
|
53 <p id="display"></p> |
|
54 <div id="content" style="display: none"> |
|
55 |
|
56 </div> |
|
57 |
|
58 |
|
59 <div id="log" style="font-size: small;"></div> |
|
60 <pre id="test"> |
|
61 <script type="application/javascript"> |
|
62 |
|
63 /** Test for Bug 479711 **/ |
|
64 |
|
65 function createVideo(name, type, id) { |
|
66 var v = document.createElement("video"); |
|
67 // Make sure each video is a unique resource |
|
68 v.src = name + "?" + id; |
|
69 v._name = name; |
|
70 v.id = id; |
|
71 register(v); |
|
72 return v; |
|
73 } |
|
74 |
|
75 var test = getPlayableVideo(gSmallTests); |
|
76 |
|
77 // Straightforward add, causing a load. |
|
78 var v = createVideo(test.name, test.type, "1"); |
|
79 document.body.appendChild(v); |
|
80 |
|
81 // Load, add, then remove. |
|
82 v = createVideo(test.name, test.type, "1"); |
|
83 v.load(); |
|
84 document.body.appendChild(v); |
|
85 v.parentNode.removeChild(v); |
|
86 |
|
87 // Load and add. |
|
88 v = createVideo(test.name, test.type, "2"); |
|
89 v.load(); |
|
90 document.body.appendChild(v); |
|
91 |
|
92 // Load outside of doc. |
|
93 v = createVideo(test.name, test.type, "3"); |
|
94 v.load(); |
|
95 |
|
96 // Open a new window for the following test. We open it here instead of in |
|
97 // the event handler to ensure that our document load event doesn't fire while |
|
98 // window.open is spinning the event loop. |
|
99 var w = window.open("", "testWindow", "width=400,height=400"); |
|
100 testWindows.push(w); |
|
101 |
|
102 v = createVideo(test.name, test.type, "4"); |
|
103 v.onloadstart = function(e) { |
|
104 // Using a new window to do this is a bit annoying, but if we use an iframe here, |
|
105 // delaying of the iframe's load event might interfere with the firing of our load event |
|
106 // in some confusing way. So it's simpler just to use another window. |
|
107 w.document.body.appendChild(v); |
|
108 }; |
|
109 v.load(); // load started while in this document, this doc's load will block until |
|
110 // the video's finished loading (in the other document). |
|
111 |
|
112 if (gRegisteredElements.length > 0) { |
|
113 SimpleTest.waitForExplicitFinish(); |
|
114 } else { |
|
115 todo(false, "No types supported"); |
|
116 } |
|
117 |
|
118 </script> |
|
119 </pre> |
|
120 </body> |
|
121 </html> |