Bug 1321615 fix tests for header modification in toplevel loads, r=kmag
☠☠ backed out by cf2d377f4a5f ☠ ☠
authorShane Caraveo <scaraveo@mozilla.com>
Thu, 01 Dec 2016 11:46:36 -0800
changeset 325061 4c343bdb6e2aad0f2254bfa14d39b19810a53201
parent 325060 308bc1917b91c428eeaffe19940018f1373c3e82
child 325062 c4db9e919f6c7b4cb6b3892a3a23f3056d63f811
push id24
push usermaklebus@msu.edu
push dateTue, 20 Dec 2016 03:11:33 +0000
reviewerskmag
bugs1321615
milestone53.0a1
Bug 1321615 fix tests for header modification in toplevel loads, r=kmag MozReview-Commit-ID: 3GfDbeumwzj
browser/components/extensions/test/browser/browser_ext_webRequest.js
toolkit/components/extensions/test/mochitest/head_webrequest.js
--- a/browser/components/extensions/test/browser/browser_ext_webRequest.js
+++ b/browser/components/extensions/test/browser/browser_ext_webRequest.js
@@ -21,31 +21,59 @@ function createHiddenBrowser(url) {
 
       doc.documentElement.appendChild(browser);
       resolve({frame: frame, browser: browser});
     }));
 }
 
 let extension;
 let dummy = "http://mochi.test:8888/browser/browser/components/extensions/test/browser/file_dummy.html";
+let headers = {
+  request: {
+    add: {
+      "X-WebRequest-request": "text",
+      "X-WebRequest-request-binary": "binary",
+    },
+    modify: {
+      "user-agent": "WebRequest",
+    },
+    remove: [
+      "accept-encoding",
+    ],
+  },
+  response: {
+    add: {
+      "X-WebRequest-response": "text",
+      "X-WebRequest-response-binary": "binary",
+    },
+    modify: {
+      "server": "WebRequest",
+      "content-type": "text/html; charset=utf-8",
+    },
+    remove: [
+      "connection",
+    ],
+  },
+};
 
 add_task(function* setup() {
   // SelfSupport has a tendency to fire when running this test alone, without
   // a good way to turn it off we just set the url to ""
   yield SpecialPowers.pushPrefEnv({
     set: [["browser.selfsupport.url", ""]],
   });
   extension = makeExtension();
   yield extension.startup();
 });
 
 add_task(function* test_newWindow() {
   let expect = {
     "file_dummy.html": {
       type: "main_frame",
+      headers,
     },
   };
   // NOTE: When running solo, favicon will be loaded at some point during
   // the tests in this file, so all tests ignore it.  When running with
   // other tests in this directory, favicon gets loaded at some point before
   // we run, and we never see the request, thus it cannot be handled as part
   // of expect above.
   extension.sendMessage("set-expected", {expect, ignore: ["favicon.ico"]});
@@ -58,30 +86,32 @@ add_task(function* test_newWindow() {
   yield BrowserTestUtils.closeWindow(openedWindow);
 });
 
 add_task(function* test_newTab() {
   // again, in this window
   let expect = {
     "file_dummy.html": {
       type: "main_frame",
+      headers,
     },
   };
   extension.sendMessage("set-expected", {expect, ignore: ["favicon.ico"]});
   yield extension.awaitMessage("continue");
   let tab = yield BrowserTestUtils.openNewForegroundTab(window.gBrowser, dummy + "?newTab");
 
   yield extension.awaitMessage("done");
   yield BrowserTestUtils.removeTab(tab);
 });
 
 add_task(function* test_subframe() {
   let expect = {
     "file_dummy.html": {
       type: "main_frame",
+      headers,
     },
   };
   // test a content subframe attached to hidden window
   extension.sendMessage("set-expected", {expect, ignore: ["favicon.ico"]});
   yield extension.awaitMessage("continue");
   let frameInfo = yield createHiddenBrowser(dummy + "?subframe");
   yield extension.awaitMessage("done");
   // cleanup
--- a/toolkit/components/extensions/test/mochitest/head_webrequest.js
+++ b/toolkit/components/extensions/test/mochitest/head_webrequest.js
@@ -85,16 +85,17 @@ function background(events) {
   //   remove: ["HeaderName",],
   // },
   function processHeaders(phase, expected, details) {
     // This should only happen once per phase [request|response].
     browser.test.assertFalse(!!expected.test[phase], `First processing of headers for ${phase}`);
     expected.test[phase] = true;
 
     let headers = details[`${phase}Headers`];
+    browser.test.log(`headers are ${JSON.stringify(headers)}`);
     browser.test.assertTrue(Array.isArray(headers), `${phase}Headers array present`);
 
     let {add, modify, remove} = expected.headers[phase];
 
     for (let name in add) {
       browser.test.assertTrue(!headers.find(h => h.name === name), `header ${name} to be added not present yet in ${phase}Headers`);
       let header = {name: name};
       if (name.endsWith("-binary")) {