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