Bug 1579503 [wpt PR 18905] - [WPT/common/security-features] Remove {mixed-content,referrer-policy}-test-case.sub.js, a=testonly
authorHiroshige Hayashizaki <hiroshige@chromium.org>
Fri, 13 Sep 2019 10:33:43 +0000
changeset 554545 13c959452f1af32ad5240516e2c9bf4d96d2b6bf
parent 554544 d5100a30368e449a160043472a4ffe218003b028
child 554546 d6a259fed875176e1f7bc83e32e1eb6cc9ef1fb0
push id12169
push userffxbld-merge
push dateMon, 14 Oct 2019 16:59:29 +0000
treeherdermozilla-beta@c819687300ed [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewerstestonly
bugs1579503, 18905, 906850, 1787166, 694150
milestone71.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 1579503 [wpt PR 18905] - [WPT/common/security-features] Remove {mixed-content,referrer-policy}-test-case.sub.js, a=testonly Automatic update from web-platform-tests [WPT/common/security-features] Remove {mixed-content,referrer-policy}-test-case.sub.js This CL merges getSubresourceOrigin() from *test-case.js into `common.sub.js`. This removes the dependency from `common.sub.js` to *test-case.js. Previously, some manually-written tests includes `<script src=referrer-policy-test-case.sub.js>` because of this dependency, and now we can remove such `<script>`s. After then, no scripts uses {mixed-content,referrer-policy}-test-case.sub.js and this CL removes them. Bug: 906850 Change-Id: I93acf8477037276e0a0289afabbbdc7a484734f2 Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/1787166 Commit-Queue: Hiroshige Hayashizaki <hiroshige@chromium.org> Reviewed-by: Kenichi Ishibashi <bashi@chromium.org> Reviewed-by: Hiroki Nakagawa <nhiroki@chromium.org> Cr-Commit-Position: refs/heads/master@{#694150} -- wpt-commits: b1420eb260d4fcc7bbd7cccc973fa3762d01f29c wpt-pr: 18905
testing/web-platform/tests/common/security-features/resources/common.sub.js
testing/web-platform/tests/mixed-content/generic/mixed-content-test-case.js
testing/web-platform/tests/mixed-content/generic/test-case.sub.js
testing/web-platform/tests/referrer-policy/css-integration/child-css/external-import-stylesheet.html
testing/web-platform/tests/referrer-policy/css-integration/child-css/internal-import-stylesheet.html
testing/web-platform/tests/referrer-policy/css-integration/child-css/processing-instruction.html
testing/web-platform/tests/referrer-policy/css-integration/font-face/external-import-stylesheet.html
testing/web-platform/tests/referrer-policy/css-integration/font-face/external-stylesheet.html
testing/web-platform/tests/referrer-policy/css-integration/font-face/internal-import-stylesheet.html
testing/web-platform/tests/referrer-policy/css-integration/font-face/internal-stylesheet.html
testing/web-platform/tests/referrer-policy/css-integration/font-face/processing-instruction.html
testing/web-platform/tests/referrer-policy/css-integration/image/external-import-stylesheet.html
testing/web-platform/tests/referrer-policy/css-integration/image/external-stylesheet.html
testing/web-platform/tests/referrer-policy/css-integration/image/inline-style.html
testing/web-platform/tests/referrer-policy/css-integration/image/internal-import-stylesheet.html
testing/web-platform/tests/referrer-policy/css-integration/image/internal-stylesheet.html
testing/web-platform/tests/referrer-policy/css-integration/image/presentation-attribute.html
testing/web-platform/tests/referrer-policy/css-integration/image/processing-instruction.html
testing/web-platform/tests/referrer-policy/css-integration/svg/external-stylesheet.html
testing/web-platform/tests/referrer-policy/css-integration/svg/inline-style.html
testing/web-platform/tests/referrer-policy/css-integration/svg/internal-stylesheet.html
testing/web-platform/tests/referrer-policy/css-integration/svg/presentation-attribute.html
testing/web-platform/tests/referrer-policy/css-integration/svg/processing-instruction.html
testing/web-platform/tests/referrer-policy/generic/inheritance/iframe-inheritance-srcdoc.html
testing/web-platform/tests/referrer-policy/generic/multiple-headers-and-values.html
testing/web-platform/tests/referrer-policy/generic/multiple-headers-combined.html
testing/web-platform/tests/referrer-policy/generic/multiple-headers-one-invalid.html
testing/web-platform/tests/referrer-policy/generic/multiple-headers-one-unknown-token.html
testing/web-platform/tests/referrer-policy/generic/multiple-headers.html
testing/web-platform/tests/referrer-policy/generic/referrer-policy-test-case.sub.js
testing/web-platform/tests/referrer-policy/generic/sandboxed-iframe-with-opaque-origin.html
testing/web-platform/tests/referrer-policy/generic/subresource-test/area-navigate.html
testing/web-platform/tests/referrer-policy/generic/subresource-test/fetch-messaging.html
testing/web-platform/tests/referrer-policy/generic/subresource-test/iframe-messaging.html
testing/web-platform/tests/referrer-policy/generic/subresource-test/image-decoding.html
testing/web-platform/tests/referrer-policy/generic/subresource-test/link-navigate.html
testing/web-platform/tests/referrer-policy/generic/subresource-test/script-messaging.html
testing/web-platform/tests/referrer-policy/generic/subresource-test/worker-messaging.html
testing/web-platform/tests/referrer-policy/generic/subresource-test/xhr-messaging.html
testing/web-platform/tests/referrer-policy/generic/test-case.sub.js
testing/web-platform/tests/referrer-policy/generic/unsupported-csp-referrer-directive.html
--- a/testing/web-platform/tests/common/security-features/resources/common.sub.js
+++ b/testing/web-platform/tests/common/security-features/resources/common.sub.js
@@ -947,16 +947,62 @@ for (const workletType of ['animation', 
 
   Represents what redirects should occur to the subresource request
   after initial request.
   See preprocess_redirection() in
   /common/security-features/subresource/subresource.py for valid values.
 */
 
 /**
+  Construct subresource (and related) origin.
+
+  @param {string} originType
+  @returns {object} the origin of the subresource.
+*/
+function getSubresourceOrigin(originType) {
+  const httpProtocol = "http";
+  const httpsProtocol = "https";
+  const wsProtocol = "ws";
+  const wssProtocol = "wss";
+
+  const sameOriginHost = "{{host}}";
+  const crossOriginHost = "{{domains[www1]}}";
+
+  // These values can evaluate to either empty strings or a ":port" string.
+  const httpPort = getNormalizedPort(parseInt("{{ports[http][0]}}", 10));
+  const httpsPort = getNormalizedPort(parseInt("{{ports[https][0]}}", 10));
+  const wsPort = getNormalizedPort(parseInt("{{ports[ws][0]}}", 10));
+  const wssPort = getNormalizedPort(parseInt("{{ports[wss][0]}}", 10));
+
+  /**
+    @typedef OriginType
+    @type {string}
+
+    Represents the origin of the subresource request URL.
+    The keys of `originMap` below are the valid values.
+
+    Note that there can be redirects from the specified origin
+    (see RedirectionType), and thus the origin of the subresource
+    response URL might be different from what is specified by OriginType.
+  */
+  const originMap = {
+    "same-https": httpsProtocol + "://" + sameOriginHost + httpsPort,
+    "same-http": httpProtocol + "://" + sameOriginHost + httpPort,
+    "cross-https": httpsProtocol + "://" + crossOriginHost + httpsPort,
+    "cross-http": httpProtocol + "://" + crossOriginHost + httpPort,
+    "same-wss": wssProtocol + "://" + sameOriginHost + wssPort,
+    "same-ws": wsProtocol + "://" + sameOriginHost + wsPort,
+    "cross-wss": wssProtocol + "://" + crossOriginHost + wssPort,
+    "cross-ws": wsProtocol + "://" + crossOriginHost + wsPort,
+  };
+
+  return originMap[originType];
+}
+
+/**
   Construct subresource (and related) URLs.
 
   @param {SubresourceType} subresourceType
   @param {OriginType} originType
   @param {RedirectionType} redirectionType
   @returns {object} with following properties:
     {string} testUrl
       The subresource request URL.
deleted file mode 100644
--- a/testing/web-platform/tests/mixed-content/generic/mixed-content-test-case.js
+++ /dev/null
@@ -1,124 +0,0 @@
-/**
- * @fileoverview Test case for mixed-content in Web Platform Tests.
- * @author burnik@google.com (Kristijan Burnik)
- */
-
-// TODO: This function is currently placed and duplicated at:
-// - mixed-content/generic/mixed-content-test-case.js
-// - referrer-policy/generic/referrer-policy-test-case.js
-// but should be moved to /common/security-features/resources/common.js.
-function getSubresourceOrigin(originType) {
-  const httpProtocol = "http";
-  const httpsProtocol = "https";
-  const wsProtocol = "ws";
-  const wssProtocol = "wss";
-
-  const sameOriginHost = "{{host}}";
-  const crossOriginHost = "{{domains[www1]}}";
-
-  // These values can evaluate to either empty strings or a ":port" string.
-  const httpPort = getNormalizedPort(parseInt("{{ports[http][0]}}", 10));
-  const httpsPort = getNormalizedPort(parseInt("{{ports[https][0]}}", 10));
-  const wsPort = getNormalizedPort(parseInt("{{ports[ws][0]}}", 10));
-  const wssPort = getNormalizedPort(parseInt("{{ports[wss][0]}}", 10));
-
-  /**
-    @typedef OriginType
-    @type {string}
-
-    Represents the origin of the subresource request URL.
-    The keys of `originMap` below are the valid values.
-
-    Note that there can be redirects from the specified origin
-    (see RedirectionType), and thus the origin of the subresource
-    response URL might be different from what is specified by OriginType.
-  */
-  const originMap = {
-    "same-https": httpsProtocol + "://" + sameOriginHost + httpsPort,
-    "same-http": httpProtocol + "://" + sameOriginHost + httpPort,
-    "cross-https": httpsProtocol + "://" + crossOriginHost + httpsPort,
-    "cross-http": httpProtocol + "://" + crossOriginHost + httpPort,
-    "same-wss": wssProtocol + "://" + sameOriginHost + wssPort,
-    "same-ws": wsProtocol + "://" + sameOriginHost + wsPort,
-    "cross-wss": wssProtocol + "://" + crossOriginHost + wssPort,
-    "cross-ws": wsProtocol + "://" + crossOriginHost + wsPort,
-  };
-
-  return originMap[originType];
-}
-
-/**
- * MixedContentTestCase exercises all the tests for checking browser behavior
- * when resources regarded as mixed-content are requested. A single run covers
- * only a single scenario.
- * @param {object} scenario A JSON describing the test arrangement and
- *     expectation(s). Refer to /mixed-content/spec.src.json for details.
- * @param {string} description The test scenario verbose description.
- * @param {SanityChecker} sanityChecker Instance of an object used to check the
- *     running scenario. Useful in debug mode. See ./sanity-checker.js.
- *     Run {@code ./tools/generate.py -h} for info on test generating modes.
- * @return {object} Object wrapping the start method used to run the test.
- */
-function MixedContentTestCase(scenario, description, sanityChecker) {
-  sanityChecker.checkScenario(scenario, subresourceMap);
-
-  let sourceContextList = [];
-  let subresourceType = scenario.subresource;
-  if (subresourceType === 'classic-data-worker-fetch') {
-    // Currently 'classic-data-worker-fetch' (fetch API from inside classic
-    // data: worker) is handled as a kind of subresource request
-    // on the genarator side, but should be processed using the combination of
-    // SourceContext list (classic data: worker) + Subresource (fetch API)
-    // on the JavaScript side.
-    // We bridge this inconsistency here, and will later pass these information
-    // directly from the generated tests and remove this conversion here.
-    subresourceType = 'fetch-request';
-    sourceContextList = [{sourceContextType: 'worker-classic-data'}];
-  }
-
-  const originTypeConversion = {
-    "same-host-https": "same-https",
-    "same-host-http": "same-http",
-    "cross-origin-https": "cross-https",
-    "cross-origin-http": "cross-http",
-    "same-host-wss": "same-wss",
-    "same-host-ws": "same-ws",
-    "cross-origin-wss": "cross-wss",
-    "cross-origin-ws": "cross-ws",
-  };
-
-  const urls = getRequestURLs(subresourceType,
-                              originTypeConversion[scenario.origin],
-                              scenario.redirection);
-  const checkResult = _ => {
-    // Send request to check if the key has been torn down.
-    return xhrRequest(urls.assertUrl)
-      .then(assertResult => {
-          // Now check if the value has been torn down. If it's still there,
-          // we have blocked the request to mixed-content.
-          assert_equals(assertResult.status, scenario.expectation,
-            "The resource request should be '" + scenario.expectation + "'.");
-        });
-  };
-
-  function runTest() {
-    /** @type {Subresource} */
-    const subresource = {
-      subresourceType: subresourceType,
-      url: urls.testUrl,
-      policyDeliveries: []
-    };
-
-    promise_test(() => {
-      return xhrRequest(urls.announceUrl)
-        // Send out the real resource request.
-        // This should tear down the key if it's not blocked.
-        .then(_ => invokeRequest(subresource, sourceContextList))
-        // We check the key state, regardless of whether the main request
-        // succeeded or failed.
-        .then(checkResult, checkResult);
-      }, description);
-  }  // runTest
-
-  return {start: runTest};
-}  // MixedContentTestCase
--- a/testing/web-platform/tests/mixed-content/generic/test-case.sub.js
+++ b/testing/web-platform/tests/mixed-content/generic/test-case.sub.js
@@ -1,57 +1,13 @@
 /**
  * @fileoverview Test case for mixed-content in Web Platform Tests.
  * @author burnik@google.com (Kristijan Burnik)
  */
 
-// TODO: This function is currently placed and duplicated at:
-// - mixed-content/generic/mixed-content-test-case.js
-// - referrer-policy/generic/referrer-policy-test-case.js
-// but should be moved to /common/security-features/resources/common.js.
-function getSubresourceOrigin(originType) {
-  const httpProtocol = "http";
-  const httpsProtocol = "https";
-  const wsProtocol = "ws";
-  const wssProtocol = "wss";
-
-  const sameOriginHost = "{{host}}";
-  const crossOriginHost = "{{domains[www1]}}";
-
-  // These values can evaluate to either empty strings or a ":port" string.
-  const httpPort = getNormalizedPort(parseInt("{{ports[http][0]}}", 10));
-  const httpsPort = getNormalizedPort(parseInt("{{ports[https][0]}}", 10));
-  const wsPort = getNormalizedPort(parseInt("{{ports[ws][0]}}", 10));
-  const wssPort = getNormalizedPort(parseInt("{{ports[wss][0]}}", 10));
-
-  /**
-    @typedef OriginType
-    @type {string}
-
-    Represents the origin of the subresource request URL.
-    The keys of `originMap` below are the valid values.
-
-    Note that there can be redirects from the specified origin
-    (see RedirectionType), and thus the origin of the subresource
-    response URL might be different from what is specified by OriginType.
-  */
-  const originMap = {
-    "same-https": httpsProtocol + "://" + sameOriginHost + httpsPort,
-    "same-http": httpProtocol + "://" + sameOriginHost + httpPort,
-    "cross-https": httpsProtocol + "://" + crossOriginHost + httpsPort,
-    "cross-http": httpProtocol + "://" + crossOriginHost + httpPort,
-    "same-wss": wssProtocol + "://" + sameOriginHost + wssPort,
-    "same-ws": wsProtocol + "://" + sameOriginHost + wsPort,
-    "cross-wss": wssProtocol + "://" + crossOriginHost + wssPort,
-    "cross-ws": wsProtocol + "://" + crossOriginHost + wsPort,
-  };
-
-  return originMap[originType];
-}
-
 /**
  * MixedContentTestCase exercises all the tests for checking browser behavior
  * when resources regarded as mixed-content are requested. A single run covers
  * only a single scenario.
  * @param {object} scenario A JSON describing the test arrangement and
  *     expectation(s). Refer to /mixed-content/spec.src.json for details.
  * @param {string} description The test scenario verbose description.
  * @param {SanityChecker} sanityChecker Instance of an object used to check the
--- a/testing/web-platform/tests/referrer-policy/css-integration/child-css/external-import-stylesheet.html
+++ b/testing/web-platform/tests/referrer-policy/css-integration/child-css/external-import-stylesheet.html
@@ -2,17 +2,16 @@
 <html>
   <head>
     <title>CSS integration - Child css from external stylesheet</title>
     <script src="/resources/testharness.js"></script>
     <script src="/resources/testharnessreport.js"></script>
     <script src="/common/utils.js"></script>
     <!-- Common global functions for referrer-policy tests. -->
     <script src="/common/security-features/resources/common.sub.js"></script>
-    <script src="/referrer-policy/generic/referrer-policy-test-case.sub.js"></script>
     <meta name="referrer" content="origin">
   </head>
   <body>
     <p>Check that child css are loaded with the referrer and referrer policy
     from the external stylesheet.</p>
 
     <div class="styled"></div>
 
--- a/testing/web-platform/tests/referrer-policy/css-integration/child-css/internal-import-stylesheet.html
+++ b/testing/web-platform/tests/referrer-policy/css-integration/child-css/internal-import-stylesheet.html
@@ -2,17 +2,16 @@
 <html>
   <head>
     <title>CSS integration - Child css from internal stylesheet</title>
     <script src="/resources/testharness.js"></script>
     <script src="/resources/testharnessreport.js"></script>
     <script src="/common/utils.js"></script>
     <!-- Common global functions for referrer-policy tests. -->
     <script src="/common/security-features/resources/common.sub.js"></script>
-    <script src="/referrer-policy/generic/referrer-policy-test-case.sub.js"></script>
     <meta name="referrer" content="never">
   </head>
   <body>
     <p>Check that child css are loaded with the referrer and referrer policy
     from the internal stylesheet.</p>
 
     <div class="styled"></div>
 
--- a/testing/web-platform/tests/referrer-policy/css-integration/child-css/processing-instruction.html
+++ b/testing/web-platform/tests/referrer-policy/css-integration/child-css/processing-instruction.html
@@ -2,17 +2,16 @@
 <html>
   <head>
     <title>CSS integration - child css via a ProcessingInstruction</title>
     <script src="/resources/testharness.js"></script>
     <script src="/resources/testharnessreport.js"></script>
     <script src="/common/utils.js"></script>
     <!-- Common global functions for referrer-policy tests. -->
     <script src="/common/security-features/resources/common.sub.js"></script>
-    <script src="/referrer-policy/generic/referrer-policy-test-case.sub.js"></script>
     <meta name="referrer" content="origin">
   </head>
   <body>
     <p>Check that child css are loaded with the referrer and referrer policy the
     external stylesheet(referenced from a ProcessingInstruction).</p>
     <div class="styled"></div>
 
     <script>
--- a/testing/web-platform/tests/referrer-policy/css-integration/font-face/external-import-stylesheet.html
+++ b/testing/web-platform/tests/referrer-policy/css-integration/font-face/external-import-stylesheet.html
@@ -2,17 +2,16 @@
 <html>
   <head>
     <title>CSS integration - Font from imported stylesheet (external)</title>
     <script src="/resources/testharness.js"></script>
     <script src="/resources/testharnessreport.js"></script>
     <script src="/common/utils.js"></script>
     <!-- Common global functions for referrer-policy tests. -->
     <script src="/common/security-features/resources/common.sub.js"></script>
-    <script src="/referrer-policy/generic/referrer-policy-test-case.sub.js"></script>
     <meta name="referrer" content="never">
   </head>
   <body>
     <p>Check that resources from imported stylesheets (loaded from external
     stylesheets) are loaded with the referrer and referrer policy from the
     external stylesheet.</p>
 
     <div class="styled"></div>
--- a/testing/web-platform/tests/referrer-policy/css-integration/font-face/external-stylesheet.html
+++ b/testing/web-platform/tests/referrer-policy/css-integration/font-face/external-stylesheet.html
@@ -2,17 +2,16 @@
 <html>
   <head>
     <title>CSS integration - Font from external stylesheet</title>
     <script src="/resources/testharness.js"></script>
     <script src="/resources/testharnessreport.js"></script>
     <script src="/common/utils.js"></script>
     <!-- Common global functions for referrer-policy tests. -->
     <script src="/common/security-features/resources/common.sub.js"></script>
-    <script src="/referrer-policy/generic/referrer-policy-test-case.sub.js"></script>
     <meta name="referrer" content="never">
   </head>
   <body>
     <p>Check that resources from external stylesheets are loaded with
     the referrer and referrer policy from the external stylesheet.</p>
 
     <div class="styled"></div>
 
--- a/testing/web-platform/tests/referrer-policy/css-integration/font-face/internal-import-stylesheet.html
+++ b/testing/web-platform/tests/referrer-policy/css-integration/font-face/internal-import-stylesheet.html
@@ -2,17 +2,16 @@
 <html>
   <head>
     <title>CSS integration - Font from imported stylesheet (internal)</title>
     <script src="/resources/testharness.js"></script>
     <script src="/resources/testharnessreport.js"></script>
     <script src="/common/utils.js"></script>
     <!-- Common global functions for referrer-policy tests. -->
     <script src="/common/security-features/resources/common.sub.js"></script>
-    <script src="/referrer-policy/generic/referrer-policy-test-case.sub.js"></script>
     <meta name="referrer" content="origin">
   </head>
   <body>
     <p>Check that resources from stylesheets (imported from internal
     stylesheets) are loaded with the referrer and referrer policy from from the
     imported style sheet.</p>
 
     <div class="styled"></div>
--- a/testing/web-platform/tests/referrer-policy/css-integration/font-face/internal-stylesheet.html
+++ b/testing/web-platform/tests/referrer-policy/css-integration/font-face/internal-stylesheet.html
@@ -2,17 +2,16 @@
 <html>
   <head>
     <title>CSS integration - Font from internal stylesheet</title>
     <script src="/resources/testharness.js"></script>
     <script src="/resources/testharnessreport.js"></script>
     <script src="/common/utils.js"></script>
     <!-- Common global functions for referrer-policy tests. -->
     <script src="/common/security-features/resources/common.sub.js"></script>
-    <script src="/referrer-policy/generic/referrer-policy-test-case.sub.js"></script>
     <meta name="referrer" content="origin">
   </head>
   <body>
     <p>Check that resources from internal stylesheets are loaded with
     the referrer and referrer policy from the document.</p>
 
     <div class="styled"></div>
 
--- a/testing/web-platform/tests/referrer-policy/css-integration/font-face/processing-instruction.html
+++ b/testing/web-platform/tests/referrer-policy/css-integration/font-face/processing-instruction.html
@@ -2,17 +2,16 @@
 <html>
   <head>
     <title>CSS integration - Font from external stylesheet inserted via a ProcessingInstruction</title>
     <script src="/resources/testharness.js"></script>
     <script src="/resources/testharnessreport.js"></script>
     <script src="/common/utils.js"></script>
     <!-- Common global functions for referrer-policy tests. -->
     <script src="/common/security-features/resources/common.sub.js"></script>
-    <script src="/referrer-policy/generic/referrer-policy-test-case.sub.js"></script>
     <meta name="referrer" content="never">
   </head>
   <body>
     <p>Check that resources from external stylesheets (referenced from a
     ProcessingInstruction) are loaded with the referrer and referrer policy
     from the external stylesheet.</p>
 
     <div class="styled"></div>
--- a/testing/web-platform/tests/referrer-policy/css-integration/image/external-import-stylesheet.html
+++ b/testing/web-platform/tests/referrer-policy/css-integration/image/external-import-stylesheet.html
@@ -2,17 +2,16 @@
 <html>
   <head>
     <title>CSS integration - image from imported stylesheet (external)</title>
     <script src="/resources/testharness.js"></script>
     <script src="/resources/testharnessreport.js"></script>
     <script src="/common/utils.js"></script>
     <!-- Common global functions for referrer-policy tests. -->
     <script src="/common/security-features/resources/common.sub.js"></script>
-    <script src="/referrer-policy/generic/referrer-policy-test-case.sub.js"></script>
     <meta name="referrer" content="never">
   </head>
   <body>
     <p>Check that resources from imported stylesheets (loaded from external
     stylesheets) are loaded with the referrer and referrer policy from the
     external stylesheet.</p>
 
     <div class="styled"></div>
--- a/testing/web-platform/tests/referrer-policy/css-integration/image/external-stylesheet.html
+++ b/testing/web-platform/tests/referrer-policy/css-integration/image/external-stylesheet.html
@@ -2,17 +2,16 @@
 <html>
   <head>
     <title>CSS integration - image from external stylesheet</title>
     <script src="/resources/testharness.js"></script>
     <script src="/resources/testharnessreport.js"></script>
     <script src="/common/utils.js"></script>
     <!-- Common global functions for referrer-policy tests. -->
     <script src="/common/security-features/resources/common.sub.js"></script>
-    <script src="/referrer-policy/generic/referrer-policy-test-case.sub.js"></script>
     <meta name="referrer" content="never">
   </head>
   <body>
     <p>Check that resources from external stylesheets are loaded with
     the referrer and referrer policy from the external stylesheet.</p>
 
     <div class="styled"></div>
 
--- a/testing/web-platform/tests/referrer-policy/css-integration/image/inline-style.html
+++ b/testing/web-platform/tests/referrer-policy/css-integration/image/inline-style.html
@@ -2,17 +2,16 @@
 <html>
   <head>
     <title>CSS integration - image from inline style</title>
     <script src="/resources/testharness.js"></script>
     <script src="/resources/testharnessreport.js"></script>
     <script src="/common/utils.js"></script>
     <!-- Common global functions for referrer-policy tests. -->
     <script src="/common/security-features/resources/common.sub.js"></script>
-    <script src="/referrer-policy/generic/referrer-policy-test-case.sub.js"></script>
     <meta name="referrer" content="origin">
   </head>
   <body>
     <p>Check that resources from inline styles are loaded with
     the referrer and referrer policy from the document.</p>
 
     <div class="styled"></div>
 
--- a/testing/web-platform/tests/referrer-policy/css-integration/image/internal-import-stylesheet.html
+++ b/testing/web-platform/tests/referrer-policy/css-integration/image/internal-import-stylesheet.html
@@ -2,17 +2,16 @@
 <html>
   <head>
     <title>CSS integration - image from imported stylesheet (internal)</title>
     <script src="/resources/testharness.js"></script>
     <script src="/resources/testharnessreport.js"></script>
     <script src="/common/utils.js"></script>
     <!-- Common global functions for referrer-policy tests. -->
     <script src="/common/security-features/resources/common.sub.js"></script>
-    <script src="/referrer-policy/generic/referrer-policy-test-case.sub.js"></script>
     <meta name="referrer" content="origin">
   </head>
   <body>
     <p>Check that resources from stylesheets (imported from internal
     stylesheets) are loaded with the referrer and referrer policy from the
     document.</p>
 
     <div class="styled"></div>
--- a/testing/web-platform/tests/referrer-policy/css-integration/image/internal-stylesheet.html
+++ b/testing/web-platform/tests/referrer-policy/css-integration/image/internal-stylesheet.html
@@ -2,17 +2,16 @@
 <html>
   <head>
     <title>CSS integration - image from internal stylesheet</title>
     <script src="/resources/testharness.js"></script>
     <script src="/resources/testharnessreport.js"></script>
     <script src="/common/utils.js"></script>
     <!-- Common global functions for referrer-policy tests. -->
     <script src="/common/security-features/resources/common.sub.js"></script>
-    <script src="/referrer-policy/generic/referrer-policy-test-case.sub.js"></script>
     <meta name="referrer" content="origin">
   </head>
   <body>
     <p>Check that resources from internal stylesheets are loaded with
     the referrer and referrer policy from the document.</p>
 
     <div class="styled"></div>
 
--- a/testing/web-platform/tests/referrer-policy/css-integration/image/presentation-attribute.html
+++ b/testing/web-platform/tests/referrer-policy/css-integration/image/presentation-attribute.html
@@ -2,17 +2,16 @@
 <html>
   <head>
     <title>CSS integration - image from presentation attribute</title>
     <script src="/resources/testharness.js"></script>
     <script src="/resources/testharnessreport.js"></script>
     <script src="/common/utils.js"></script>
     <!-- Common global functions for referrer-policy tests. -->
     <script src="/common/security-features/resources/common.sub.js"></script>
-    <script src="/referrer-policy/generic/referrer-policy-test-case.sub.js"></script>
     <meta name="referrer" content="origin">
   </head>
   <body>
     <p>Check that resources from presentation attributes are loaded with
     the referrer and referrer policy from the document.</p>
 
     <script>
       promise_test(function(css_test) {
--- a/testing/web-platform/tests/referrer-policy/css-integration/image/processing-instruction.html
+++ b/testing/web-platform/tests/referrer-policy/css-integration/image/processing-instruction.html
@@ -2,17 +2,16 @@
 <html>
   <head>
     <title>CSS integration - image from external stylesheet inserted via a ProcessingInstruction</title>
     <script src="/resources/testharness.js"></script>
     <script src="/resources/testharnessreport.js"></script>
     <script src="/common/utils.js"></script>
     <!-- Common global functions for referrer-policy tests. -->
     <script src="/common/security-features/resources/common.sub.js"></script>
-    <script src="/referrer-policy/generic/referrer-policy-test-case.sub.js"></script>
     <meta name="referrer" content="never">
   </head>
   <body>
     <p>Check that resources from external stylesheets (referenced from a
     ProcessingInstruction) are loaded with the referrer and referrer policy
     from the external stylesheet.</p>
 
     <div class="styled"></div>
--- a/testing/web-platform/tests/referrer-policy/css-integration/svg/external-stylesheet.html
+++ b/testing/web-platform/tests/referrer-policy/css-integration/svg/external-stylesheet.html
@@ -2,17 +2,16 @@
 <html>
   <head>
     <title>CSS integration - styling SVG from external stylesheet</title>
     <script src="/resources/testharness.js"></script>
     <script src="/resources/testharnessreport.js"></script>
     <script src="/common/utils.js"></script>
     <!-- Common global functions for referrer-policy tests. -->
     <script src="/common/security-features/resources/common.sub.js"></script>
-    <script src="/referrer-policy/generic/referrer-policy-test-case.sub.js"></script>
     <!-- Helper functions for referrer-policy css tests. -->
     <script src="/referrer-policy/css-integration/css-test-helper.js"></script>
     <meta name="referrer" content="never">
   </head>
   <body>
     <p>Check that resources from external stylesheets are loaded with
     the referrer and referrer policy from the external stylesheet.</p>
 
--- a/testing/web-platform/tests/referrer-policy/css-integration/svg/inline-style.html
+++ b/testing/web-platform/tests/referrer-policy/css-integration/svg/inline-style.html
@@ -2,17 +2,16 @@
 <html>
   <head>
     <title>CSS integration - styling SVG from inline style</title>
     <script src="/resources/testharness.js"></script>
     <script src="/resources/testharnessreport.js"></script>
     <script src="/common/utils.js"></script>
     <!-- Common global functions for referrer-policy tests. -->
     <script src="/common/security-features/resources/common.sub.js"></script>
-    <script src="/referrer-policy/generic/referrer-policy-test-case.sub.js"></script>
     <!-- Helper functions for referrer-policy css tests. -->
     <script src="/referrer-policy/css-integration/css-test-helper.js"></script>
     <meta name="referrer" content="origin">
   </head>
   <body>
     <p>Check that resources from inline styles are loaded with
     the referrer and referrer policy from the document.</p>
     <script>
--- a/testing/web-platform/tests/referrer-policy/css-integration/svg/internal-stylesheet.html
+++ b/testing/web-platform/tests/referrer-policy/css-integration/svg/internal-stylesheet.html
@@ -2,17 +2,16 @@
 <html>
   <head>
     <title>CSS integration - styling SVG from internal style</title>
     <script src="/resources/testharness.js"></script>
     <script src="/resources/testharnessreport.js"></script>
     <script src="/common/utils.js"></script>
     <!-- Common global functions for referrer-policy tests. -->
     <script src="/common/security-features/resources/common.sub.js"></script>
-    <script src="/referrer-policy/generic/referrer-policy-test-case.sub.js"></script>
     <!-- Helper functions for referrer-policy css tests. -->
     <script src="/referrer-policy/css-integration/css-test-helper.js"></script>
     <meta name="referrer" content="origin">
   </head>
   <body>
     <p>Check that resources from internal styles are loaded with
     the referrer and referrer policy from the document.</p>
     <script>
--- a/testing/web-platform/tests/referrer-policy/css-integration/svg/presentation-attribute.html
+++ b/testing/web-platform/tests/referrer-policy/css-integration/svg/presentation-attribute.html
@@ -3,17 +3,16 @@
   <head>
     <title>CSS integration - styling SVG from external stylesheet from
            presentation attribute</title>
     <script src="/resources/testharness.js"></script>
     <script src="/resources/testharnessreport.js"></script>
     <script src="/common/utils.js"></script>
     <!-- Common global functions for referrer-policy tests. -->
     <script src="/common/security-features/resources/common.sub.js"></script>
-    <script src="/referrer-policy/generic/referrer-policy-test-case.sub.js"></script>
     <!-- Helper functions for referrer-policy css tests. -->
     <script src="/referrer-policy/css-integration/css-test-helper.js"></script>
     <meta name="referrer" content="origin">
   </head>
   <body>
     <p>Check that resources from presentation attributes are loaded with
     the referrer and referrer policy from the document.</p>
    <script>
--- a/testing/web-platform/tests/referrer-policy/css-integration/svg/processing-instruction.html
+++ b/testing/web-platform/tests/referrer-policy/css-integration/svg/processing-instruction.html
@@ -3,17 +3,16 @@
   <head>
     <title>CSS integration - styling SVG from external stylesheet via
            ProcessingInstruction</title>
     <script src="/resources/testharness.js"></script>
     <script src="/resources/testharnessreport.js"></script>
     <script src="/common/utils.js"></script>
     <!-- Common global functions for referrer-policy tests. -->
     <script src="/common/security-features/resources/common.sub.js"></script>
-    <script src="/referrer-policy/generic/referrer-policy-test-case.sub.js"></script>
     <!-- Helper functions for referrer-policy css tests. -->
     <script src="/referrer-policy/css-integration/css-test-helper.js"></script>
     <meta name="referrer" content="origin">
   </head>
   <body>
     <p>Check that resources from external stylesheets (referenced from a
     ProcessingInstruction) are loaded with the referrer and referrer policy
     from the external stylesheet.</p>
--- a/testing/web-platform/tests/referrer-policy/generic/inheritance/iframe-inheritance-srcdoc.html
+++ b/testing/web-platform/tests/referrer-policy/generic/inheritance/iframe-inheritance-srcdoc.html
@@ -2,33 +2,31 @@
 <html>
   <head>
     <title>Referrer Policy: iframes srdoc correctly inherit the ancestor's referrer policy</title>
     <link rel="help" href="https://www.w3.org/TR/referrer-policy/#referrer-policy-delivery-nested">
     <script src="/resources/testharness.js"></script>
     <script src="/resources/testharnessreport.js"></script>
     <!-- Common global functions for referrer-policy tests. -->
     <script src="/common/security-features/resources/common.sub.js"></script>
-    <script src="/referrer-policy/generic/referrer-policy-test-case.sub.js"></script>
     <meta name="referrer" content="origin">
   </head>
   <body onload="runTest()">
     <h1>Referrer Policy: iframes srcdoc correctly inherit the ancestor's referrer policy</h1>
     <script>
       var test = async_test("iframes srcdoc correctly inherit the ancestor's referrer policy");
       window.addEventListener("message", test.step_func((msg) => {
         assert_equals(msg.data.referrer, document.location.origin + "/");
         test.done();
       }));
 
       function runTest() {
         var iframe = document.createElement("iframe");
         iframe.srcdoc =
             `<script src = "/common/security-features/resources/common.sub.js"></` + `script>
-            <script src = "/referrer-policy/generic/referrer-policy-test-case.sub.js"></` + `script>
             <script>
               var urlPath = "/common/security-features/subresource/xhr.py";
               var url = "${location.protocol}//www1.${location.hostname}:${location.port}" + urlPath;
               requestViaXhr(url).then((msg) => {
                   parent.postMessage({referrer: msg.referrer}, "*")})
                 .catch((e) => {
                     parent.postMessage({referrer: "FAILURE"}, "*");
                   });
--- a/testing/web-platform/tests/referrer-policy/generic/multiple-headers-and-values.html
+++ b/testing/web-platform/tests/referrer-policy/generic/multiple-headers-and-values.html
@@ -1,17 +1,16 @@
 <!DOCTYPE html>
 <html>
   <head>
     <title>Referrer Policy: multiple Referrer-Policy header and header values are allowed</title>
     <script src="/resources/testharness.js"></script>
     <script src="/resources/testharnessreport.js"></script>
 
     <script src="/common/security-features/resources/common.sub.js"></script>
-    <script src="/referrer-policy/generic/referrer-policy-test-case.sub.js"></script>
   </head>
   <body>
     <h1>Referrer Policy: multiple Referrer-Policy header and header values are allowed</h1>
     <p></p>
 
     <pre id="received_message">Running...</pre>
 
     <script>
--- a/testing/web-platform/tests/referrer-policy/generic/multiple-headers-combined.html
+++ b/testing/web-platform/tests/referrer-policy/generic/multiple-headers-combined.html
@@ -1,17 +1,16 @@
 <!DOCTYPE html>
 <html>
   <head>
     <title>Referrer Policy: multiple Referrer-Policy header values are allowed</title>
     <script src="/resources/testharness.js"></script>
     <script src="/resources/testharnessreport.js"></script>
 
     <script src="/common/security-features/resources/common.sub.js"></script>
-    <script src="/referrer-policy/generic/referrer-policy-test-case.sub.js"></script>
   </head>
   <body>
     <h1>Referrer Policy: multiple Referrer-Policy header values are allowed</h1>
     <p></p>
 
     <pre id="received_message">Running...</pre>
 
     <script>
--- a/testing/web-platform/tests/referrer-policy/generic/multiple-headers-one-invalid.html
+++ b/testing/web-platform/tests/referrer-policy/generic/multiple-headers-one-invalid.html
@@ -1,17 +1,16 @@
 <!DOCTYPE html>
 <html>
   <head>
     <title>Referrer Policy: multiple Referrer-Policy headers with one invalid</title>
     <script src="/resources/testharness.js"></script>
     <script src="/resources/testharnessreport.js"></script>
 
     <script src="/common/security-features/resources/common.sub.js"></script>
-    <script src="/referrer-policy/generic/referrer-policy-test-case.sub.js"></script>
   </head>
   <body>
     <h1>Referrer Policy: multiple Referrer-Policy headers with one invalid</h1>
     <p></p>
 
     <pre id="received_message">Running...</pre>
 
     <script>
--- a/testing/web-platform/tests/referrer-policy/generic/multiple-headers-one-unknown-token.html
+++ b/testing/web-platform/tests/referrer-policy/generic/multiple-headers-one-unknown-token.html
@@ -1,17 +1,16 @@
 <!DOCTYPE html>
 <html>
   <head>
     <title>Referrer Policy: multiple Referrer-Policy headers with one invalid</title>
     <script src="/resources/testharness.js"></script>
     <script src="/resources/testharnessreport.js"></script>
 
     <script src="/common/security-features/resources/common.sub.js"></script>
-    <script src="/referrer-policy/generic/referrer-policy-test-case.sub.js"></script>
   </head>
   <body>
     <h1>Referrer Policy: multiple Referrer-Policy headers with one invalid</h1>
     <p></p>
 
     <pre id="received_message">Running...</pre>
 
     <script>
--- a/testing/web-platform/tests/referrer-policy/generic/multiple-headers.html
+++ b/testing/web-platform/tests/referrer-policy/generic/multiple-headers.html
@@ -1,17 +1,16 @@
 <!DOCTYPE html>
 <html>
   <head>
     <title>Referrer Policy: multiple Referrer-Policy headers are allowed</title>
     <script src="/resources/testharness.js"></script>
     <script src="/resources/testharnessreport.js"></script>
 
     <script src="/common/security-features/resources/common.sub.js"></script>
-    <script src="/referrer-policy/generic/referrer-policy-test-case.sub.js"></script>
   </head>
   <body>
     <h1>Referrer Policy: multiple Referrer-Policy headers are allowed</h1>
     <p></p>
 
     <pre id="received_message">Running...</pre>
 
     <script>
deleted file mode 100644
--- a/testing/web-platform/tests/referrer-policy/generic/referrer-policy-test-case.sub.js
+++ /dev/null
@@ -1,260 +0,0 @@
-// TODO: This function is currently placed and duplicated at:
-// - mixed-content/generic/mixed-content-test-case.js
-// - referrer-policy/generic/referrer-policy-test-case.sub.js
-// but should be moved to /common/security-features/resources/common.js.
-function getSubresourceOrigin(originType) {
-  const httpProtocol = "http";
-  const httpsProtocol = "https";
-  const wsProtocol = "ws";
-  const wssProtocol = "wss";
-
-  const sameOriginHost = "{{host}}";
-  const crossOriginHost = "{{domains[www1]}}";
-
-  // These values can evaluate to either empty strings or a ":port" string.
-  const httpPort = getNormalizedPort(parseInt("{{ports[http][0]}}", 10));
-  const httpsPort = getNormalizedPort(parseInt("{{ports[https][0]}}", 10));
-  const wsPort = getNormalizedPort(parseInt("{{ports[ws][0]}}", 10));
-  const wssPort = getNormalizedPort(parseInt("{{ports[wss][0]}}", 10));
-
-  /**
-    @typedef OriginType
-    @type {string}
-
-    Represents the origin of the subresource request URL.
-    The keys of `originMap` below are the valid values.
-
-    Note that there can be redirects from the specified origin
-    (see RedirectionType), and thus the origin of the subresource
-    response URL might be different from what is specified by OriginType.
-  */
-  const originMap = {
-    "same-https": httpsProtocol + "://" + sameOriginHost + httpsPort,
-    "same-http": httpProtocol + "://" + sameOriginHost + httpPort,
-    "cross-https": httpsProtocol + "://" + crossOriginHost + httpsPort,
-    "cross-http": httpProtocol + "://" + crossOriginHost + httpPort,
-    "same-wss": wssProtocol + "://" + sameOriginHost + wssPort,
-    "same-ws": wsProtocol + "://" + sameOriginHost + wsPort,
-    "cross-wss": wssProtocol + "://" + crossOriginHost + wssPort,
-    "cross-ws": wsProtocol + "://" + crossOriginHost + wsPort,
-  };
-
-  return originMap[originType];
-}
-
-// NOTE: This method only strips the fragment and is not in accordance to the
-// recommended draft specification:
-// https://w3c.github.io/webappsec/specs/referrer-policy/#null
-// TODO(kristijanburnik): Implement this helper as defined by spec once added
-// scenarios for URLs containing username/password/etc.
-function stripUrlForUseAsReferrer(url) {
-  return url.replace(/#.*$/, "");
-}
-
-function invokeScenario(scenario, sourceContextList) {
-  const originTypeConversion = {
-    "same-origin-http": "same-http",
-    "same-origin-https": "same-https",
-    "cross-origin-http": "cross-http",
-    "cross-origin-https": "cross-https"
-  };
-  const urls = getRequestURLs(
-    scenario.subresource,
-    originTypeConversion[scenario.origin + '-' + scenario.target_protocol],
-    scenario.redirection);
-
-  const deliveryTypeConversion = {
-    "attr-referrer": "attr",
-    "rel-noreferrer": "rel-noref",
-    // Other delivery methods such as "http-rp" are ignored here because
-    // they are already applied to the main document by generator.py.
-  };
-
-  /** @type {PolicyDelivery} */
-  const delivery = {
-      deliveryType: deliveryTypeConversion[scenario.delivery_method],
-      key: "referrerPolicy",
-      value: scenario.referrer_policy};
-
-  /** @type {Subresource} */
-  const subresource = {
-    subresourceType: scenario.subresource,
-    url: urls.testUrl,
-    policyDeliveries: [delivery]
-  };
-
-  return invokeRequest(subresource, sourceContextList || []);
-}
-
-function ReferrerPolicyTestCase(scenario, testDescription, sanityChecker) {
-  // Pass and skip rest of the test if browser does not support fetch.
-  if (scenario.subresource == "fetch-request" && !window.fetch) {
-    // TODO(kristijanburnik): This should be refactored.
-    return {
-      start: function() {
-        test(function() { assert_true(true); },
-             "[ReferrerPolicyTestCase] Skipping test: Fetch is not supported.");
-      }
-    };
-  }
-
-  // This check is A NOOP in release.
-  sanityChecker.checkScenario(scenario);
-
-  const referrerUrlResolver = {
-    "omitted": function(sourceUrl) {
-      return undefined;
-    },
-    "origin": function(sourceUrl) {
-      return new URL(sourceUrl).origin + "/";
-    },
-    "stripped-referrer": function(sourceUrl) {
-      return stripUrlForUseAsReferrer(sourceUrl);
-    }
-  };
-
-  const checkResult = (expectation, result) => {
-    let currentURL = location.toString();
-    const expectedReferrerUrl =
-      referrerUrlResolver[expectation](currentURL);
-
-    // Check the reported URL.
-    assert_equals(result.referrer,
-                  expectedReferrerUrl,
-                  "Reported Referrer URL is '" +
-                  expectation + "'.");
-    assert_equals(result.headers.referer,
-                  expectedReferrerUrl,
-                  "Reported Referrer URL from HTTP header is '" +
-                  expectedReferrerUrl + "'");
-  };
-
-  function runTest() {
-    function historyBackPromise(t, scenario) {
-      history.back();
-      return new Promise(resolve => {
-          // Wait for completion of `history.back()` by listening the
-          // popstate events that are fired near the end of
-          // `history.back()` processing.
-          window.addEventListener('popstate', resolve, {once: true});
-
-          // Workaround for Safari: Waiting for popstate events causes
-          // timeout in a-tag tests. To avoid timeout, we anyway resolve
-          // the promise.
-          if (scenario.subresource === 'a-tag') {
-            t.step_timeout(resolve, 1000);
-          }
-        });
-    }
-
-    // Request in the top-level document.
-    promise_test(_ => {
-      return invokeScenario(scenario)
-        .then(result => checkResult(scenario.referrer_url, result));
-    }, testDescription);
-
-    // `Referer` headers with length over 4k are culled down to an origin, so,
-    // let's test around that boundary for tests that would otherwise return
-    // the complete URL.
-    // Different subresource URLs are used because getRequestURLs() is called
-    // for each sub test which returns a unique URL.
-    if (scenario.referrer_url == "stripped-referrer") {
-      promise_test(t => {
-        history.pushState(null, null, "/");
-        history.replaceState(null, null, "A".repeat(4096 - location.href.length - 1));
-        return invokeScenario(scenario)
-          .then(result => checkResult(scenario.referrer_url, result))
-          .finally(_ => historyBackPromise(t, scenario));
-      }, "`Referer` header with length < 4k is not stripped to an origin.");
-
-      promise_test(t => {
-        history.pushState(null, null, "/");
-        history.replaceState(null, null, "A".repeat(4096 - location.href.length));
-        return invokeScenario(scenario)
-          .then(result => checkResult(scenario.referrer_url, result))
-          .finally(_ => historyBackPromise(t, scenario));
-      }, "`Referer` header with length == 4k is not stripped to an origin.");
-
-      promise_test(t => {
-        history.pushState(null, null, "/");
-        history.replaceState(null, null, "A".repeat(4096 - location.href.length + 1));
-        return invokeScenario(scenario)
-          .then(result => checkResult("origin", result))
-          .finally(_ => historyBackPromise(t, scenario));
-      }, "`Referer` header with length > 4k is stripped to an origin.");
-    }
-
-    // We test requests from inside iframes only for <img> tags.
-    // This is just to preserve the previous test coverage.
-    // TODO(hiroshige): Enable iframe tests for all subresource types.
-    if (scenario.subresource !== "img-tag") {
-      return;
-    }
-
-    // We skip <srcdoc> tests for attr-referrer, because delivering referrer
-    // policy via DOM attributes inside <srcdoc> is quite similar to doing
-    // so in the top-level Document.
-    if (scenario.delivery_method === "attr-referrer") {
-      return;
-    }
-
-    // Request in a `srcdoc` frame to ensure that it uses the referrer
-    // policy of its parent,
-    promise_test(_ => {
-        /** @type {Array<SourceContext>} */
-        const sourceContextList = [{sourceContextType: "srcdoc"}];
-
-        return invokeScenario(scenario, sourceContextList)
-          .then(result => checkResult(scenario.referrer_url, result));
-      }, testDescription + " (srcdoc iframe inherits parent)");
-
-    // We skip (top Document w/ referrer policy by HTTP headers)->
-    // (<iframe srcdoc> w/ overriding referrer policy) tests, because we
-    // already have similar (top Document w/ referrer policy by <meta>)->
-    // (<iframe srcdoc> w/ overriding referrer policy) tests.
-    if (scenario.delivery_method === "http-rp") {
-      return;
-    }
-
-    // We skip (top Document w/o referrer policy)->
-    // (<iframe srcdoc> w/ overriding referrer policy) tests, to simplify the
-    // generator. We already have (top Document w/ referrer policy)->
-    // (<iframe srcdoc> w/ overriding referrer policy) tests, which verify the
-    // <iframe srcdoc>'s referrer policy behavior.
-    if (scenario.referrer_policy === null) {
-      return;
-    }
-
-    // Request in a `srcdoc` frame with its own referrer policy to
-    // override its parent.
-    promise_test(_ => {
-        // Give a srcdoc iframe a referrer policy different from the
-        // top-level page's policy.
-        const overridingPolicy =
-            scenario.referrer_policy === "no-referrer" ? "unsafe-url"
-                                                       : "no-referrer";
-        const overrridingExpectation =
-            overridingPolicy === "no-referrer" ? "omitted"
-                                               : "stripped-referrer";
-
-        const scenarioWithoutDelivery = Object.assign({}, scenario);
-        // Omit policy deliveries applied to subresource requests.
-        // This is hacky method but will be removed soon.
-        scenarioWithoutDelivery.delivery_method = null;
-
-        // <iframe srcdoc> with overriding <meta> referrerPolicy.
-        /** @type {Array<SourceContext>} */
-        const sourceContextList = [{
-            sourceContextType: "srcdoc",
-            policyDeliveries: [{deliveryType: "meta",
-                                key: "referrerPolicy",
-                                value: overridingPolicy}]
-          }];
-
-        return invokeScenario(scenarioWithoutDelivery, sourceContextList)
-          .then(result => checkResult(overrridingExpectation, result));
-      }, testDescription + " (overridden by srcdoc iframe)");
-  }
-
-  return {start: runTest};
-}
--- a/testing/web-platform/tests/referrer-policy/generic/sandboxed-iframe-with-opaque-origin.html
+++ b/testing/web-platform/tests/referrer-policy/generic/sandboxed-iframe-with-opaque-origin.html
@@ -3,17 +3,16 @@
   <head>
     <title>Referrer Policy: Sandboxed iframes with opaque origins don't send referrers</title>
     <link rel="author" title="Jochen Eisinger" href="mailto:jochen@chromium.org">
     <link rel="help" href="https://www.w3.org/TR/referrer-policy/#determine-requests-referrer">
     <script src="/resources/testharness.js"></script>
     <script src="/resources/testharnessreport.js"></script>
     <!-- Common global functions for referrer-policy tests. -->
     <script src="/common/security-features/resources/common.sub.js"></script>
-    <script src="/referrer-policy/generic/referrer-policy-test-case.sub.js"></script>
   </head>
   <body>
     <h1>Referrer Policy: A document with an opaque origin doesn't send referrers</h1>
     <script>
       function testSandboxedIframe(description, sandboxAttributes, expectedReferrer) {
         async_test(function(test) {
           window.addEventListener("message", test.step_func((msg) => {
             if (msg.data.description === description) {
@@ -22,17 +21,16 @@
             }
           }));
 
           var iframe = document.createElement("iframe");
           iframe.sandbox = sandboxAttributes;
           iframe.srcdoc = `
               <meta name = "referrer" content = "always">
               <script src = "/common/security-features/resources/common.sub.js"></` + `script>
-              <script src = "/referrer-policy/generic/referrer-policy-test-case.sub.js"></` + `script>
               <script>
                 var urlPath = "/common/security-features/subresource/xhr.py";
                 var url = "${location.protocol}//www1.${location.hostname}:${location.port}" + urlPath;
                 requestViaXhr(url).then((msg) => {
                     parent.postMessage({referrer: msg.referrer, description: "${description}"}, "*")
                   })
                   .catch((e) => {
                     parent.postMessage({referrer: "FAILURE", description: "${description}"}, "*")
--- a/testing/web-platform/tests/referrer-policy/generic/subresource-test/area-navigate.html
+++ b/testing/web-platform/tests/referrer-policy/generic/subresource-test/area-navigate.html
@@ -2,17 +2,16 @@
 <!-- TODO(kristijanburnik): Remove subres. duplication. Reuse a template. -->
 <html>
   <head>
     <title>Area Link messaging - cross-origin Area Link navigation</title>
     <script src="/resources/testharness.js"></script>
     <script src="/resources/testharnessreport.js"></script>
     <!-- Common global functions for referrer-policy tests. -->
     <script src="/common/security-features/resources/common.sub.js"></script>
-    <script src="/referrer-policy/generic/referrer-policy-test-case.sub.js"></script>
   </head>
   <body>
     <h1>Area Link messaging - cross-origin Area Link navigation</h1>
     <p>If you can read JSON encoded HTTP request headers of the Area link below,
        the messaging works as expected.</p>
 
     <pre id="received_message">Running...</pre>
 
--- a/testing/web-platform/tests/referrer-policy/generic/subresource-test/fetch-messaging.html
+++ b/testing/web-platform/tests/referrer-policy/generic/subresource-test/fetch-messaging.html
@@ -2,17 +2,16 @@
 <!-- TODO(kristijanburnik): Remove subres. duplication. Reuse a template. -->
 <html>
   <head>
     <title>Fetch messaging - same-origin Fetch request</title>
     <script src="/resources/testharness.js"></script>
     <script src="/resources/testharnessreport.js"></script>
     <!-- Common global functions for referrer-policy tests. -->
     <script src="/common/security-features/resources/common.sub.js"></script>
-    <script src="/referrer-policy/generic/referrer-policy-test-case.sub.js"></script>
   </head>
   <body>
     <h1>Fetch messaging - same-origin Fetch request</h1>
     <p>If you can read JSON encoded HTTP request headers of the Fetch below,
        the messaging works as expected.</p>
 
     <pre id="received_message">Running...</pre>
 
--- a/testing/web-platform/tests/referrer-policy/generic/subresource-test/iframe-messaging.html
+++ b/testing/web-platform/tests/referrer-policy/generic/subresource-test/iframe-messaging.html
@@ -2,17 +2,16 @@
 <!-- TODO(kristijanburnik): Remove subres. duplication. Reuse a template. -->
 <html>
   <head>
     <title>Iframe messaging - cross-origin iframe request</title>
     <script src="/resources/testharness.js"></script>
     <script src="/resources/testharnessreport.js"></script>
     <!-- Common global functions for referrer-policy tests. -->
     <script src="/common/security-features/resources/common.sub.js"></script>
-    <script src="/referrer-policy/generic/referrer-policy-test-case.sub.js"></script>
   </head>
   <body>
     <h1>Iframe messaging - cross-origin iframe request</h1>
     <p>If you can read JSON encoded HTTP request headers of the iframe below,
        the messaging works as expected.</p>
 
     <pre id="received_message">Running...</pre>
 
--- a/testing/web-platform/tests/referrer-policy/generic/subresource-test/image-decoding.html
+++ b/testing/web-platform/tests/referrer-policy/generic/subresource-test/image-decoding.html
@@ -2,17 +2,16 @@
 <!-- TODO(kristijanburnik): Remove subres. duplication. Reuse a template. -->
 <html>
   <head>
     <title>Image decoding - cross-origin image request</title>
     <script src="/resources/testharness.js"></script>
     <script src="/resources/testharnessreport.js"></script>
     <!-- Common global functions for referrer-policy tests. -->
     <script src="/common/security-features/resources/common.sub.js"></script>
-    <script src="/referrer-policy/generic/referrer-policy-test-case.sub.js"></script>
   </head>
   <body>
     <h1>Image decoding - cross-origin image request</h1>
     <p>If you can read JSON encoded HTTP headers of the image below,
        the decoding works as expected.</p>
 
     <pre id="received_message">Running...</pre>
 
--- a/testing/web-platform/tests/referrer-policy/generic/subresource-test/link-navigate.html
+++ b/testing/web-platform/tests/referrer-policy/generic/subresource-test/link-navigate.html
@@ -2,17 +2,16 @@
 <!-- TODO(kristijanburnik): Remove subres. duplication. Reuse a template. -->
 <html>
   <head>
     <title>Link messaging - cross-origin Link navigation</title>
     <script src="/resources/testharness.js"></script>
     <script src="/resources/testharnessreport.js"></script>
     <!-- Common global functions for referrer-policy tests. -->
     <script src="/common/security-features/resources/common.sub.js"></script>
-    <script src="/referrer-policy/generic/referrer-policy-test-case.sub.js"></script>
   </head>
   <body>
     <h1>Link messaging - cross-origin Link navigation</h1>
     <p>If you can read JSON encoded HTTP request headers of the Link below,
        the messaging works as expected.</p>
 
     <pre id="received_message">Running...</pre>
 
--- a/testing/web-platform/tests/referrer-policy/generic/subresource-test/script-messaging.html
+++ b/testing/web-platform/tests/referrer-policy/generic/subresource-test/script-messaging.html
@@ -2,17 +2,16 @@
 <!-- TODO(kristijanburnik): Remove subres. duplication. Reuse a template. -->
 <html>
   <head>
     <title>Script messaging - cross-origin Script request</title>
     <script src="/resources/testharness.js"></script>
     <script src="/resources/testharnessreport.js"></script>
     <!-- Common global functions for referrer-policy tests. -->
     <script src="/common/security-features/resources/common.sub.js"></script>
-    <script src="/referrer-policy/generic/referrer-policy-test-case.sub.js"></script>
   </head>
   <body>
     <h1>Script messaging - cross-origin Script request</h1>
     <p>If you can read JSON encoded HTTP request headers of the Script below,
        the messaging works as expected.</p>
 
     <pre id="received_message">Running...</pre>
 
--- a/testing/web-platform/tests/referrer-policy/generic/subresource-test/worker-messaging.html
+++ b/testing/web-platform/tests/referrer-policy/generic/subresource-test/worker-messaging.html
@@ -2,17 +2,16 @@
 <!-- TODO(kristijanburnik): Remove subres. duplication. Reuse a template. -->
 <html>
   <head>
     <title>Worker messaging - same-origin Worker request</title>
     <script src="/resources/testharness.js"></script>
     <script src="/resources/testharnessreport.js"></script>
     <!-- Common global functions for referrer-policy tests. -->
     <script src="/common/security-features/resources/common.sub.js"></script>
-    <script src="/referrer-policy/generic/referrer-policy-test-case.sub.js"></script>
   </head>
   <body>
     <h1>Worker messaging - same-origin Worker request</h1>
     <p>If you can read JSON encoded HTTP request headers of the Worker below,
        the messaging works as expected.</p>
 
     <pre id="received_message">Running...</pre>
 
--- a/testing/web-platform/tests/referrer-policy/generic/subresource-test/xhr-messaging.html
+++ b/testing/web-platform/tests/referrer-policy/generic/subresource-test/xhr-messaging.html
@@ -2,17 +2,16 @@
 <!-- TODO(kristijanburnik): Remove subres. duplication. Reuse a template. -->
 <html>
   <head>
     <title>XHR messaging - cross-origin XHR request</title>
     <script src="/resources/testharness.js"></script>
     <script src="/resources/testharnessreport.js"></script>
     <!-- Common global functions for referrer-policy tests. -->
     <script src="/common/security-features/resources/common.sub.js"></script>
-    <script src="/referrer-policy/generic/referrer-policy-test-case.sub.js"></script>
   </head>
   <body>
     <h1>XHR messaging - cross-origin XHR request</h1>
     <p>If you can read JSON encoded HTTP request headers of the XHR below,
        the messaging works as expected.</p>
 
     <pre id="received_message">Running...</pre>
 
--- a/testing/web-platform/tests/referrer-policy/generic/test-case.sub.js
+++ b/testing/web-platform/tests/referrer-policy/generic/test-case.sub.js
@@ -1,52 +1,8 @@
-// TODO: This function is currently placed and duplicated at:
-// - mixed-content/generic/mixed-content-test-case.js
-// - referrer-policy/generic/referrer-policy-test-case.sub.js
-// but should be moved to /common/security-features/resources/common.js.
-function getSubresourceOrigin(originType) {
-  const httpProtocol = "http";
-  const httpsProtocol = "https";
-  const wsProtocol = "ws";
-  const wssProtocol = "wss";
-
-  const sameOriginHost = "{{host}}";
-  const crossOriginHost = "{{domains[www1]}}";
-
-  // These values can evaluate to either empty strings or a ":port" string.
-  const httpPort = getNormalizedPort(parseInt("{{ports[http][0]}}", 10));
-  const httpsPort = getNormalizedPort(parseInt("{{ports[https][0]}}", 10));
-  const wsPort = getNormalizedPort(parseInt("{{ports[ws][0]}}", 10));
-  const wssPort = getNormalizedPort(parseInt("{{ports[wss][0]}}", 10));
-
-  /**
-    @typedef OriginType
-    @type {string}
-
-    Represents the origin of the subresource request URL.
-    The keys of `originMap` below are the valid values.
-
-    Note that there can be redirects from the specified origin
-    (see RedirectionType), and thus the origin of the subresource
-    response URL might be different from what is specified by OriginType.
-  */
-  const originMap = {
-    "same-https": httpsProtocol + "://" + sameOriginHost + httpsPort,
-    "same-http": httpProtocol + "://" + sameOriginHost + httpPort,
-    "cross-https": httpsProtocol + "://" + crossOriginHost + httpsPort,
-    "cross-http": httpProtocol + "://" + crossOriginHost + httpPort,
-    "same-wss": wssProtocol + "://" + sameOriginHost + wssPort,
-    "same-ws": wsProtocol + "://" + sameOriginHost + wsPort,
-    "cross-wss": wssProtocol + "://" + crossOriginHost + wssPort,
-    "cross-ws": wsProtocol + "://" + crossOriginHost + wsPort,
-  };
-
-  return originMap[originType];
-}
-
 // NOTE: This method only strips the fragment and is not in accordance to the
 // recommended draft specification:
 // https://w3c.github.io/webappsec/specs/referrer-policy/#null
 // TODO(kristijanburnik): Implement this helper as defined by spec once added
 // scenarios for URLs containing username/password/etc.
 function stripUrlForUseAsReferrer(url) {
   return url.replace(/#.*$/, "");
 }
--- a/testing/web-platform/tests/referrer-policy/generic/unsupported-csp-referrer-directive.html
+++ b/testing/web-platform/tests/referrer-policy/generic/unsupported-csp-referrer-directive.html
@@ -2,17 +2,16 @@
 <html>
   <head>
     <title>Referrer Policy: CSP 'referrer' directive should not be supported</title>
     <meta http-equiv="Content-Security-Policy" content="referrer no-referrer">
     <script src="/resources/testharness.js"></script>
     <script src="/resources/testharnessreport.js"></script>
     <!-- Common global functions for referrer-policy tests. -->
     <script src="/common/security-features/resources/common.sub.js"></script>
-    <script src="/referrer-policy/generic/referrer-policy-test-case.sub.js"></script>
   </head>
   <body>
     <h1>Referrer Policy: CSP 'referrer' directive should not be supported</h1>
     <p>CSP used to have a 'referrer' directive to set a Referrer Policy. This directive has been removed and should not be supported.</p>
 
     <pre id="received_message">Running...</pre>
 
     <script>