Bug 1489390 [wpt PR 12892] - Add more WPT tests for mixed-content check in workers/worklets (1/2), a=testonly
authorHiroshige Hayashizaki <hiroshige@chromium.org>
Thu, 13 Sep 2018 02:52:50 +0000
changeset 492298 2d6b9e0a2b7b0bdc9b72bec8ace1836bed533073
parent 492297 84bbe77cbbe54e90c8b6eada1a45af573010a321
child 492299 ab1b27f53a5c5742be353ac4bc8457d6f00e5b98
push id9984
push userffxbld-merge
push dateMon, 15 Oct 2018 21:07:35 +0000
treeherdermozilla-beta@183d27ea8570 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewerstestonly
bugs1489390, 12892, 1212746, 1208390, 880986, 880023, 880015, 1212744, 590239
milestone64.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 1489390 [wpt PR 12892] - Add more WPT tests for mixed-content check in workers/worklets (1/2), a=testonly Automatic update from web-platform-testsAdd more WPT tests for mixed-content check in workers/worklets (1/2) This CL adds test code for more worker/worklet-related cases to mixed-content/ WPT tests: - module-worker-top-level (outsideSettings of https: module script) - module-data-worker-import (outsideSettings of data: worker) - classic-data-worker-fetch (insideSettings of data: worker) - worklet-*-top-level (outsideSettings of https: worklets) - worklet-*-data-import (outsideSettings of data: worklets) Actual generated tests is added in a separate CL https://chromium-review.googlesource.com/1212746 for easier code review. These tests are for https://chromium-review.googlesource.com/1208390. Bug: 880986, 880023, 880015 Change-Id: I07eb96cffec889103bf437813180127644466af8 Reviewed-on: https://chromium-review.googlesource.com/1212744 Commit-Queue: Hiroshige Hayashizaki <hiroshige@chromium.org> Reviewed-by: Mike West <mkwst@chromium.org> Reviewed-by: Hiroki Nakagawa <nhiroki@chromium.org> Reviewed-by: Andy Paicu <andypaicu@chromium.org> Cr-Commit-Position: refs/heads/master@{#590239} -- wpt-commits: 46535e59509a8d070884a3869ceeed43a1145aa1 wpt-pr: 12892
testing/web-platform/meta/MANIFEST.json
testing/web-platform/tests/mixed-content/generic/common.js
testing/web-platform/tests/mixed-content/generic/mixed-content-test-case.js
--- a/testing/web-platform/meta/MANIFEST.json
+++ b/testing/web-platform/meta/MANIFEST.json
@@ -618113,25 +618113,25 @@
    "9045019de11f7b57f1faca355e862f0f22dc4129",
    "testharness"
   ],
   "mixed-content/fetch-request/no-opt-in/same-host-https/top-level/no-redirect/allowed/allowed.https.html": [
    "d4b8292af3242c70d6449864143843fe4c786d5e",
    "testharness"
   ],
   "mixed-content/generic/common.js": [
-   "12e9262ca075885597ecd76ccf2ef908e383aba2",
+   "7b4c9e754a0fbc15bff5017a7c72a2f7b76f6aa8",
    "support"
   ],
   "mixed-content/generic/expect.py": [
    "672a54c3a6ebff3dc16b86b44ec511102eb29501",
    "support"
   ],
   "mixed-content/generic/mixed-content-test-case.js": [
-   "f0e2d340fcffd6cc3fc68d244c3be0a85e7b6fe4",
+   "8708f5a9357d188014fae8a630a152d1c02e295a",
    "support"
   ],
   "mixed-content/generic/sanity-checker.js": [
    "55a103adf0f29c615d40bc47943be1aec25c8f1e",
    "support"
   ],
   "mixed-content/generic/template/disclaimer.template": [
    "66c43ed6f21324d44b1596c09a02fecf53f41323",
--- a/testing/web-platform/tests/mixed-content/generic/common.js
+++ b/testing/web-platform/tests/mixed-content/generic/common.js
@@ -179,36 +179,71 @@ function requestViaXhr(url) {
  * Initiates a new GET request to provided URL via the Fetch API.
  * @param {string} url The endpoint URL for the Fetch.
  * @return {Promise} The promise for success/error events.
  */
 function requestViaFetch(url) {
   return fetch(url);
 }
 
+function dedicatedWorkerUrlThatFetches(url) {
+  return `data:text/javascript,
+    fetch('${url}')
+      .then(() => postMessage(''),
+            () => postMessage(''));`;
+}
+
+function workerUrlThatImports(url) {
+  return `data:text/javascript,import '${url}';`;
+}
+
 /**
  * Creates a new Worker, binds message and error events wrapping them into.
  *     {@code worker.eventPromise} and posts an empty string message to start
  *     the worker.
  * @param {string} url The endpoint URL for the worker script.
+ * @param {object} options The options for Worker constructor.
  * @return {Promise} The promise for success/error events.
  */
-function requestViaWorker(url) {
+function requestViaDedicatedWorker(url, options) {
   var worker;
   try {
-    worker = new Worker(url);
+    worker = new Worker(url, options);
   } catch (e) {
     return Promise.reject(e);
   }
   bindEvents(worker, "message", "error");
   worker.postMessage('');
 
   return worker.eventPromise;
 }
 
+// Returns a reference to a worklet object corresponding to a given type.
+function get_worklet(type) {
+  if (type == 'animation')
+    return CSS.animationWorklet;
+  if (type == 'layout')
+    return CSS.layoutWorklet;
+  if (type == 'paint')
+    return CSS.paintWorklet;
+  if (type == 'audio')
+    return new OfflineAudioContext(2,44100*40,44100).audioWorklet;
+
+  assert_unreached('unknown worklet type is passed.');
+  return undefined;
+}
+
+function requestViaWorklet(type, url) {
+  try {
+    return get_worklet(type).addModule(url);
+  } catch (e) {
+    return Promise.reject(e);
+  }
+}
+
 /**
  * Sets the href attribute on a navigable DOM element and performs a navigation
  *     by clicking it. To avoid navigating away from the current execution
  *     context, a target attribute is set to point to a new helper iframe.
  * @param {DOMElement} navigableElement The navigable DOMElement
  * @param {string} url The href for the navigable element.
  * @return {Promise} The promise for success/error events.
  */
--- a/testing/web-platform/tests/mixed-content/generic/mixed-content-test-case.js
+++ b/testing/web-platform/tests/mixed-content/generic/mixed-content-test-case.js
@@ -60,50 +60,74 @@ function MixedContentTestCase(scenario, 
     "a-tag": requestViaAnchor,
     "area-tag": requestViaArea,
     "beacon-request": requestViaSendBeacon,
     "fetch-request": requestViaFetch,
     "form-tag": requestViaForm,
     "iframe-tag": requestViaIframe,
     "img-tag":  requestViaImage,
     "script-tag": requestViaScript,
-    "worker-request": requestViaWorker,
+    "worker-request":
+        url => requestViaDedicatedWorker(url),
+    "module-worker-top-level":
+        url => requestViaDedicatedWorker(url, {type: "module"}),
+    "module-data-worker-import":
+        url => requestViaDedicatedWorker(workerUrlThatImports(url), {type: "module"}),
+    "classic-data-worker-fetch":
+        url => requestViaDedicatedWorker(dedicatedWorkerUrlThatFetches(url), {}),
     "xhr-request": requestViaXhr,
     "audio-tag": requestViaAudio,
     "video-tag": requestViaVideo,
     "picture-tag": requestViaPicture,
     "object-tag": requestViaObject,
     "link-css-tag": requestViaLinkStylesheet,
     "link-prefetch-tag": requestViaLinkPrefetch,
     "websocket-request": requestViaWebSocket
   };
 
-  sanityChecker.checkScenario(scenario, resourceMap);
-
   // Mapping all expected MIME types to the scenario.
   var contentType = {
     "a-tag": "text/html",
     "area-tag": "text/html",
     "beacon-request": "text/plain",
     "fetch-request": "application/json",
     "form-tag": "text/html",
     "iframe-tag": "text/html",
     "img-tag":  "image/png",
     "script-tag": "text/javascript",
+
     "worker-request": "application/javascript",
+    "module-worker-top-level": "application/javascript",
+    "module-data-worker-import": "application/javascript",
+    "classic-data-worker-fetch": "application/javascript",
+
     "xhr-request": "application/json",
     "audio-tag": "audio/wav",
     "video-tag": "video/ogg",
     "picture-tag": "image/png",
     "object-tag": "text/html",
     "link-css-tag": "text/css",
     "link-prefetch-tag": "text/html",
     "websocket-request": "application/json"
   };
 
+  for (const workletType of ['animation', 'audio', 'layout', 'paint']) {
+    resourceMap[`worklet-${workletType}-top-level`] =
+      url => requestViaWorklet(workletType, url);
+    contentType[`worklet-${workletType}-top-level`] =
+      "application/javascript";
+
+    resourceMap[`worklet-${workletType}-data-import`] =
+      url => requestViaWorklet(workletType, workerUrlThatImports(url));
+    contentType[`worklet-${workletType}-data-import`] =
+      "application/javascript";
+  }
+
+  sanityChecker.checkScenario(scenario, resourceMap);
+
   var mixed_content_test = async_test(description);
 
   function runTest() {
     sanityChecker.setFailTimeout(mixed_content_test);
 
     var key = guid();
     var value = guid();
     // We use the same path for both HTTP/S and WS/S stash requests.