Bug 1321854 add logging for intermittent, r=mixedpuppy draft
authorShane Caraveo <scaraveo@mozilla.com>
Tue, 31 Oct 2017 15:46:13 -0700
changeset 689767 cdee6fc233475a3f29f4ec58833da67a32632b5a
parent 689459 0a7ff6e19bcc229500d92597fac9340d9bdef959
child 738385 37aee10f2975286d52394cad8152ac922e5ffc12
push id87099
push usermixedpuppy@gmail.com
push dateTue, 31 Oct 2017 22:46:32 +0000
reviewersmixedpuppy
bugs1321854
milestone58.0a1
Bug 1321854 add logging for intermittent, r=mixedpuppy MozReview-Commit-ID: 6Wo1CYLVtgL
browser/components/extensions/test/browser/browser_ext_webRequest.js
--- a/browser/components/extensions/test/browser/browser_ext_webRequest.js
+++ b/browser/components/extensions/test/browser/browser_ext_webRequest.js
@@ -4,16 +4,18 @@
 
 /* import-globals-from ../../../../../toolkit/components/extensions/test/mochitest/head_webrequest.js */
 Services.scriptloader.loadSubScript(new URL("head_webrequest.js", gTestPath).href,
                                     this);
 
 Cu.import("resource://testing-common/HiddenFrame.jsm", this);
 const XUL_NS = "http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul";
 
+SimpleTest.requestCompleteLog();
+
 function createHiddenBrowser(url) {
   let frame = new HiddenFrame();
   return new Promise(resolve =>
     frame.get().then(subframe => {
       let doc = subframe.document;
       let browser = doc.createElementNS(XUL_NS, "browser");
       browser.setAttribute("type", "content");
       browser.setAttribute("disableglobalhistory", "true");
@@ -49,18 +51,27 @@ let headers = {
       "content-type": "text/html; charset=utf-8",
     },
     remove: [
       "connection",
     ],
   },
 };
 
+let urls = ["http://mochi.test/browser/*"];
+let events = {
+  "onBeforeRequest":     [{urls}, ["blocking"]],
+  "onBeforeSendHeaders": [{urls}, ["blocking", "requestHeaders"]],
+  "onSendHeaders":       [{urls}, ["requestHeaders"]],
+  "onHeadersReceived":   [{urls}, ["blocking", "responseHeaders"]],
+  "onCompleted":         [{urls}, ["responseHeaders"]],
+};
+
 add_task(async function setup() {
-  extension = makeExtension();
+  extension = makeExtension(events);
   await extension.startup();
 });
 
 add_task(async function test_newWindow() {
   let expect = {
     "file_dummy.html": {
       type: "main_frame",
       headers,
@@ -70,50 +81,54 @@ add_task(async function test_newWindow()
   // 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"]});
   await extension.awaitMessage("continue");
 
   let openedWindow = await BrowserTestUtils.openNewBrowserWindow();
-  await BrowserTestUtils.openNewForegroundTab(openedWindow.gBrowser, dummy + "?newWindow");
+  await BrowserTestUtils.openNewForegroundTab(openedWindow.gBrowser, `${dummy}?newWindow=${Math.random()}`);
 
   await extension.awaitMessage("done");
   await BrowserTestUtils.closeWindow(openedWindow);
 });
 
 add_task(async function test_newTab() {
   // again, in this window
   let expect = {
     "file_dummy.html": {
       type: "main_frame",
       headers,
     },
   };
   extension.sendMessage("set-expected", {expect, ignore: ["favicon.ico"]});
   await extension.awaitMessage("continue");
-  let tab = await BrowserTestUtils.openNewForegroundTab(window.gBrowser, dummy + "?newTab");
+  let tab = await BrowserTestUtils.openNewForegroundTab(window.gBrowser, `${dummy}?newTab=${Math.random()}`);
 
   await extension.awaitMessage("done");
   await BrowserTestUtils.removeTab(tab);
 });
 
 add_task(async 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"]});
+  info("*** waiting to continue");
   await extension.awaitMessage("continue");
-  let frameInfo = await createHiddenBrowser(dummy + "?subframe");
+  info("*** creating hidden browser");
+  let frameInfo = await createHiddenBrowser(`${dummy}?subframe=${Math.random()}`);
+  info("*** waiting for finish");
   await extension.awaitMessage("done");
+  info("*** destroying hidden browser");
   // cleanup
   frameInfo.browser.remove();
   frameInfo.frame.destroy();
 });
 
 add_task(async function teardown() {
   await extension.unload();
 });