tor-browser

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

cancel-watch-availability.html (2190B)


      1 <!DOCTYPE html>
      2 <html>
      3  <title>Tests cancelWatchAvailability()</title>
      4  <script src="/resources/testharness.js"></script>
      5  <script src="/resources/testharnessreport.js"></script>
      6  <script src="/common/media.js"></script>
      7  <script>
      8    async_test(t => {
      9      let v = document.createElement("video");
     10      v.src = getVideoURI("/media/movie_5");
     11 
     12      v.remote
     13        .watchAvailability(() => {})
     14        .then(
     15          t.step_func(id => {
     16            v.remote.cancelWatchAvailability(id).then(
     17              t.step_func(() => {
     18                v.remote.cancelWatchAvailability(id).then(
     19                  t.unreached_func(),
     20                  t.step_func_done(e => {
     21                    assert_equals(e.name, "NotFoundError");
     22                  })
     23                );
     24              }),
     25              t.unreached_func()
     26            );
     27          }),
     28          t.unreached_func()
     29        );
     30    }, "Test that calling cancelWatchAvailability() with an id does remove the callback, and calling cancelWatchAvailability with a removed id throws NotFoundError.");
     31 
     32    async_test(t => {
     33      let v = document.createElement("video");
     34      v.src = getVideoURI("/media/movie_5");
     35 
     36      Promise.all([
     37        v.remote.watchAvailability(() => {}),
     38        v.remote.watchAvailability(() => {}),
     39      ]).then(
     40        t.step_func(ids =>
     41          v.remote.cancelWatchAvailability().then(
     42            t.step_func(() =>
     43              v.remote.cancelWatchAvailability(ids[0]).then(
     44                t.unreached_func(),
     45                t.step_func(e => {
     46                  assert_equals(e.name, "NotFoundError");
     47                  v.remote.cancelWatchAvailability(ids[1]).then(
     48                    t.unreached_func(),
     49                    t.step_func_done(e =>
     50                      assert_equals(e.name, "NotFoundError")
     51                    )
     52                  );
     53                })
     54              )
     55            ),
     56            t.unreached_func()
     57          )
     58        ),
     59        t.unreached_func()
     60      );
     61    }, "Test that calling cancelWatchAvailability() without an id removes all the callbacks, and calling cancelWatchAvailability() with a removed id throws NotFoundError.");
     62  </script>
     63 </html>