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: chained ogg files.</title> |
michael@0 | 5 | <meta charset='utf-8'> |
michael@0 | 6 | <script type="text/javascript" src="/MochiKit/Base.js"></script> |
michael@0 | 7 | <script type="text/javascript" src="/MochiKit/DOM.js"></script> |
michael@0 | 8 | <script type="text/javascript" src="/MochiKit/Style.js"></script> |
michael@0 | 9 | <script type="text/javascript" src="/MochiKit/Signal.js"></script> |
michael@0 | 10 | <script type="text/javascript" src="/tests/SimpleTest/SimpleTest.js"></script> |
michael@0 | 11 | <link rel="stylesheet" type="text/css" href="/tests/SimpleTest/test.css" /> |
michael@0 | 12 | <script type="text/javascript" src="manifest.js"></script> |
michael@0 | 13 | </head> |
michael@0 | 14 | <body> |
michael@0 | 15 | <pre id="test"> |
michael@0 | 16 | <script class="testbody" type="text/javascript"> |
michael@0 | 17 | var manager = new MediaTestManager; |
michael@0 | 18 | |
michael@0 | 19 | function finish_test(element) { |
michael@0 | 20 | if (element.parentNode) |
michael@0 | 21 | element.parentNode.removeChild(element); |
michael@0 | 22 | manager.finished(element.token); |
michael@0 | 23 | } |
michael@0 | 24 | |
michael@0 | 25 | function onended(e) { |
michael@0 | 26 | var t = e.target; |
michael@0 | 27 | is(t._metadataCount, t._links, "We should have received "+ t._links + |
michael@0 | 28 | " metadataloaded event. " + t.src); |
michael@0 | 29 | |
michael@0 | 30 | // If we encounter a file that has links with a different numbers of channel, |
michael@0 | 31 | // we stop the decoding at the end of the first link. Hence, we report normal |
michael@0 | 32 | // |seekable| and |buffered| values. |
michael@0 | 33 | if (t._links != 1) { |
michael@0 | 34 | is(t.seekable.length, 0, "No seekable ranges should be reported." + t.src); |
michael@0 | 35 | is(t.buffered.length, 0, "No buffered region should be reported." + t.src); |
michael@0 | 36 | } |
michael@0 | 37 | |
michael@0 | 38 | is(t.played.length, 1, "The played region should be continuous." + t.src); |
michael@0 | 39 | |
michael@0 | 40 | if (t._links != 1) { |
michael@0 | 41 | var oldCurrentTime = t.currentTime; |
michael@0 | 42 | t.currentTime = 0.0; |
michael@0 | 43 | is(t.currentTime, oldCurrentTime, |
michael@0 | 44 | "Seeking should be disabled when playing chained media." + t.src); |
michael@0 | 45 | } |
michael@0 | 46 | |
michael@0 | 47 | finish_test(t); |
michael@0 | 48 | } |
michael@0 | 49 | |
michael@0 | 50 | function onmetadataloaded(e) { |
michael@0 | 51 | var t = e.target; |
michael@0 | 52 | if (! t._metadataCount) { |
michael@0 | 53 | t._metadataCount = 0; |
michael@0 | 54 | } |
michael@0 | 55 | |
michael@0 | 56 | if (t._metadataCount > 1 && t._links === 1) { |
michael@0 | 57 | ok(false, "We should receive only one \"loadedmetadata\" event for a chained file we don't support.") |
michael@0 | 58 | } |
michael@0 | 59 | |
michael@0 | 60 | // We should be able to assert equality here, but somehow it fails (rarely but |
michael@0 | 61 | // still) on try. Instead, we give it a little slack and assert that the index |
michael@0 | 62 | // increases monotonically. |
michael@0 | 63 | ok(t.mozGetMetadata().index >= t._metadataCount || t._links === 1, |
michael@0 | 64 | "The metadata index value should increase." + t.src); |
michael@0 | 65 | |
michael@0 | 66 | // The files have all a user comment name 'index' that increments at each link |
michael@0 | 67 | // in the chained media. |
michael@0 | 68 | t._metadataCount++; |
michael@0 | 69 | if (!t.playing && !t.ended) { |
michael@0 | 70 | t.play(); |
michael@0 | 71 | } |
michael@0 | 72 | } |
michael@0 | 73 | |
michael@0 | 74 | function startTest(test, token) { |
michael@0 | 75 | var elemType = /^audio/.test(test.type) ? "audio" : "video"; |
michael@0 | 76 | var element = document.createElement(elemType); |
michael@0 | 77 | document.body.appendChild(element); |
michael@0 | 78 | manager.started(token); |
michael@0 | 79 | element._links= test.links; |
michael@0 | 80 | element.src = test.name; |
michael@0 | 81 | element.token = token; |
michael@0 | 82 | element.controls = true; |
michael@0 | 83 | element.addEventListener("loadedmetadata", onmetadataloaded); |
michael@0 | 84 | element.addEventListener("ended", onended); |
michael@0 | 85 | } |
michael@0 | 86 | |
michael@0 | 87 | manager.runTests(gChainingTests, startTest); |
michael@0 | 88 | </script> |
michael@0 | 89 | </pre> |
michael@0 | 90 | </body> |
michael@0 | 91 | </html> |