Bug 1485660 - Special test fixes. r=jdescottes
☠☠ backed out by 7a97fe41a34f ☠ ☠
authorAlexandre Poirot <poirot.alex@gmail.com>
Thu, 11 Oct 2018 15:46:32 +0000
changeset 496464 9bb2f56f219dea3965b61216f770af18c89765a0
parent 496463 40a3c2dd1b38a33b31a99a6810b6df1f15dfb85d
child 496465 26e82fa6244486b3516c3279c13b6778839fcc3e
push id9984
push userffxbld-merge
push dateMon, 15 Oct 2018 21:07:35 +0000
treeherdermozilla-beta@183d27ea8570 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersjdescottes
bugs1485660
milestone64.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 1485660 - Special test fixes. r=jdescottes * browser_addons_debug_webextension_popup: It looks like frame-update events are now fired earlier. I had to move the listener to an earlier step in order to make it work. * helper_disable_cache + toolbox.js: this test wasn't correctly listening for reconfigure request's end. Not clear how this test was passing before without high rate of intermittent... * test_webextension-addon-debugging-connect.html: We can no longer listen for frame-update *before* the target object is created. (because we now need a TabTarget object or the TargetFront and not just the DebuggerClient) MozReview-Commit-ID: 49qvWSCn6nq Depends on D8066 Differential Revision: https://phabricator.services.mozilla.com/D7460
devtools/client/aboutdebugging/test/browser_addons_debug_webextension_popup.js
devtools/client/framework/test/helper_disable_cache.js
devtools/client/framework/toolbox.js
devtools/server/tests/mochitest/test_webextension-addon-debugging-connect.html
--- a/devtools/client/aboutdebugging/test/browser_addons_debug_webextension_popup.js
+++ b/devtools/client/aboutdebugging/test/browser_addons_debug_webextension_popup.js
@@ -86,17 +86,27 @@ add_task(async function testWebExtension
   // Be careful, this JS function is going to be executed in the addon toolbox,
   // which lives in another process. So do not try to use any scope variable!
   const env = Cc["@mozilla.org/process/environment;1"].getService(Ci.nsIEnvironment);
 
   const testScript = function() {
     /* eslint-disable no-undef */
 
     let jsterm;
-    let popupFramePromise;
+    const popupFramePromise = new Promise(resolve => {
+      const listener = data => {
+        if (data.frames.some(({url}) => url && url.endsWith("popup.html"))) {
+          toolbox.target.off("frame-update", listener);
+          resolve();
+        }
+      };
+      toolbox.target.on("frame-update", listener);
+    });
+
+    const waitForFrameListUpdate = toolbox.target.once("frame-update");
 
     toolbox.selectTool("webconsole")
       .then(async (console) => {
         const clickNoAutoHideMenu = () => {
           return new Promise(resolve => {
             toolbox.doc.getElementById("toolbox-meatball-menu-button").click();
             toolbox.doc.addEventListener("popupshown", () => {
               const menuItem =
@@ -106,28 +116,16 @@ add_task(async function testWebExtension
             }, { once: true });
           });
         };
 
         dump(`Clicking the menu button\n`);
         await clickNoAutoHideMenu();
         dump(`Clicked the menu button\n`);
 
-        popupFramePromise = new Promise(resolve => {
-          const listener = data => {
-            if (data.frames.some(({url}) => url && url.endsWith("popup.html"))) {
-              toolbox.target.off("frame-update", listener);
-              resolve();
-            }
-          };
-          toolbox.target.on("frame-update", listener);
-        });
-
-        const waitForFrameListUpdate = toolbox.target.once("frame-update");
-
         jsterm = console.hud.jsterm;
         jsterm.execute("myWebExtensionShowPopup()");
 
         await Promise.all([
           // Wait the initial frame update (which list the background page).
           waitForFrameListUpdate,
           // Wait the new frame update (once the extension popup has been opened).
           popupFramePromise,
--- a/devtools/client/framework/test/helper_disable_cache.js
+++ b/devtools/client/framework/test/helper_disable_cache.js
@@ -80,21 +80,22 @@ async function checkCacheEnabled(tabX, e
 async function setDisableCacheCheckboxChecked(tabX, state) {
   gBrowser.selectedTab = tabX.tab;
 
   const panel = tabX.toolbox.getCurrentPanel();
   const cbx = panel.panelDoc.getElementById("devtools-disable-cache");
 
   if (cbx.checked !== state) {
     info("Setting disable cache checkbox to " + state + " for " + tabX.title);
+    const onReconfigured = tabX.toolbox.once("cache-reconfigured");
     cbx.click();
 
-    // We need to wait for all checkboxes to be updated and the docshells to
-    // apply the new cache settings.
-    await waitForTick();
+    // We have to wait for the reconfigure request to be finished before reloading
+    // the page.
+    await onReconfigured;
   }
 }
 
 function reloadTab(tabX) {
   const browser = gBrowser.selectedBrowser;
 
   const reloadTabPromise = BrowserTestUtils.browserLoaded(browser).then(function() {
     info("Reloaded tab " + tabX.title);
--- a/devtools/client/framework/toolbox.js
+++ b/devtools/client/framework/toolbox.js
@@ -1334,26 +1334,31 @@ Toolbox.prototype = {
 
     return this.pickerButton;
   },
 
   /**
    * Apply the current cache setting from devtools.cache.disabled to this
    * toolbox's tab.
    */
-  _applyCacheSettings: function() {
+  _applyCacheSettings: async function() {
     const pref = "devtools.cache.disabled";
     const cacheDisabled = Services.prefs.getBoolPref(pref);
 
     if (this.target.activeTab) {
-      this.target.activeTab.reconfigure({
+      await this.target.activeTab.reconfigure({
         options: {
           "cacheDisabled": cacheDisabled
         }
       });
+
+      // This event is only emitted for tests in order to know when to reload
+      if (flags.testing) {
+        this.emit("cache-reconfigured");
+      }
     }
   },
 
   /**
    * Apply the current service workers testing setting from
    * devtools.serviceWorkers.testing.enabled to this toolbox's tab.
    */
   _applyServiceWorkersTestingSettings: function() {
--- a/devtools/server/tests/mochitest/test_webextension-addon-debugging-connect.html
+++ b/devtools/server/tests/mochitest/test_webextension-addon-debugging-connect.html
@@ -37,25 +37,24 @@ async function test_connect_addon(oopMod
   await client.connect();
 
   // List addons and assertions on the expected addon actor.
   const {addons} = await client.mainRoot.listAddons();
   const addonTargetActor = addons.filter(actor => actor.id === extension.id).pop();
   ok(addonTargetActor, "The expected webextension addon actor has been found");
 
   // Connect to the target addon actor and wait for the updated list of frames.
-  const waitFramesUpdated = waitForFramesUpdated({client});
   const addonTarget = await TargetFactory.forRemoteTab({
     form: addonTargetActor,
     client,
     chrome: true,
   });
   is(addonTarget.form.isOOP, oopMode,
      "Got the expected oop mode in the webextension actor form");
-  const frames = await waitFramesUpdated;
+  const frames = await waitForFramesUpdated(addonTarget);
   const backgroundPageFrame = frames.filter((frame) => {
     return frame.url && frame.url.endsWith("/_generated_background_page.html");
   }).pop();
   is(backgroundPageFrame.addonID, extension.id, "Got an extension frame");
   ok(addonTarget.activeTab, "The addon target has an activeTab");
 
   // When running in oop mode we can explicitly attach the thread without locking
   // the main process.