Tue, 06 Jan 2015 21:39:09 +0100
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 | <head> |
michael@0 | 4 | <title>Media test: seeking off the end of a file</title> |
michael@0 | 5 | <script type="text/javascript" src="/tests/SimpleTest/SimpleTest.js"></script> |
michael@0 | 6 | <link rel="stylesheet" type="text/css" href="/tests/SimpleTest/test.css" /> |
michael@0 | 7 | <script type="text/javascript" src="manifest.js"></script> |
michael@0 | 8 | </head> |
michael@0 | 9 | <body> |
michael@0 | 10 | <pre id="test"> |
michael@0 | 11 | <script class="testbody" type="text/javascript"> |
michael@0 | 12 | |
michael@0 | 13 | if (navigator.platform.startsWith("Win")) { |
michael@0 | 14 | SimpleTest.expectAssertions(0, 10); |
michael@0 | 15 | } |
michael@0 | 16 | |
michael@0 | 17 | var manager = new MediaTestManager; |
michael@0 | 18 | |
michael@0 | 19 | // Test if the ended event works correctly. |
michael@0 | 20 | |
michael@0 | 21 | function startTest(e) { |
michael@0 | 22 | var v = e.target; |
michael@0 | 23 | checkMetadata(v._name, v, v._test); |
michael@0 | 24 | is(v._loadedMetadata, false, "Should only receive one loadedmetadata event for " + v._name); |
michael@0 | 25 | v._loadedMetadata = true; |
michael@0 | 26 | v.currentTime = 3.0 * v.duration; |
michael@0 | 27 | } |
michael@0 | 28 | |
michael@0 | 29 | function playbackEnded(e) { |
michael@0 | 30 | var v = e.target; |
michael@0 | 31 | // We should have dispatched an ended event when we seeked to the end of |
michael@0 | 32 | // media, but we want the ended event which dispatches once playback has |
michael@0 | 33 | // completed after the seek to the beginning. |
michael@0 | 34 | if (!v._played) |
michael@0 | 35 | return; |
michael@0 | 36 | ok(v.ended, "Checking ended set after seeking to EOF and playing for " + v._name); |
michael@0 | 37 | ok(!v._finished, "Should only hit the end once for " + v._name); |
michael@0 | 38 | v._finished = true; |
michael@0 | 39 | removeNodeAndSource(v); |
michael@0 | 40 | manager.finished(v.token); |
michael@0 | 41 | } |
michael@0 | 42 | |
michael@0 | 43 | function endSeek(e) { |
michael@0 | 44 | var v = e.target; |
michael@0 | 45 | if (v._seeked) |
michael@0 | 46 | return; |
michael@0 | 47 | v._seeked = true; |
michael@0 | 48 | ok(Math.abs(v.duration - v.currentTime) < 0.1, |
michael@0 | 49 | "Should be at end of media for " + v._name + " t=" + v.currentTime + " d=" + v.duration); |
michael@0 | 50 | v.play(); |
michael@0 | 51 | } |
michael@0 | 52 | |
michael@0 | 53 | function playing(e) { |
michael@0 | 54 | e.target._played = true; |
michael@0 | 55 | } |
michael@0 | 56 | |
michael@0 | 57 | function initTest(test, token) { |
michael@0 | 58 | var type = getMajorMimeType(test.type); |
michael@0 | 59 | var v = document.createElement(type); |
michael@0 | 60 | v.preload = "auto"; |
michael@0 | 61 | v.token = token; |
michael@0 | 62 | manager.started(token); |
michael@0 | 63 | v.src = test.name; |
michael@0 | 64 | v._name = test.name; |
michael@0 | 65 | v._finished = false; |
michael@0 | 66 | v._test = test; |
michael@0 | 67 | v._loadedMetadata = false; |
michael@0 | 68 | v._seeked = false; |
michael@0 | 69 | v._played = false; |
michael@0 | 70 | v.addEventListener("loadedmetadata", startTest, false); |
michael@0 | 71 | v.addEventListener("playing", playing, false); |
michael@0 | 72 | v.addEventListener("seeked", endSeek, false); |
michael@0 | 73 | v.addEventListener("ended", playbackEnded, false); |
michael@0 | 74 | document.body.appendChild(v); |
michael@0 | 75 | } |
michael@0 | 76 | |
michael@0 | 77 | manager.runTests(gSmallTests, initTest); |
michael@0 | 78 | |
michael@0 | 79 | </script> |
michael@0 | 80 | </pre> |
michael@0 | 81 | </body> |
michael@0 | 82 | </html> |