tor-browser

The Tor Browser
git clone https://git.dasho.dev/tor-browser.git
Log | Files | Refs | README | LICENSE

test_background_video_ended_event.html (1510B)


      1 <!DOCTYPE html>
      2 <meta charset="utf-8">
      3 <title>Test Background Video Suspends</title>
      4 <script src="/tests/SimpleTest/SimpleTest.js"></script>
      5 <script src="manifest.js"></script>
      6 <script src="background_video.js"></script>
      7 <link rel="stylesheet" href="/tests/SimpleTest/test.css"/>
      8 <script type="text/javascript">
      9 "use strict";
     10 
     11 var manager = new MediaTestManager;
     12 
     13 startTest({
     14  desc: "Test background video doesn't fire the 'ended' event twice.",
     15  prefs: [
     16    [ "media.test.video-suspend", true ],
     17    [ "media.suspend-background-video.enabled", true ],
     18    [ "media.suspend-background-video.delay-ms", 100 ]
     19  ],
     20  tests: gDecodeSuspendTests,
     21  runTest: (test, token) => {
     22    let v = appendVideoToDoc(test.name, token);
     23    manager.started(token);
     24 
     25    let count = 0;
     26    v.addEventListener("ended", function() {
     27      is(++count, 1, `${token} should get only one 'ended' event.`);
     28    });
     29 
     30    /*
     31     * This test checks that, after a video element had finished its playback,
     32     * resuming video decoder doesn't dispatch 2nd ended event.
     33     * This issue was found in bug 1349097.
     34     */
     35    waitUntilPlaying(v)
     36      .then(() => testVideoSuspendsWhenHidden(v))
     37      .then(() => waitUntilEnded(v))
     38      .then(() => testVideoResumesWhenShown(v))
     39      .then(() => {
     40        // Wait for a while and finish the test. We should get only one 'ended' event.
     41        setTimeout(function() {
     42          removeNodeAndSource(v);
     43          manager.finished(token);
     44        }, 3000);
     45      });
     46  }
     47 });
     48 </script>