Bug 1243453 P2 Test XHR with a non-intercepting service worker. r=ehsan
authorBen Kelly <ben@wanderview.com>
Thu, 04 Feb 2016 07:28:21 -0800
changeset 283106 9c8c41a4678ecafbb20689d1b92cd5facdf60e8e
parent 283105 642aa364f5ae01e7584a2038abf5a1969bf14ca5
child 283107 880ef8eaff44943842cd54f1ea5985c4ef0076ec
push id29974
push usercbook@mozilla.com
push dateFri, 05 Feb 2016 10:53:43 +0000
treeherdermozilla-central@1dbe350b57b1 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersehsan
bugs1243453
milestone47.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 1243453 P2 Test XHR with a non-intercepting service worker. r=ehsan
dom/workers/test/serviceworkers/fetch/fetch_tests.js
dom/workers/test/serviceworkers/fetch_event_worker.js
--- a/dom/workers/test/serviceworkers/fetch/fetch_tests.js
+++ b/dom/workers/test/serviceworkers/fetch/fetch_tests.js
@@ -160,16 +160,25 @@ fetchXHR('hello-after-extracting.gz', fu
 });
 
 fetchXHR(corsServerURL + '?status=200&allowOrigin=*', function(xhr) {
   my_ok(xhr.status == 200, "cross origin load with correct headers should be successful");
   my_ok(xhr.getResponseHeader("access-control-allow-origin") == null, "cors headers should be filtered out");
   finish();
 });
 
+// Verify origin header is sent properly even when we have a no-intercept SW.
+var uriOrigin = encodeURIComponent(origin);
+fetchXHR('http://example.org' + corsServerPath + '?ignore&status=200&origin=' + uriOrigin +
+         '&allowOrigin=' + uriOrigin, function(xhr) {
+  my_ok(xhr.status == 200, "cross origin load with correct headers should be successful");
+  my_ok(xhr.getResponseHeader("access-control-allow-origin") == null, "cors headers should be filtered out");
+  finish();
+});
+
 // Verify that XHR is considered CORS tainted even when original URL is same-origin
 // redirected to cross-origin.
 fetchXHR(redirectURL([{ server: origin },
                       { server: 'http://example.org',
                         allowOrigin: origin }]), function(xhr) {
   my_ok(xhr.status == 200, "cross origin load with correct headers should be successful");
   my_ok(xhr.getResponseHeader("access-control-allow-origin") == null, "cors headers should be filtered out");
   finish();
--- a/dom/workers/test/serviceworkers/fetch_event_worker.js
+++ b/dom/workers/test/serviceworkers/fetch_event_worker.js
@@ -1,11 +1,15 @@
 var seenIndex = false;
 
 onfetch = function(ev) {
+  if (ev.request.url.includes("ignore")) {
+    return;
+  }
+
   if (ev.request.url.includes("bare-synthesized.txt")) {
     ev.respondWith(Promise.resolve(
       new Response("synthesized response body", {})
     ));
   }
 
   else if (ev.request.url.includes('file_CrossSiteXHR_server.sjs')) {
     // N.B. this response would break the rules of CORS if it were allowed, but
@@ -58,19 +62,16 @@ onfetch = function(ev) {
   }
 
   else if (ev.request.url.includes("synthesized-redirect-twice-synthesized.txt")) {
     ev.respondWith(Promise.resolve(
       Response.redirect("synthesized-redirect-synthesized.txt")
      ));
    }
 
-  else if (ev.request.url.includes("ignored.txt")) {
-  }
-
   else if (ev.request.url.includes("rejected.txt")) {
     ev.respondWith(Promise.reject());
   }
 
   else if (ev.request.url.includes("nonresponse.txt")) {
     ev.respondWith(Promise.resolve(5));
   }