content/media/test/test_timeupdate_small_files.html

Tue, 06 Jan 2015 21:39:09 +0100

author
Michael Schloh von Bennewitz <michael@schloh.com>
date
Tue, 06 Jan 2015 21:39:09 +0100
branch
TOR_BUG_9701
changeset 8
97036ab72558
permissions
-rw-r--r--

Conditionally force memory storage according to privacy.thirdparty.isolate;
This solves Tor bug #9701, complying with disk avoidance documented in
https://www.torproject.org/projects/torbrowser/design/#disk-avoidance.

michael@0 1 <!DOCTYPE HTML>
michael@0 2 <html>
michael@0 3 <!--
michael@0 4 https://bugzilla.mozilla.org/show_bug.cgi?id=495319
michael@0 5 -->
michael@0 6
michael@0 7 <head>
michael@0 8 <title>Bug 495319 - playing back small audio files should fire timeupdate</title>
michael@0 9 <script type="text/javascript" src="/tests/SimpleTest/SimpleTest.js"></script>
michael@0 10 <link rel="stylesheet" type="text/css" href="/tests/SimpleTest/test.css" />
michael@0 11 <script type="text/javascript" src="manifest.js"></script>
michael@0 12 </head>
michael@0 13 <body>
michael@0 14 <a target="_blank" href="https://bugzilla.mozilla.org/show_bug.cgi?id=495319">Mozilla Bug 495319</a>
michael@0 15 <pre id="test">
michael@0 16 <script class="testbody" type="text/javascript">
michael@0 17
michael@0 18 var manager = new MediaTestManager;
michael@0 19
michael@0 20 function timeupdate(e) {
michael@0 21 var v = e.target;
michael@0 22 v._timeupdateCount++;
michael@0 23 ok(v.gotEnded == 0, v._name + " - shouldn't get timeupdate after ended");
michael@0 24 }
michael@0 25
michael@0 26 function ended(e) {
michael@0 27 var v = e.target;
michael@0 28 ++v.gotEnded;
michael@0 29 ok(v._timeupdateCount > 0, v._name + " - should see at least one timeupdate: " + v.currentTime);
michael@0 30 v._finished = true;
michael@0 31 // Finish the test after 500ms. We shouldn't receive any timeupdate events
michael@0 32 // after the ended event, so this gives time for any pending timeupdate events
michael@0 33 // to fire so we can ensure we don't regress behaviour.
michael@0 34 setTimeout(
michael@0 35 function() {
michael@0 36 // Remove the event listeners before removing the video from the document.
michael@0 37 // We should receive a timeupdate and pause event when we remove the element
michael@0 38 // from the document (as the element is specified to behave as if pause() was
michael@0 39 // invoked when it's removed from a document), and we don't want those
michael@0 40 // confusing the test results.
michael@0 41 v.removeEventListener("ended", ended, false);
michael@0 42 v.removeEventListener("timeupdate", timeupdate, false);
michael@0 43 for (var i = 0; i < eventsToLog.length; ++i) {
michael@0 44 v.removeEventListener(eventsToLog[i], logEvent, false);
michael@0 45 }
michael@0 46 removeNodeAndSource(v);
michael@0 47 manager.finished(v.token);
michael@0 48 },
michael@0 49 500);
michael@0 50 }
michael@0 51
michael@0 52 var eventsToLog = ["play", "canplay", "canplaythrough", "loadstart", "loadedmetadata",
michael@0 53 "loadeddata", "playing", "progress", "timeupdate", "ended", "suspend", "error", "stalled", "emptied", "abort",
michael@0 54 "waiting", "pause"];
michael@0 55 function logEvent(event) {
michael@0 56 if (event.target.gotEnded > (event.type == "ended" ? 1 : 0)) {
michael@0 57 if (event.target.currentSrc.slice(-9) == "seek.webm" && event.type == "stalled") {
michael@0 58 todo(false, event.target.currentSrc + " got unexpected stalled after ended (bug 760770)");
michael@0 59 } else {
michael@0 60 ok(false, event.target.currentSrc + " got unexpected " + event.type + " after ended");
michael@0 61 }
michael@0 62 } else {
michael@0 63 info(event.target.currentSrc + " got " + event.type);
michael@0 64 }
michael@0 65 }
michael@0 66
michael@0 67 function startTest(test, token) {
michael@0 68 var type = getMajorMimeType(test.type);
michael@0 69 var v = document.createElement(type);
michael@0 70 v.token = token;
michael@0 71 manager.started(token);
michael@0 72 v.src = test.name;
michael@0 73 v._name = test.name;
michael@0 74 v._timeupdateCount = 0;
michael@0 75 v._finished = false;
michael@0 76 v.gotEnded = 0;
michael@0 77 v.addEventListener("ended", ended, false);
michael@0 78 v.addEventListener("timeupdate", timeupdate, false);
michael@0 79 for (var i = 0; i < eventsToLog.length; ++i) {
michael@0 80 v.addEventListener(eventsToLog[i], logEvent, false);
michael@0 81 }
michael@0 82 document.body.appendChild(v);
michael@0 83 v.play();
michael@0 84 }
michael@0 85
michael@0 86 manager.runTests(gSmallTests, startTest);
michael@0 87
michael@0 88 </script>
michael@0 89 </pre>
michael@0 90 </body>
michael@0 91 </html>

mercurial