content/media/test/fragment_play.js

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 function test_fragment_play(v, start, end, is, ok, finish) {
michael@0 2
michael@0 3 var completed = false;
michael@0 4 var loadedMetadataRaised = false;
michael@0 5 var seekedRaised = false;
michael@0 6 var pausedRaised = false;
michael@0 7
michael@0 8 function onLoadedMetadata() {
michael@0 9 var s = start == null ? 0 : start;
michael@0 10 var e = end == null ? v.duration : end;
michael@0 11 ok(v.currentTime == s, "loadedmetadata currentTime is " + v.currentTime + " != " + s);
michael@0 12 ok(v.mozFragmentEnd == e, "mozFragmentEnd (" + v.mozFragmentEnd + ") == end Time (" + e + ")");
michael@0 13 loadedMetadataRaised = true;
michael@0 14 v.play();
michael@0 15 }
michael@0 16
michael@0 17 function onSeeked() {
michael@0 18 if (completed)
michael@0 19 return;
michael@0 20
michael@0 21 var s = start == null ? 0 : start;
michael@0 22 ok(v.currentTime == s, "seeked currentTime is " + v.currentTime + " != " + s);
michael@0 23
michael@0 24 seekedRaised = true;
michael@0 25 }
michael@0 26
michael@0 27 function onTimeUpdate() {
michael@0 28 if (completed)
michael@0 29 return;
michael@0 30
michael@0 31 v._lastTimeUpdate = v.currentTime;
michael@0 32 }
michael@0 33
michael@0 34 function onPause() {
michael@0 35 if (completed)
michael@0 36 return;
michael@0 37
michael@0 38 var e = end == null ? v.duration : end;
michael@0 39 var a = e - 0.05;
michael@0 40 var b = e + 0.05;
michael@0 41 ok(v.currentTime >= a && v.currentTime <= b, "paused currentTime is " + a + " < " + v.currentTime + " < " + b + " ? " + v._lastTimeUpdate);
michael@0 42 pausedRaised = true;
michael@0 43 v.play();
michael@0 44 }
michael@0 45
michael@0 46
michael@0 47 function onEnded() {
michael@0 48 if (completed)
michael@0 49 return;
michael@0 50
michael@0 51 completed = true;
michael@0 52 ok(loadedMetadataRaised, "loadedmetadata event");
michael@0 53 if (start) {
michael@0 54 ok(seekedRaised, "seeked event");
michael@0 55 }
michael@0 56 if (end) {
michael@0 57 ok(pausedRaised, "paused event: " + end + " " + v.duration);
michael@0 58 }
michael@0 59 finish();
michael@0 60 }
michael@0 61
michael@0 62 v.addEventListener("ended", onEnded, false);
michael@0 63 v.addEventListener("loadedmetadata", onLoadedMetadata, false);
michael@0 64 v.addEventListener("seeked", onSeeked, false);
michael@0 65 v.addEventListener("pause", onPause, false);
michael@0 66 v.addEventListener("timeupdate", onTimeUpdate, false);
michael@0 67 }

mercurial