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 | <!-- |
michael@0 | 4 | https://bugzilla.mozilla.org/show_bug.cgi?id=778077 |
michael@0 | 5 | --> |
michael@0 | 6 | <head> |
michael@0 | 7 | <meta charset="utf-8"> |
michael@0 | 8 | <title>Test for Bug 778077</title> |
michael@0 | 9 | <script type="application/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=778077">Mozilla Bug 778077</a> |
michael@0 | 15 | <p id="display"></p> |
michael@0 | 16 | <div id="content" style="display: none"> |
michael@0 | 17 | |
michael@0 | 18 | </div> |
michael@0 | 19 | <pre id="test"> |
michael@0 | 20 | </pre> |
michael@0 | 21 | <script type="application/javascript"> |
michael@0 | 22 | |
michael@0 | 23 | /** Test for Bug 778077 - HTMLMediaElement.fastSeek() **/ |
michael@0 | 24 | // Iterate through a list of keyframe timestamps, and seek to |
michael@0 | 25 | // halfway between the keyframe and the keyframe after it. |
michael@0 | 26 | var manager = new MediaTestManager; |
michael@0 | 27 | |
michael@0 | 28 | function doSeek(v) { |
michael@0 | 29 | // fastSeek to half way between this keyframe and the next, or if this is the last |
michael@0 | 30 | // keyframe seek to halfway between this keyframe and the end of media. |
michael@0 | 31 | var nextKeyFrame = (v.keyframeIndex + 1) < v.keyframes.length ? v.keyframes[v.keyframeIndex + 1] : v.duration; |
michael@0 | 32 | v.target = (v.keyframes[v.keyframeIndex] + nextKeyFrame) / 2; |
michael@0 | 33 | v.fastSeek(v.target); |
michael@0 | 34 | ok(Math.abs(v.currentTime - v.target) < 0.01, |
michael@0 | 35 | v.name + " seekTo=" + v.target + " currentTime (" + v.currentTime + ") should be close to seek target initially"); |
michael@0 | 36 | } |
michael@0 | 37 | |
michael@0 | 38 | function onloadedmetadata(event) { |
michael@0 | 39 | var v = event.target; |
michael@0 | 40 | doSeek(v); |
michael@0 | 41 | } |
michael@0 | 42 | |
michael@0 | 43 | function onseeked(event) { |
michael@0 | 44 | var v = event.target; |
michael@0 | 45 | var keyframe = v.keyframes[v.keyframeIndex]; |
michael@0 | 46 | |
michael@0 | 47 | // Check that the current time ended up roughly after the keyframe. |
michael@0 | 48 | // We must be a bit fuzzy here, as the decoder backend may actually |
michael@0 | 49 | // seek to the audio sample prior to the keyframe. |
michael@0 | 50 | ok(v.currentTime >= keyframe - 0.05, |
michael@0 | 51 | v.name + " seekTo=" + v.target + " currentTime (" + v.currentTime + |
michael@0 | 52 | ") should be end up roughly after keyframe (" + keyframe + ") after fastSeek"); |
michael@0 | 53 | |
michael@0 | 54 | ok(v.currentTime <= v.target, |
michael@0 | 55 | v.name + " seekTo=" + v.target + " currentTime (" + v.currentTime + |
michael@0 | 56 | ") should be end up less than target after fastSeek"); |
michael@0 | 57 | |
michael@0 | 58 | v.keyframeIndex++ |
michael@0 | 59 | if (v.keyframeIndex == v.keyframes.length) { |
michael@0 | 60 | v.src = ""; |
michael@0 | 61 | v.parentNode.removeChild(v); |
michael@0 | 62 | manager.finished(v.token); |
michael@0 | 63 | } else { |
michael@0 | 64 | doSeek(v); |
michael@0 | 65 | } |
michael@0 | 66 | } |
michael@0 | 67 | |
michael@0 | 68 | function startTest(test, token) { |
michael@0 | 69 | manager.started(token); |
michael@0 | 70 | v = document.createElement("video"); |
michael@0 | 71 | v.src = test.name; |
michael@0 | 72 | v.name = test.name; |
michael@0 | 73 | v.preload = "metadata"; |
michael@0 | 74 | v.token = token; |
michael@0 | 75 | v.target = 0; |
michael@0 | 76 | v.keyframes = test.keyframes; |
michael@0 | 77 | v.keyframeIndex = 0; |
michael@0 | 78 | ok(v.keyframes.length > 0, v.name + " - video should have at least one sync point"); |
michael@0 | 79 | v.addEventListener("loadedmetadata", onloadedmetadata); |
michael@0 | 80 | v.addEventListener("seeked", onseeked); |
michael@0 | 81 | document.body.appendChild(v); |
michael@0 | 82 | } |
michael@0 | 83 | |
michael@0 | 84 | manager.runTests(gFastSeekTests, startTest); |
michael@0 | 85 | |
michael@0 | 86 | </script> |
michael@0 | 87 | </body> |
michael@0 | 88 | </html> |