tor-browser

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

clients-matchall.https.html (1770B)


      1 <!DOCTYPE html>
      2 <title>Service Worker: Clients.matchAll</title>
      3 <script src="/resources/testharness.js"></script>
      4 <script src="/resources/testharnessreport.js"></script>
      5 <script src="resources/test-helpers.sub.js"></script>
      6 <script>
      7 var scope = 'resources/blank.html?clients-matchAll';
      8 var frames = [];
      9 promise_test(function(t) {
     10    return service_worker_unregister_and_register(
     11        t, 'resources/clients-matchall-worker.js', scope)
     12      .then(function(registration) {
     13          t.add_cleanup(function() {
     14              return service_worker_unregister(t, scope);
     15            });
     16 
     17          return wait_for_state(t, registration.installing, 'activated');
     18        })
     19      .then(function() { return with_iframe(scope + '#1'); })
     20      .then(function(frame1) {
     21          frames.push(frame1);
     22          frame1.focus();
     23          return with_iframe(scope + '#2');
     24        })
     25      .then(function(frame2) {
     26          frames.push(frame2);
     27          var channel = new MessageChannel();
     28 
     29          return new Promise(function(resolve) {
     30              channel.port1.onmessage = resolve;
     31              frame2.contentWindow.navigator.serviceWorker.controller.postMessage(
     32                  {port:channel.port2}, [channel.port2]);
     33            });
     34        })
     35      .then(onMessage);
     36 }, 'Test Clients.matchAll()');
     37 
     38 var expected = [
     39    // visibilityState, focused, url, type, frameType
     40    ['visible', true, new URL(scope + '#1', location).toString(), 'window', 'nested'],
     41    ['visible', false, new URL(scope + '#2', location).toString(), 'window', 'nested']
     42 ];
     43 
     44 function onMessage(e) {
     45  assert_equals(e.data.length, 2);
     46  assert_array_equals(e.data[0], expected[0]);
     47  assert_array_equals(e.data[1], expected[1]);
     48  frames.forEach(function(f) { f.remove(); });
     49 }
     50 </script>