tor-browser

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

prompt-and-watch-availability-with-device-manual.html (1785B)


      1 <!DOCTYPE html>
      2 <html>
      3  <title>
      4    Test that watchAvailability() runs the callback with true when user selects a device
      5  </title>
      6  <script src="/resources/testharness.js"></script>
      7  <script src="/resources/testharnessreport.js"></script>
      8  <script src="/common/media.js"></script>
      9  <script>
     10    setup({ explicit_timeout: true });
     11  </script>
     12  <body>
     13    <div id="prep">
     14      <p>Please make sure a device for remote playback is <b>available.</b></p>
     15      <button id="prompt-button-prep">Show devices</button>
     16      <button id="start-button">Start test</button>
     17    </div>
     18    <div id="pick-device" style="display: none">
     19      <p>
     20        Click the button below to prompt for a remote playback device and select
     21        one!
     22      </p>
     23      <button id="prompt-button">Pick device</button>
     24    </div>
     25  </body>
     26  <script src="./prepare-device.js"></script>
     27  <script>
     28    let v = document.createElement("video");
     29    v.src = getVideoURI("/media/movie_5");
     30 
     31    async_test(t => {
     32      let deviceAvailable = false;
     33      let button = document.getElementById("prompt-button");
     34      button.onclick = () => {
     35        v.remote
     36          .watchAvailability(t.step_func(avail => (deviceAvailable = avail)))
     37          .then(
     38            t.step_func(() => {
     39              v.remote
     40                .prompt()
     41                .then(() => {
     42                  assert_true(deviceAvailable);
     43                  t.done();
     44                })
     45                .catch(
     46                  t.unreached_func(
     47                    "Selecting a remote device was not successful."
     48                  )
     49                );
     50            }),
     51            t.unreached_func()
     52          );
     53      };
     54    }, "Test that watchAvailability() runs the callback with true when user selects a device.");
     55  </script>
     56 </html>