Bug 1343308 P2 Add a WPT test verifying Clients.matchAll() only returns Clients controlled by calling worker. r=baku
authorBen Kelly <ben@wanderview.com>
Wed, 01 Mar 2017 13:08:55 -0500
changeset 374370 b8a79ad3b03e21a21477d1d03311e623e277680d
parent 374369 1a34bdb0c31a69914719d5b68e05781e4e62b81c
child 374371 51bf67737ecb58976dcbe96d0771f28268a0ee5d
push id10863
push userjlorenzo@mozilla.com
push dateMon, 06 Mar 2017 23:02:23 +0000
treeherdermozilla-aurora@0931190cd725 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersbaku
bugs1343308
milestone54.0a1
Bug 1343308 P2 Add a WPT test verifying Clients.matchAll() only returns Clients controlled by calling worker. r=baku
testing/web-platform/meta/MANIFEST.json
testing/web-platform/tests/service-workers/service-worker/clients-matchall-exact-controller.https.html
--- a/testing/web-platform/meta/MANIFEST.json
+++ b/testing/web-platform/meta/MANIFEST.json
@@ -118625,16 +118625,22 @@
     ]
    ],
    "service-workers/service-worker/clients-matchall-client-types.https.html": [
     [
      "/service-workers/service-worker/clients-matchall-client-types.https.html",
      {}
     ]
    ],
+   "service-workers/service-worker/clients-matchall-exact-controller.https.html": [
+    [
+     "/service-workers/service-worker/clients-matchall-exact-controller.https.html",
+     {}
+    ]
+   ],
    "service-workers/service-worker/clients-matchall-include-uncontrolled.https.html": [
     [
      "/service-workers/service-worker/clients-matchall-include-uncontrolled.https.html",
      {}
     ]
    ],
    "service-workers/service-worker/clients-matchall-order.https.html": [
     [
@@ -199806,16 +199812,20 @@
   "service-workers/service-worker/clients-get.https.html": [
    "32ccf7734a7d0d40205c4fd30b393b175e6507bd",
    "testharness"
   ],
   "service-workers/service-worker/clients-matchall-client-types.https.html": [
    "aaca38d0ad5e6a03775632fcef1657dd40753ae0",
    "testharness"
   ],
+  "service-workers/service-worker/clients-matchall-exact-controller.https.html": [
+   "231ce3ee744eeb670e00ee3a670ba361d5ca0707",
+   "testharness"
+  ],
   "service-workers/service-worker/clients-matchall-include-uncontrolled.https.html": [
    "a4f4cb575ffea826c642aa3de424c0a0f986fdd0",
    "testharness"
   ],
   "service-workers/service-worker/clients-matchall-order.https.html": [
    "b2617b7dce0dce64c1a354a3dc07c67f1fa0adf2",
    "testharness"
   ],
new file mode 100644
--- /dev/null
+++ b/testing/web-platform/tests/service-workers/service-worker/clients-matchall-exact-controller.https.html
@@ -0,0 +1,68 @@
+<!DOCTYPE html>
+<title>Service Worker: Clients.matchAll with exact controller</title>
+<script src="/resources/testharness.js"></script>
+<script src="/resources/testharnessreport.js"></script>
+<script src="resources/test-helpers.sub.js"></script>
+<script>
+const scope = 'resources/blank.html?clients-matchAll';
+const t = async_test('Test Clients.matchAll() with exact controller');
+let frames = [];
+
+function checkWorkerClients(worker, expected) {
+  return new Promise((resolve, reject) => {
+    let channel = new MessageChannel();
+    channel.port1.onmessage = evt => {
+      try {
+        assert_equals(evt.data.length, expected.length);
+        for (let i = 0; i < expected.length; ++i) {
+          assert_array_equals(evt.data[i], expected[i]);
+        }
+        resolve();
+      } catch (e) {
+        reject(e);
+      }
+    };
+
+    worker.postMessage({port:channel.port2}, [channel.port2]);
+  });
+}
+
+let expected = [
+    /* visibilityState, focused, url, frameType */
+    ['visible', true, new URL(scope + '#1', location).toString(), 'window', 'nested'],
+    ['visible', false, new URL(scope + '#2', location).toString(), 'window', 'nested']
+];
+
+t.step(_ => {
+    let script = 'resources/clients-matchall-worker.js';
+    service_worker_unregister_and_register(t, script, scope)
+      .then(registration => {
+          return wait_for_state(t, registration.installing, 'activated');
+        })
+      .then(_ => with_iframe(scope + '#1') )
+      .then(frame1 => {
+          frames.push(frame1);
+          frame1.focus();
+          return with_iframe(scope + '#2');
+        })
+      .then(frame2 => {
+          frames.push(frame2);
+          return navigator.serviceWorker.register(script + '?updated', { scope: scope });
+        })
+      .then(registration => {
+          return wait_for_state(t, registration.installing, 'installed')
+            .then(_ => registration);
+        })
+      .then(registration => {
+          return Promise.all([
+            checkWorkerClients(registration.waiting, []),
+            checkWorkerClients(registration.active, expected),
+          ]);
+        })
+      .then(_ => {
+          frames.forEach(f => f.remove() );
+          service_worker_unregister_and_done(t, scope);
+        })
+      .catch(unreached_rejection(t));
+  });
+</script>