Bug 1205495 - Correctly use the requests's body and redirect mode in reroute.js. r=nsm, a=test-only
authorEhsan Akhgari <ehsan@mozilla.com>
Tue, 22 Sep 2015 17:45:25 -0400
changeset 297848 18f38260f260e8dec7878fec4edb3364b84b2bcd
parent 297847 53fa6882c8c559bb8b5e72897e6ff5512c57f6bd
child 297849 8d8e196388b2a14f1cf9db825d244bfb634951ae
push id962
push userjlund@mozilla.com
push dateFri, 04 Dec 2015 23:28:54 +0000
treeherdermozilla-release@23a2d286e80f [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersnsm, test-only
bugs1205495
milestone43.0a2
Bug 1205495 - Correctly use the requests's body and redirect mode in reroute.js. r=nsm, a=test-only
dom/tests/mochitest/fetch/reroute.js
--- a/dom/tests/mochitest/fetch/reroute.js
+++ b/dom/tests/mochitest/fetch/reroute.js
@@ -1,19 +1,23 @@
 onfetch = function(e) {
   if (e.request.url.indexOf("Referer") >= 0) {
     // Silently rewrite the referrer so the referrer test passes since the
     // document/worker isn't aware of this service worker.
     var url = e.request.url.substring(0, e.request.url.indexOf('?'));
     url += '?headers=' + ({ 'Referer': self.location.href }).toSource();
 
-    e.respondWith(fetch(url, {
-      method: e.request.method,
-      headers: e.request.headers,
-      body: e.request.body,
-      mode: e.request.mode,
-      credentials: e.request.credentials,
-      cache: e.request.cache,
+    e.respondWith(e.request.text().then(function(text) {
+      var body = text === '' ? undefined : text;
+      return fetch(url, {
+        method: e.request.method,
+        headers: e.request.headers,
+        body: body,
+        mode: e.request.mode,
+        credentials: e.request.credentials,
+        redirect: e.request.redirect,
+        cache: e.request.cache,
+      });
     }));
     return;
   }
   e.respondWith(fetch(e.request));
 };