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

--HG--
extra : moz-landing-system : lando
This commit is contained in:
Alexandre Poirot 2018-10-11 15:46:32 +00:00
parent 289ee36566
commit 99a923c818
4 changed files with 23 additions and 20 deletions

View File

@ -91,7 +91,17 @@ add_task(async function testWebExtensionsToolboxSwitchToPopup() {
/* 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) => {
@ -111,18 +121,6 @@ add_task(async function testWebExtensionsToolboxSwitchToPopup() {
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()");

View File

@ -85,11 +85,12 @@ async function setDisableCacheCheckboxChecked(tabX, state) {
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;
}
}

View File

@ -1339,16 +1339,21 @@ Toolbox.prototype = {
* 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");
}
}
},

View File

@ -42,7 +42,6 @@ async function test_connect_addon(oopMode) {
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,
@ -50,7 +49,7 @@ async function test_connect_addon(oopMode) {
});
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();