Bug 1426979 P2 Make about-blank-replacement.https.html check simple about:blank and about:srcdoc cases. r=asuth
authorBen Kelly <ben@wanderview.com>
Wed, 10 Jan 2018 13:59:30 -0500
changeset 398673 a4c611046a0c977a82d0797af446a1b2fca2ee7a
parent 398672 1e1991807b395b83e2e1e7b1eb67ce00c479da2e
child 398674 36be4f8806ce195b201299beb1af66200294e381
push id33228
push useraciure@mozilla.com
push dateThu, 11 Jan 2018 09:55:35 +0000
treeherdermozilla-central@e61c4485494e [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersasuth
bugs1426979
milestone59.0a1
first release with
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
last release without
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
Bug 1426979 P2 Make about-blank-replacement.https.html check simple about:blank and about:srcdoc cases. r=asuth
testing/web-platform/meta/MANIFEST.json
testing/web-platform/tests/service-workers/service-worker/about-blank-replacement.https.html
testing/web-platform/tests/service-workers/service-worker/resources/about-blank-replacement-blank-dynamic-nested-frame.html
testing/web-platform/tests/service-workers/service-worker/resources/about-blank-replacement-blank-nested-frame.html
testing/web-platform/tests/service-workers/service-worker/resources/about-blank-replacement-srcdoc-nested-frame.html
--- a/testing/web-platform/meta/MANIFEST.json
+++ b/testing/web-platform/meta/MANIFEST.json
@@ -285056,31 +285056,46 @@
      {}
     ]
    ],
    "service-workers/service-worker/resources/404.py": [
     [
      {}
     ]
    ],
+   "service-workers/service-worker/resources/about-blank-replacement-blank-dynamic-nested-frame.html": [
+    [
+     {}
+    ]
+   ],
+   "service-workers/service-worker/resources/about-blank-replacement-blank-nested-frame.html": [
+    [
+     {}
+    ]
+   ],
    "service-workers/service-worker/resources/about-blank-replacement-frame.py": [
     [
      {}
     ]
    ],
    "service-workers/service-worker/resources/about-blank-replacement-ping-frame.py": [
     [
      {}
     ]
    ],
    "service-workers/service-worker/resources/about-blank-replacement-popup-frame.py": [
     [
      {}
     ]
    ],
+   "service-workers/service-worker/resources/about-blank-replacement-srcdoc-nested-frame.html": [
+    [
+     {}
+    ]
+   ],
    "service-workers/service-worker/resources/about-blank-replacement-uncontrolled-nested-frame.html": [
     [
      {}
     ]
    ],
    "service-workers/service-worker/resources/about-blank-replacement-worker.js": [
     [
      {}
@@ -529180,17 +529195,17 @@
    "9a4881ad5825e2c4e967226f537e4e5ae281c2fb",
    "reftest"
   ],
   "custom-elements/CustomElementRegistry.html": [
    "d1661ab1734f7d1a252030aeac7e9842a7a4cb3b",
    "testharness"
   ],
   "custom-elements/Document-createElement.html": [
-   "fb10e851deb193aed700c8ab6790c216766cc362",
+   "14960ee9498f6ff23c1c94d3351a8ef383e60067",
    "testharness"
   ],
   "custom-elements/HTMLElement-constructor.html": [
    "64522527ef425b90c704b20b000c8feef0d1ca25",
    "testharness"
   ],
   "custom-elements/OWNERS": [
    "9f6553b67cad3b479d3beb678653db4e712ed227",
@@ -529240,17 +529255,17 @@
    "b338f193a803ea679bbf0e041f71daf1e6d703f6",
    "testharness"
   ],
   "custom-elements/parser/parser-constructs-custom-element-synchronously.html": [
    "dc0ca4a066d9a05362a81b263594965763919e46",
    "testharness"
   ],
   "custom-elements/parser/parser-constructs-custom-elements-with-is.html": [
-   "7a7df7aab092906b5a753c0d122b971aff01517a",
+   "17145d44113ea88688060c6cfd10d162cd97e28b",
    "testharness"
   ],
   "custom-elements/parser/parser-constructs-custom-elements.html": [
    "228d4a90d57dc942692becc6f126ec9130b3a4e0",
    "testharness"
   ],
   "custom-elements/parser/parser-fallsback-to-unknown-element.html": [
    "2fbbd742bfdc3ab63c5d5f01160830451fe620d2",
@@ -536692,17 +536707,17 @@
    "99a355c63562aded2e2b252d989de332e8c12a0d",
    "testharness"
   ],
   "html/browsers/browsing-the-web/scroll-to-fragid/scroll-frag-percent-encoded.html": [
    "ac172eb5c05ee24b8e3059cbc68851729f1be943",
    "testharness"
   ],
   "html/browsers/browsing-the-web/scroll-to-fragid/scroll-to-anchor-name.html": [
-   "8de758988400b4b1acad6bb4c94069b4d0167c20",
+   "9bc91bc9bb368e8bf42810ed8aed936a6c9d581a",
    "testharness"
   ],
   "html/browsers/browsing-the-web/scroll-to-fragid/scroll-to-id-top.html": [
    "4a4da96ba43bd45b6723b852277c9169b56ec2e1",
    "testharness"
   ],
   "html/browsers/browsing-the-web/scroll-to-fragid/scroll-to-top.html": [
    "2dabab8b5505e7934c0977f1cf0975d4600981d5",
@@ -574228,17 +574243,17 @@
    "9fe4c10b921a84dc086cea47d48bb34fdbb28eee",
    "testharness"
   ],
   "service-workers/service-worker/ServiceWorkerGlobalScope/update.https.html": [
    "f574c7a96a1ca766445cd0b427b9963b18c62795",
    "testharness"
   ],
   "service-workers/service-worker/about-blank-replacement.https.html": [
-   "345259908d040e4f5d810ae7089dab8a8c909b0a",
+   "0eee8e63450cff5a2f67b6d71d565b99baddbb69",
    "testharness"
   ],
   "service-workers/service-worker/activate-event-after-install-state-change.https.html": [
    "9d1971d9b5dcb52a14a0d2313065e27766c0489a",
    "testharness"
   ],
   "service-workers/service-worker/activation-after-registration.https.html": [
    "913c58ba58de077b82d0ec9cc21258610b26fe97",
@@ -574480,17 +574495,17 @@
    "4aaa0b1995643f4e18c47d1947476a1a67fe997d",
    "testharness"
   ],
   "service-workers/service-worker/fetch-request-xhr.https.html": [
    "b30618dfe4c10370865229cbe9606cce8ed42040",
    "testharness"
   ],
   "service-workers/service-worker/fetch-response-taint.https.html": [
-   "217383b4dddcc6f984c4cc7cd5f99e1f9b86cdd1",
+   "154a52255d0aae9a99879389afba6214b803b08d",
    "testharness"
   ],
   "service-workers/service-worker/fetch-response-xhr.https.html": [
    "6b68ad7251c3daef1cd2bde8660f01c3e47b711f",
    "testharness"
   ],
   "service-workers/service-worker/fetch-waits-for-activate.https.html": [
    "04eeedc3f074aff32281a438acda62b7a6d86e2d",
@@ -574831,28 +574846,40 @@
   "service-workers/service-worker/resource-timing.https.html": [
    "a835a0baeb4fcc0c44e6be28502f89308464acc5",
    "testharness"
   ],
   "service-workers/service-worker/resources/404.py": [
    "567d0a7de3ef54adaa8339bb04632a2ecfcc57a5",
    "support"
   ],
+  "service-workers/service-worker/resources/about-blank-replacement-blank-dynamic-nested-frame.html": [
+   "bfd2c8e7acb010cd7b5a0076a9138d8584e5efab",
+   "support"
+  ],
+  "service-workers/service-worker/resources/about-blank-replacement-blank-nested-frame.html": [
+   "79cb319dbdbae7efb9abf3405c2bc76ad9f0bc0f",
+   "support"
+  ],
   "service-workers/service-worker/resources/about-blank-replacement-frame.py": [
    "2f22a4c92cfb7c7e8cfbe6f168872c2f5875867d",
    "support"
   ],
   "service-workers/service-worker/resources/about-blank-replacement-ping-frame.py": [
    "d632f7a565cb9619db802bff4cbc61310f6ddf4d",
    "support"
   ],
   "service-workers/service-worker/resources/about-blank-replacement-popup-frame.py": [
    "498a08b652ec0d867e8d2e173be954f69354a208",
    "support"
   ],
+  "service-workers/service-worker/resources/about-blank-replacement-srcdoc-nested-frame.html": [
+   "6a0d88da977057eb365dfc8bfb531558d7a1bd4a",
+   "support"
+  ],
   "service-workers/service-worker/resources/about-blank-replacement-uncontrolled-nested-frame.html": [
    "ab2ce3693bbc40943b7390c8d76f3601f52410ca",
    "support"
   ],
   "service-workers/service-worker/resources/about-blank-replacement-worker.js": [
    "487ea5fe465410ba3e88f3c8bd657009a99e6ad0",
    "support"
   ],
@@ -575824,17 +575851,17 @@
    "40ec7850c61a3ee7578f055d3eef87293cfad482",
    "testharness"
   ],
   "service-workers/service-worker/windowclient-navigate.https.html": [
    "828d8d920459541a37e747ac01376fdcac51ffb3",
    "testharness"
   ],
   "service-workers/service-worker/worker-interception.https.html": [
-   "2c5e8cb2b7be6d394aaa1400158d3f14895909f3",
+   "41f7e5e8da2c305370fddad83518cd0fa57547eb",
    "testharness"
   ],
   "service-workers/specgen.json": [
    "0d98c8249e25cd4c7a4d88f722cfe8f235fb7a66",
    "support"
   ],
   "service-workers/stub-3.1-service-worker-obj.html": [
    "26e7afb8569cc3c997c6338dc86bfbe7232a8c0e",
--- a/testing/web-platform/tests/service-workers/service-worker/about-blank-replacement.https.html
+++ b/testing/web-platform/tests/service-workers/service-worker/about-blank-replacement.https.html
@@ -53,42 +53,52 @@ function getClientIdByURL(worker, url) {
       }
       navigator.serviceWorker.removeEventListener('message', onMsg);
       resolve(evt.data.result);
     });
     worker.postMessage({ type: 'GET_CLIENT_ID', url: url.toString() });
   });
 }
 
-async function doAsyncTest(t, scope, extraSearchParams) {
+async function doAsyncTest(t, scope) {
   let reg = await service_worker_unregister_and_register(t, worker, scope);
   await wait_for_state(t, reg.installing, 'activated');
 
   // Load the scope as a frame.  We expect this in turn to have a nested
   // iframe.  The service worker will intercept the load of the nested
   // iframe and populate its body with the client ID of the initial
   // about:blank document it sees via clients.matchAll().
   let frame = await createFrameWithNestedWindow(scope);
   let initialResult = frame.contentWindow.nested().document.body.textContent;
   assert_false(initialResult.startsWith('failure:'), `result: ${initialResult}`);
 
+  assert_equals(frame.contentWindow.navigator.serviceWorker.controller.scriptURL,
+                frame.contentWindow.nested().navigator.serviceWorker.controller.scriptURL,
+                'nested about:blank should have same controlling service worker');
+
   // Next, ask the service worker to find the final client ID for the fully
   // loaded nested frame.
-  let nestedURL = new URL(scope, window.location);
-  nestedURL.searchParams.set('nested', true);
-  extraSearchParams = extraSearchParams || {};
-  for (let p in extraSearchParams) {
-    nestedURL.searchParams.set(p, extraSearchParams[p]);
-  }
+  let nestedURL = new URL(frame.contentWindow.nested().location);
   let finalResult = await getClientIdByURL(reg.active, nestedURL);
   assert_false(finalResult.startsWith('failure:'), `result: ${finalResult}`);
 
-  // The initial about:blank client and the final loaded client should have
-  // the same ID value.
-  assert_equals(initialResult, finalResult, 'client ID values should match');
+  // If the nested frame doesn't have a URL to load, then there is no fetch
+  // event and the body should be empty.  We can't verify the final client ID
+  // against anything.
+  if (nestedURL.href === 'about:blank' ||
+      nestedURL.href === 'about:srcdoc') {
+    assert_equals('', initialResult, 'about:blank text content should be blank');
+  }
+
+  // If the nested URL is not about:blank, though, then the fetch event handler
+  // should have populated the body with the client id of the initial about:blank.
+  // Verify the final client id matches.
+  else {
+    assert_equals(initialResult, finalResult, 'client ID values should match');
+  }
 
   frame.remove();
   await service_worker_unregister_and_done(t, scope);
 }
 
 promise_test(async function(t) {
   // Execute a test where the nested frame is simply loaded normally.
   await doAsyncTest(t, 'resources/about-blank-replacement-frame.py');
@@ -96,18 +106,17 @@ promise_test(async function(t) {
    'matches final Client.');
 
 promise_test(async function(t) {
   // Execute a test where the nested frame is modified immediately by
   // its parent.  In this case we add a message listener so the service
   // worker can ping the client to verify its existence.  This ping-pong
   // check is performed during the initial load and when verifying the
   // final loaded client.
-  await doAsyncTest(t, 'resources/about-blank-replacement-ping-frame.py',
-                    { 'ping': true });
+  await doAsyncTest(t, 'resources/about-blank-replacement-ping-frame.py');
 }, 'Initial about:blank modified by parent is controlled, exposed to ' +
    'clients.matchAll(), and matches final Client.');
 
 promise_test(async function(t) {
   // Execute a test where the nested window is a popup window instead of
   // an iframe.  This should behave the same as the simple iframe case.
   await doAsyncTest(t, 'resources/about-blank-replacement-popup-frame.py');
 }, 'Popup initial about:blank is controlled, exposed to clients.matchAll(), and ' +
@@ -137,10 +146,32 @@ promise_test(async function(t) {
   assert_equals(nested.navigator.serviceWorker.controller, null,
                 'nested frame should not be controlled');
 
   frame.remove();
   await service_worker_unregister_and_done(t, scope);
 }, 'Initial about:blank is controlled, exposed to clients.matchAll(), and ' +
    'final Client is not controlled by a service worker.');
 
+promise_test(async function(t) {
+  // Execute a test where the nested frame is an iframe without a src
+  // attribute.  This simple nested about:blank should still inherit the
+  // controller and be visible to clients.matchAll().
+  await doAsyncTest(t, 'resources/about-blank-replacement-blank-nested-frame.html');
+}, 'Simple about:blank is controlled and is exposed to clients.matchAll().');
+
+promise_test(async function(t) {
+  // Execute a test where the nested frame is an iframe using a non-empty
+  // srcdoc containing only a tag pair so its textContent is still empty.
+  // This nested iframe should still inherit the controller and be visible
+  // to clients.matchAll().
+  await doAsyncTest(t, 'resources/about-blank-replacement-srcdoc-nested-frame.html');
+}, 'Nested about:srcdoc is controlled and is exposed to clients.matchAll().');
+
+promise_test(async function(t) {
+  // Execute a test where the nested frame is dynamically added without a src
+  // attribute.  This simple nested about:blank should still inherit the
+  // controller and be visible to clients.matchAll().
+  await doAsyncTest(t, 'resources/about-blank-replacement-blank-dynamic-nested-frame.html');
+}, 'Dynamic about:blank is controlled and is exposed to clients.matchAll().');
+
 </script>
 </body>
new file mode 100644
--- /dev/null
+++ b/testing/web-platform/tests/service-workers/service-worker/resources/about-blank-replacement-blank-dynamic-nested-frame.html
@@ -0,0 +1,21 @@
+<!doctype html>
+<html>
+<body>
+<script>
+function nestedLoaded() {
+  parent.postMessage({ type: 'NESTED_LOADED' }, '*');
+}
+
+// dynamically add an about:blank iframe
+var f = document.createElement('iframe');
+f.onload = nestedLoaded;
+document.body.appendChild(f);
+
+// Helper routine to make it slightly easier for our parent to find
+// the nested frame.
+function nested() {
+  return f.contentWindow;
+}
+</script>
+</body>
+</html>
new file mode 100644
--- /dev/null
+++ b/testing/web-platform/tests/service-workers/service-worker/resources/about-blank-replacement-blank-nested-frame.html
@@ -0,0 +1,22 @@
+<!doctype html>
+<html>
+<body>
+<script>
+function nestedLoaded() {
+  parent.postMessage({ type: 'NESTED_LOADED' }, '*');
+}
+</script>
+<iframe id="nested" onload="nestedLoaded()"></iframe>
+<script>
+// Helper routine to make it slightly easier for our parent to find
+// the nested frame.
+function nested() {
+  return document.getElementById('nested').contentWindow;
+}
+
+// NOTE: Make sure not to touch the iframe directly here.  We want to
+//       test the case where the initial about:blank document is not
+//       directly accessed before load.
+</script>
+</body>
+</html>
new file mode 100644
--- /dev/null
+++ b/testing/web-platform/tests/service-workers/service-worker/resources/about-blank-replacement-srcdoc-nested-frame.html
@@ -0,0 +1,22 @@
+<!doctype html>
+<html>
+<body>
+<script>
+function nestedLoaded() {
+  parent.postMessage({ type: 'NESTED_LOADED' }, '*');
+}
+</script>
+<iframe id="nested" srcdoc="<div></div>" onload="nestedLoaded()"></iframe>
+<script>
+// Helper routine to make it slightly easier for our parent to find
+// the nested frame.
+function nested() {
+  return document.getElementById('nested').contentWindow;
+}
+
+// NOTE: Make sure not to touch the iframe directly here.  We want to
+//       test the case where the initial about:blank document is not
+//       directly accessed before load.
+</script>
+</body>
+</html>