Bug 1366710 set webrequest type to xmlhttprequest for fetch requests, r=aswan
authorShane Caraveo <scaraveo@mozilla.com>
Tue, 23 May 2017 13:33:55 -0700
changeset 409234 c53d4e01d100a1353cc7b8f0928c2470e9b48e1a
parent 409233 3e84fda34fa7e538bb0a443695a72ba1c30bce97
child 409235 7679f368a1f3426bc0c9e3cc4156f9d630c7dfe5
push id7391
push usermtabara@mozilla.com
push dateMon, 12 Jun 2017 13:08:53 +0000
treeherdermozilla-beta@2191d7f87e2e [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersaswan
bugs1366710
milestone55.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 1366710 set webrequest type to xmlhttprequest for fetch requests, r=aswan MozReview-Commit-ID: GkhojDrmWC5
toolkit/components/extensions/test/mochitest/test_ext_webrequest_background_events.html
toolkit/components/extensions/test/mochitest/test_ext_webrequest_filter.html
toolkit/modules/addons/WebRequestCommon.jsm
--- a/toolkit/components/extensions/test/mochitest/test_ext_webrequest_background_events.html
+++ b/toolkit/components/extensions/test/mochitest/test_ext_webrequest_background_events.html
@@ -77,16 +77,17 @@ add_task(async function test_webRequest_
         "onCompleted",
       ]);
 
       function listener(name, details) {
         browser.test.assertTrue(eventNames.has(name), `recieved ${name}`);
         eventNames.delete(name);
 
         if (eventNames.size === 0) {
+          browser.test.assertEq("xmlhttprequest", details.type, "correct type for fetch [bug 1366710]");
           browser.test.assertEq(0, eventNames.size, "messages recieved");
           browser.test.sendMessage("done");
         }
       }
 
       for (let name of eventNames) {
         browser.webRequest[name].addListener(
           listener.bind(null, name),
--- a/toolkit/components/extensions/test/mochitest/test_ext_webrequest_filter.html
+++ b/toolkit/components/extensions/test/mochitest/test_ext_webrequest_filter.html
@@ -167,17 +167,17 @@ add_task(async function test_webRequest_
   let expect = {
     "webrequest_worker.js": {
       type: "script",
     },
     "example.txt": {
       status: 404,
       events: ["onBeforeRequest", "onBeforeSendHeaders", "onSendHeaders", "onHeadersReceived", "onResponseStarted"],
       optional_events: ["onCompleted", "onErrorOccurred"],
-      type: "other",
+      type: "xmlhttprequest",
       origin: SimpleTest.getTestFileURL("webrequest_worker.js?test2"),
     },
   };
 
   let extension = makeExtension(events);
   await extension.startup();
   extension.sendMessage("set-expected", {expect, origin: location.href});
   await extension.awaitMessage("continue");
--- a/toolkit/modules/addons/WebRequestCommon.jsm
+++ b/toolkit/modules/addons/WebRequestCommon.jsm
@@ -19,16 +19,18 @@ var WebRequestCommon = {
       case Ci.nsIContentPolicy.TYPE_DOCUMENT: return "main_frame";
       case Ci.nsIContentPolicy.TYPE_SUBDOCUMENT: return "sub_frame";
       case Ci.nsIContentPolicy.TYPE_STYLESHEET: return "stylesheet";
       case Ci.nsIContentPolicy.TYPE_SCRIPT: return "script";
       case Ci.nsIContentPolicy.TYPE_IMAGE: return "image";
       case Ci.nsIContentPolicy.TYPE_OBJECT: return "object";
       case Ci.nsIContentPolicy.TYPE_OBJECT_SUBREQUEST: return "object_subrequest";
       case Ci.nsIContentPolicy.TYPE_XMLHTTPREQUEST: return "xmlhttprequest";
+      // TYPE_FETCH returns xmlhttprequest for cross-browser compatibility.
+      case Ci.nsIContentPolicy.TYPE_FETCH: return "xmlhttprequest";
       case Ci.nsIContentPolicy.TYPE_XBL: return "xbl";
       case Ci.nsIContentPolicy.TYPE_XSLT: return "xslt";
       case Ci.nsIContentPolicy.TYPE_PING: return "ping";
       case Ci.nsIContentPolicy.TYPE_BEACON: return "beacon";
       case Ci.nsIContentPolicy.TYPE_DTD: return "xml_dtd";
       case Ci.nsIContentPolicy.TYPE_FONT: return "font";
       case Ci.nsIContentPolicy.TYPE_MEDIA: return "media";
       case Ci.nsIContentPolicy.TYPE_WEBSOCKET: return "websocket";