content/media/test/seek6.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.

     1 function test_seek6(v, seekTime, is, ok, finish) {
     3 // Test for bug identified by Chris Pearce in comment 40 on
     4 // bug 449159.
     5 var seekCount = 0;
     6 var completed = false;
     7 var interval;
     8 var sum = 0;
    10 function poll() {
    11   sum += v.currentTime;
    12 }
    14 function startTest() {
    15   if (completed)
    16     return;
    17   interval = setInterval(poll, 10);
    18   v.currentTime = Math.random() * v.duration;
    19 }
    21 function seekEnded() {
    22   if (completed)
    23     return;
    25   seekCount++;
    26   ok(true, "Seek " + seekCount);
    27   if (seekCount == 3) {
    28     clearInterval(interval);
    29     completed = true;
    30     finish();
    31   } else {
    32     v.currentTime = Math.random() * v.duration;
    33   }
    34 }
    36 v.addEventListener("loadedmetadata", startTest, false);
    37 v.addEventListener("seeked", seekEnded, false);
    39 }

mercurial