Bug 1340652 P4 Test fetch referer header in worker and redirected worker scripts. r=baku
authorBen Kelly <ben@wanderview.com>
Thu, 23 Feb 2017 10:54:42 -0500
changeset 373630 6417e23dc2ad87cbb058cdccfd9a1acd75d84a12
parent 373629 9b3d067a2d743d5a24451c24e08e8cd7aa600fc6
child 373631 a02f3229c14c08ed7017e8c527d7a36cc03692a1
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
bugs1340652
milestone54.0a1
Bug 1340652 P4 Test fetch referer header in worker and redirected worker scripts. r=baku
testing/web-platform/meta/MANIFEST.json
testing/web-platform/tests/fetch/api/basic/request-referrer-redirected-worker.html
testing/web-platform/tests/fetch/api/basic/request-referrer-worker.html
testing/web-platform/tests/fetch/api/basic/request-referrer.js
--- a/testing/web-platform/meta/MANIFEST.json
+++ b/testing/web-platform/meta/MANIFEST.json
@@ -87094,16 +87094,28 @@
     ]
    ],
    "fetch/api/basic/request-headers.html": [
     [
      "/fetch/api/basic/request-headers.html",
      {}
     ]
    ],
+   "fetch/api/basic/request-referrer-redirected-worker.html": [
+    [
+     "/fetch/api/basic/request-referrer-redirected-worker.html",
+     {}
+    ]
+   ],
+   "fetch/api/basic/request-referrer-worker.html": [
+    [
+     "/fetch/api/basic/request-referrer-worker.html",
+     {}
+    ]
+   ],
    "fetch/api/basic/request-referrer.html": [
     [
      "/fetch/api/basic/request-referrer.html",
      {}
     ]
    ],
    "fetch/api/basic/request-upload-worker.html": [
     [
@@ -163313,22 +163325,30 @@
   "fetch/api/basic/request-headers.html": [
    "acbbe8b43977b92a4545be5ca061a0214a55dea5",
    "testharness"
   ],
   "fetch/api/basic/request-headers.js": [
    "6a15c64c072f4e57470ed3f2709e43fa2f806b79",
    "support"
   ],
+  "fetch/api/basic/request-referrer-redirected-worker.html": [
+   "41013925a84ab080c9c9f3b16ef4d8fdd1d50588",
+   "testharness"
+  ],
+  "fetch/api/basic/request-referrer-worker.html": [
+   "3dad9617d76eed94d8b759d0d27b20c431873dd4",
+   "testharness"
+  ],
   "fetch/api/basic/request-referrer.html": [
    "acf1ca37cf3904eccf4c7a9248c49e68f6260866",
    "testharness"
   ],
   "fetch/api/basic/request-referrer.js": [
-   "5267f72887c4f7b039d2a5aae3519dc54cceca97",
+   "03c8ccec8ee4b37994bf38f20ff9fd531a209974",
    "support"
   ],
   "fetch/api/basic/request-upload-worker.html": [
    "6d017418f5fef7ee2750180676294cf7770368b7",
    "testharness"
   ],
   "fetch/api/basic/request-upload.html": [
    "c0bb59ee5b15fac13b838912918b4c5ee6838136",
new file mode 100644
--- /dev/null
+++ b/testing/web-platform/tests/fetch/api/basic/request-referrer-redirected-worker.html
@@ -0,0 +1,17 @@
+<!doctype html>
+<html>
+  <head>
+    <meta charset="utf-8">
+    <title>Fetch in worker: referrer header</title>
+    <script src="/resources/testharness.js"></script>
+    <script src="/resources/testharnessreport.js"></script>
+  </head>
+  <body>
+    <script>
+      let finalURL = "/fetch/api/basic/request-referrer.js";
+      let url = "/fetch/api/resources/redirect.py?location=" +
+                encodeURIComponent(finalURL);
+      fetch_tests_from_worker(new Worker(url));
+    </script>
+  </body>
+</html>
new file mode 100644
--- /dev/null
+++ b/testing/web-platform/tests/fetch/api/basic/request-referrer-worker.html
@@ -0,0 +1,14 @@
+<!doctype html>
+<html>
+  <head>
+    <meta charset="utf-8">
+    <title>Fetch in worker: referrer header</title>
+    <script src="/resources/testharness.js"></script>
+    <script src="/resources/testharnessreport.js"></script>
+  </head>
+  <body>
+    <script>
+      fetch_tests_from_worker(new Worker("request-referrer.js"));
+    </script>
+  </body>
+</html>
--- a/testing/web-platform/tests/fetch/api/basic/request-referrer.js
+++ b/testing/web-platform/tests/fetch/api/basic/request-referrer.js
@@ -1,28 +1,28 @@
 if (this.document === undefined) {
   importScripts("/resources/testharness.js");
   importScripts("../resources/utils.js");
 }
 
-function testReferrer(referrer, expected) {
+function testReferrer(referrer, expected, desc) {
   promise_test(function(test) {
     var url = RESOURCES_DIR + "inspect-headers.py?headers=referer"
     var req = new Request(url, { referrer: referrer });
     return fetch(req).then(function(resp) {
       var actual = resp.headers.get("x-request-referer");
       if (expected) {
         assert_equals(actual, expected, "request's referer should be: " + expected);
         return;
       }
       if (actual) {
         assert_equals(actual, "", "request's referer should be empty");
       }
     });
-  });
+  }, desc);
 }
 
-testReferrer("about:client", window.location.href);
+testReferrer("about:client", self.location.href, 'about:client referrer');
 
-var fooURL = new URL("./foo", window.location).href;
-testReferrer(fooURL, fooURL);
+var fooURL = new URL("./foo", self.location).href;
+testReferrer(fooURL, fooURL, 'url referrer');
 
 done();