Bug 1285502 - Part 2: Add wpt verifying fetch() respects a Request object's referrer. r=asuth, a=gchang
authorBen Kelly <ben@wanderview.com>
Mon, 11 Jul 2016 12:40:00 -0400
changeset 340081 9baf67cba2548ba4b1495521347b6128e578c3a8
parent 340080 4e0eadf7b6a17d1602a7b01c6ea0036a4d4e3de2
child 340082 1ba7f271fd89879b18c14878a9607197aeb742f1
push id6249
push userjlund@mozilla.com
push dateMon, 01 Aug 2016 13:59:36 +0000
treeherdermozilla-beta@bad9d4f5bf7e [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersasuth, gchang
bugs1285502
milestone49.0a2
Bug 1285502 - Part 2: Add wpt verifying fetch() respects a Request object's referrer. r=asuth, a=gchang
testing/web-platform/meta/MANIFEST.json
testing/web-platform/tests/fetch/api/basic/request-referrer.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
@@ -36031,16 +36031,22 @@
           }
         ],
         "html/semantics/embedded-content/the-embed-element/embed-in-object-fallback.html": [
           {
             "path": "html/semantics/embedded-content/the-embed-element/embed-in-object-fallback.html",
             "url": "/html/semantics/embedded-content/the-embed-element/embed-in-object-fallback.html"
           }
         ],
+        "fetch/api/basic/request-referrer.html": [
+          {
+            "path": "fetch/api/basic/request-referrer.html",
+            "url": "/fetch/api/basic/request-referrer.html"
+          }
+        ],
         "service-workers/service-worker/controller-on-disconnect.https.html": [
           {
             "path": "service-workers/service-worker/controller-on-disconnect.https.html",
             "url": "/service-workers/service-worker/controller-on-disconnect.https.html"
           }
         ],
         "web-animations/timing-model/animations/current-time.html": [
           {
new file mode 100644
--- /dev/null
+++ b/testing/web-platform/tests/fetch/api/basic/request-referrer.html
@@ -0,0 +1,13 @@
+<!doctype html>
+<html>
+  <head>
+    <meta charset="utf-8">
+    <title>Fetch: fetch() respects Request referrer value</title>
+    <script src="/resources/testharness.js"></script>
+    <script src="/resources/testharnessreport.js"></script>
+  </head>
+  <body>
+    <script src="../resources/utils.js"></script>
+    <script src="request-referrer.js"></script>
+  </body>
+</html>
new file mode 100644
--- /dev/null
+++ b/testing/web-platform/tests/fetch/api/basic/request-referrer.js
@@ -0,0 +1,28 @@
+if (this.document === undefined) {
+  importScripts("/resources/testharness.js");
+  importScripts("../resources/utils.js");
+}
+
+function testReferrer(referrer, expected) {
+  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");
+      }
+    });
+  });
+}
+
+testReferrer("about:client", window.location.href);
+
+var fooURL = new URL("./foo", window.location).href;
+testReferrer(fooURL, fooURL);
+
+done();