--- a/browser/components/extensions/ext-utils.js
+++ b/browser/components/extensions/ext-utils.js
@@ -340,16 +340,22 @@ class PanelPopup extends BasePopup {
panel.setAttribute("role", "group");
document.getElementById("mainPopupSet").appendChild(panel);
super(extension, panel, popupURL, browserStyle);
this.contentReady.then(() => {
panel.openPopup(imageNode, "bottomcenter topright", 0, 0, false, false);
+
+ let event = new this.window.CustomEvent("WebExtPopupLoaded", {
+ bubbles: true,
+ detail: {extension},
+ });
+ this.browser.dispatchEvent(event);
});
}
get DESTROY_EVENT() {
return "popuphidden";
}
destroy() {
@@ -453,16 +459,22 @@ class ViewPopup extends BasePopup {
this.ignoreResizes = false;
if (this.dimensions) {
this.resizeBrowser(this.dimensions);
}
this.tempPanel.remove();
this.tempPanel = null;
+ let event = new this.window.CustomEvent("WebExtPopupLoaded", {
+ bubbles: true,
+ detail: {extension: this.extension},
+ });
+ this.browser.dispatchEvent(event);
+
return true;
}.bind(this));
}
destroy() {
return super.destroy().then(() => {
if (this.tempPanel) {
this.tempPanel.remove();
--- a/browser/components/extensions/test/browser/browser_ext_browserAction_popup_resize.js
+++ b/browser/components/extensions/test/browser/browser_ext_browserAction_popup_resize.js
@@ -3,75 +3,69 @@
"use strict";
function* openPanel(extension, win = window) {
clickBrowserAction(extension, win);
return yield awaitExtensionPanel(extension, win);
}
-function* awaitResize(browser) {
- // Debouncing code makes this a bit racy.
- // Try to skip the first, early resize, and catch the resize event we're
- // looking for, but don't wait longer than a few seconds.
-
- return Promise.race([
- BrowserTestUtils.waitForEvent(browser, "WebExtPopupResized", event => event.detail === "delayed"),
- new Promise(resolve => setTimeout(resolve, 5000)),
- ]);
-}
-
add_task(function* testBrowserActionPopupResize() {
let extension = ExtensionTestUtils.loadExtension({
manifest: {
"browser_action": {
"default_popup": "popup.html",
"browser_style": true,
},
},
files: {
- "popup.html": '<html><head><meta charset="utf-8"></head></html>',
+ "popup.html": '<!DOCTYPE html><html><head><meta charset="utf-8"></head></html>',
},
});
yield extension.startup();
clickBrowserAction(extension, window);
let browser = yield openPanel(extension);
- let panelWindow = browser.contentWindow;
- let panelBody = panelWindow.document.body;
- function checkSize(expected) {
- is(panelWindow.innerHeight, expected, `Panel window should be ${expected}px tall`);
- is(panelBody.clientHeight, panelBody.scrollHeight,
+ function* checkSize(expected) {
+ let dims = yield promiseContentDimensions(browser);
+
+ is(dims.window.innerHeight, expected, `Panel window should be ${expected}px tall`);
+ is(dims.body.clientHeight, dims.body.scrollHeight,
"Panel body should be tall enough to fit its contents");
// Tolerate if it is 1px too wide, as that may happen with the current resizing method.
- ok(Math.abs(panelWindow.innerWidth - expected) <= 1, `Panel window should be ${expected}px wide`);
- is(panelBody.clientWidth, panelBody.scrollWidth,
+ ok(Math.abs(dims.window.innerWidth - expected) <= 1, `Panel window should be ${expected}px wide`);
+ is(dims.body.clientWidth, dims.body.scrollWidth,
"Panel body should be wide enough to fit its contents");
}
function setSize(size) {
- panelBody.style.height = `${size}px`;
- panelBody.style.width = `${size}px`;
+ return Promise.all([
+ ContentTask.spawn(browser, size, function* (size) {
+ content.document.body.style.height = `${size}px`;
+ content.document.body.style.width = `${size}px`;
+ }),
+
+ BrowserTestUtils.waitForEvent(browser, "WebExtPopupResized"),
+ ]);
}
let sizes = [
200,
400,
300,
];
for (let size of sizes) {
- setSize(size);
- yield awaitResize(browser);
- checkSize(size);
+ yield setSize(size);
+ yield checkSize(size);
}
yield closeBrowserAction(extension);
yield extension.unload();
});
function* testPopupSize(standardsMode, browserWin = window, arrowSide = "top") {
let docType = standardsMode ? "<!DOCTYPE html>" : "";
@@ -116,144 +110,167 @@ function* testPopupSize(standardsMode, b
<span></span>
</body>
</html>`,
},
});
yield extension.startup();
+ /* eslint-disable mozilla/no-cpows-in-tests */
+
+ function alter(browser, task) {
+ return Promise.all([
+ ContentTask.spawn(browser, null, task),
+ awaitPopupResize(browser),
+ ]).then(() => {
+ return promiseContentDimensions(browser);
+ });
+ }
+
if (arrowSide == "top") {
// Test the standalone panel for a toolbar button.
let browser = yield openPanel(extension, browserWin);
- let win = browser.contentWindow;
- let body = win.document.body;
- let isStandards = win.document.compatMode != "BackCompat";
- is(isStandards, standardsMode, "Document has the expected compat mode");
+ let dims = yield promiseContentDimensions(browser);
+
+ is(dims.isStandards, standardsMode, "Document has the expected compat mode");
- let {innerWidth, innerHeight} = win;
+ let {innerWidth, innerHeight} = dims.window;
- body.classList.add("bigger");
- yield awaitResize(browser);
+ dims = yield alter(browser, () => {
+ content.document.body.classList.add("bigger");
+ });
+ let win = dims.window;
is(win.innerHeight, innerHeight, "Window height should not change");
ok(win.innerWidth > innerWidth, `Window width should increase (${win.innerWidth} > ${innerWidth})`);
- body.classList.remove("bigger");
- yield awaitResize(browser);
+ dims = yield alter(browser, () => {
+ content.document.body.classList.remove("bigger");
+ });
+ win = dims.window;
is(win.innerHeight, innerHeight, "Window height should not change");
// The getContentSize calculation is not always reliable to single-pixel
// precision.
ok(Math.abs(win.innerWidth - innerWidth) <= 1,
`Window width should return to approximately its original value (${win.innerWidth} ~= ${innerWidth})`);
yield closeBrowserAction(extension, browserWin);
}
// Test the PanelUI panel for a menu panel button.
let widget = getBrowserActionWidget(extension);
CustomizableUI.addWidgetToArea(widget.id, CustomizableUI.AREA_PANEL);
let browser = yield openPanel(extension, browserWin);
- let win = browser.contentWindow;
- let body = win.document.body;
let {panel} = browserWin.PanelUI;
let origPanelRect = panel.getBoundingClientRect();
// Check that the panel is still positioned as expected.
let checkPanelPosition = () => {
is(panel.getAttribute("side"), arrowSide, "Panel arrow is positioned as expected");
let panelRect = panel.getBoundingClientRect();
if (arrowSide == "top") {
ok(panelRect.top, origPanelRect.top, "Panel has not moved downwards");
ok(panelRect.bottom >= origPanelRect.bottom, `Panel has not shrunk from original size (${panelRect.bottom} >= ${origPanelRect.bottom})`);
- let screenBottom = browserWin.screen.availTop + win.screen.availHeight;
+ let screenBottom = browserWin.screen.availTop + browserWin.screen.availHeight;
let panelBottom = browserWin.mozInnerScreenY + panelRect.bottom;
ok(panelBottom <= screenBottom, `Bottom of popup should be on-screen. (${panelBottom} <= ${screenBottom})`);
} else {
ok(panelRect.bottom, origPanelRect.bottom, "Panel has not moved upwards");
ok(panelRect.top <= origPanelRect.top, `Panel has not shrunk from original size (${panelRect.top} <= ${origPanelRect.top})`);
let panelTop = browserWin.mozInnerScreenY + panelRect.top;
ok(panelTop >= browserWin.screen.availTop, `Top of popup should be on-screen. (${panelTop} >= ${browserWin.screen.availTop})`);
}
};
-
- let isStandards = win.document.compatMode != "BackCompat";
- is(isStandards, standardsMode, "Document has the expected compat mode");
-
// Wait long enough to make sure the initial resize debouncing timer has
// expired.
yield new Promise(resolve => setTimeout(resolve, 100));
+ let dims = yield promiseContentDimensions(browser);
+
+ is(dims.isStandards, standardsMode, "Document has the expected compat mode");
+
// If the browser's preferred height is smaller than the initial height of the
// panel, then it will still take up the full available vertical space. Even
// so, we need to check that we've gotten the preferred height calculation
// correct, so check that explicitly.
let getHeight = () => parseFloat(browser.style.height);
- let {innerWidth, innerHeight} = win;
+ let {innerWidth, innerHeight} = dims.window;
let height = getHeight();
info("Increase body children's width. " +
"Expect them to wrap, and the frame to grow vertically rather than widen.");
- body.className = "big";
- yield awaitResize(browser);
+
+ dims = yield alter(browser, () => {
+ content.document.body.className = "big";
+ });
+ let win = dims.window;
ok(getHeight() > height, `Browser height should increase (${getHeight()} > ${height})`);
is(win.innerWidth, innerWidth, "Window width should not change");
ok(win.innerHeight >= innerHeight, `Window height should increase (${win.innerHeight} >= ${innerHeight})`);
is(win.scrollMaxY, 0, "Document should not be vertically scrollable");
checkPanelPosition();
info("Increase body children's width and height. " +
"Expect them to wrap, and the frame to grow vertically rather than widen.");
- body.className = "bigger";
- yield awaitResize(browser);
+
+ dims = yield alter(browser, () => {
+ content.document.body.className = "bigger";
+ });
+ win = dims.window;
ok(getHeight() > height, `Browser height should increase (${getHeight()} > ${height})`);
is(win.innerWidth, innerWidth, "Window width should not change");
ok(win.innerHeight >= innerHeight, `Window height should increase (${win.innerHeight} >= ${innerHeight})`);
is(win.scrollMaxY, 0, "Document should not be vertically scrollable");
checkPanelPosition();
info("Increase body height beyond the height of the screen. " +
"Expect the panel to grow to accommodate, but not larger than the height of the screen.");
- body.className = "huge";
- yield awaitResize(browser);
+
+ dims = yield alter(browser, () => {
+ content.document.body.className = "huge";
+ });
+ win = dims.window;
ok(getHeight() > height, `Browser height should increase (${getHeight()} > ${height})`);
is(win.innerWidth, innerWidth, "Window width should not change");
ok(win.innerHeight > innerHeight, `Window height should increase (${win.innerHeight} > ${innerHeight})`);
ok(win.innerHeight < screen.height, `Window height be less than the screen height (${win.innerHeight} < ${screen.height})`);
ok(win.scrollMaxY > 0, `Document should be vertically scrollable (${win.scrollMaxY} > 0)`);
checkPanelPosition();
info("Restore original styling. Expect original dimensions.");
- body.className = "";
- yield awaitResize(browser);
+ dims = yield alter(browser, () => {
+ content.document.body.className = "";
+ });
+ win = dims.window;
is(getHeight(), height, "Browser height should return to its original value");
is(win.innerWidth, innerWidth, "Window width should not change");
is(win.innerHeight, innerHeight, "Window height should return to its original value");
is(win.scrollMaxY, 0, "Document should not be vertically scrollable");
checkPanelPosition();
--- a/browser/components/extensions/test/browser/browser_ext_pageAction_popup_resize.js
+++ b/browser/components/extensions/test/browser/browser_ext_pageAction_popup_resize.js
@@ -1,24 +1,12 @@
/* -*- Mode: indent-tabs-mode: nil; js-indent-level: 2 -*- */
/* vim: set sts=2 sw=2 et tw=80: */
"use strict";
-function* awaitResize(browser) {
- // Debouncing code makes this a bit racy.
- // Try to skip the first, early resize, and catch the resize event we're
- // looking for, but don't wait longer than a few seconds.
-
- return Promise.race([
- BrowserTestUtils.waitForEvent(browser, "WebExtPopupResized")
- .then(() => BrowserTestUtils.waitForEvent(browser, "WebExtPopupResized")),
- new Promise(resolve => setTimeout(resolve, 5000)),
- ]);
-}
-
add_task(function* testPageActionPopupResize() {
let browser;
let extension = ExtensionTestUtils.loadExtension({
manifest: {
"page_action": {
"default_popup": "popup.html",
"browser_style": true,
@@ -42,60 +30,65 @@ add_task(function* testPageActionPopupRe
yield extension.startup();
yield extension.awaitMessage("action-shown");
clickPageAction(extension, window);
browser = yield awaitExtensionPanel(extension);
- let panelWindow = browser.contentWindow;
- let panelDocument = panelWindow.document;
- let panelBody = panelDocument.body.firstChild;
- let body = panelDocument.body;
- let root = panelDocument.documentElement;
+ function* checkSize(expected) {
+ let dims = yield promiseContentDimensions(browser);
+ let {body, root} = dims;
- function checkSize(expected) {
- is(panelWindow.innerHeight, expected, `Panel window should be ${expected}px tall`);
+ is(dims.window.innerHeight, expected, `Panel window should be ${expected}px tall`);
is(body.clientHeight, body.scrollHeight,
"Panel body should be tall enough to fit its contents");
is(root.clientHeight, root.scrollHeight,
"Panel root should be tall enough to fit its contents");
// Tolerate if it is 1px too wide, as that may happen with the current resizing method.
- ok(Math.abs(panelWindow.innerWidth - expected) <= 1, `Panel window should be ${expected}px wide`);
+ ok(Math.abs(dims.window.innerWidth - expected) <= 1, `Panel window should be ${expected}px wide`);
is(body.clientWidth, body.scrollWidth,
"Panel body should be wide enough to fit its contents");
}
function setSize(size) {
- panelBody.style.height = `${size}px`;
- panelBody.style.width = `${size}px`;
+ return Promise.all([
+ ContentTask.spawn(browser, size, function* (size) {
+ let elem = content.document.body.firstChild;
+ elem.style.height = `${size}px`;
+ elem.style.width = `${size}px`;
+ }),
- return BrowserTestUtils.waitForEvent(browser, "WebExtPopupResized");
+ BrowserTestUtils.waitForEvent(browser, "WebExtPopupResized"),
+ ]);
}
let sizes = [
200,
400,
300,
];
for (let size of sizes) {
yield setSize(size);
- checkSize(size);
+ yield checkSize(size);
}
yield setSize(1400);
- is(panelWindow.innerWidth, 800, "Panel window width");
- ok(body.clientWidth <= 788, "Panel body width ${body.clientWidth} is less than 800");
+ let dims = yield promiseContentDimensions(browser);
+ let {body, root} = dims;
+
+ is(dims.window.innerWidth, 800, "Panel window width");
+ ok(body.clientWidth <= 800, `Panel body width ${body.clientWidth} is less than 800`);
is(body.scrollWidth, 1400, "Panel body scroll width");
- is(panelWindow.innerHeight, 600, "Panel window height");
+ is(dims.window.innerHeight, 600, "Panel window height");
ok([599, 600].includes(root.clientHeight), `Panel root height (${root.clientHeight}px) is ~600px`);
is(root.scrollHeight, 1400, "Panel root scroll height");
yield extension.unload();
});
add_task(function* testPageActionPopupReflow() {
let browser;
@@ -132,35 +125,37 @@ add_task(function* testPageActionPopupRe
yield extension.startup();
yield extension.awaitMessage("action-shown");
clickPageAction(extension, window);
browser = yield awaitExtensionPanel(extension);
- let win = browser.contentWindow;
- let body = win.document.body;
- let root = win.document.documentElement;
+ function setSize(size) {
+ return Promise.all([
+ ContentTask.spawn(browser, size, function* (size) {
+ content.document.body.style.fontSize = `${size}px`;
+ }),
- function setSize(size) {
- body.style.fontSize = `${size}px`;
-
- return awaitResize(browser);
+ awaitPopupResize(browser),
+ ]);
}
yield setSize(18);
- is(win.innerWidth, 800, "Panel window should be 800px wide");
- is(body.clientWidth, 800, "Panel body should be 800px wide");
- is(body.clientWidth, body.scrollWidth,
+ let dims = yield promiseContentDimensions(browser);
+
+ is(dims.window.innerWidth, 800, "Panel window should be 800px wide");
+ is(dims.body.clientWidth, 800, "Panel body should be 800px wide");
+ is(dims.body.clientWidth, dims.body.scrollWidth,
"Panel body should be wide enough to fit its contents");
- ok(win.innerHeight > 36,
- `Panel window height (${win.innerHeight}px) should be taller than two lines of text.`);
+ ok(dims.window.innerHeight > 36,
+ `Panel window height (${dims.window.innerHeight}px) should be taller than two lines of text.`);
- is(body.clientHeight, body.scrollHeight,
+ is(dims.body.clientHeight, dims.body.scrollHeight,
"Panel body should be tall enough to fit its contents");
- is(root.clientHeight, root.scrollHeight,
+ is(dims.root.clientHeight, dims.root.scrollHeight,
"Panel root should be tall enough to fit its contents");
yield extension.unload();
});
--- a/browser/components/extensions/test/browser/browser_ext_popup_background.js
+++ b/browser/components/extensions/test/browser/browser_ext_popup_background.js
@@ -1,21 +1,16 @@
/* -*- Mode: indent-tabs-mode: nil; js-indent-level: 2 -*- */
/* vim: set sts=2 sw=2 et tw=80: */
"use strict";
-function* awaitResize(browser) {
- // Debouncing code makes this a bit racy.
- // Try to skip the first, early resize, and catch the resize event we're
- // looking for, but don't wait longer than a few seconds.
-
- return Promise.race([
- BrowserTestUtils.waitForEvent(browser, "WebExtPopupResized")
- .then(() => BrowserTestUtils.waitForEvent(browser, "WebExtPopupResized")),
- new Promise(resolve => setTimeout(resolve, 5000)),
+function alter(browser, task) {
+ return Promise.all([
+ ContentTask.spawn(browser, null, task),
+ awaitPopupResize(browser),
]);
}
add_task(function* testPopupBackground() {
let extension = ExtensionTestUtils.loadExtension({
background() {
browser.tabs.query({active: true, currentWindow: true}, tabs => {
browser.pageAction.show(tabs[0].id);
@@ -74,36 +69,44 @@ add_task(function* testPopupBackground()
let backgroundIndex = image.lastIndexOf(`fill="${background}"`);
ok(borderIndex >= 0, `Have border fill (index=${borderIndex})`);
ok(backgroundIndex >= 0, `Have background fill (index=${backgroundIndex})`);
is(getComputedStyle(arrowContent).backgroundColor, background, "Arrow content should have correct background");
isnot(borderIndex, backgroundIndex, "Border and background fills are separate elements");
};
- let win = browser.contentWindow;
- let body = win.document.body;
+ function getBackground(browser) {
+ return ContentTask.spawn(browser, null, function* () {
+ return content.getComputedStyle(content.document.body)
+ .backgroundColor;
+ });
+ }
yield new Promise(resolve => setTimeout(resolve, 100));
info("Test that initial background color is applied");
- checkArrow(win.getComputedStyle(body).backgroundColor);
+ checkArrow(yield getBackground(browser));
info("Test that dynamically-changed background color is applied");
- body.style.backgroundColor = "black";
- yield awaitResize(browser);
+ /* eslint-disable mozilla/no-cpows-in-tests */
+ yield alter(browser, () => {
+ content.document.body.style.backgroundColor = "black";
+ });
- checkArrow(win.getComputedStyle(body).backgroundColor);
+ checkArrow(yield getBackground(browser));
info("Test that non-opaque background color results in default styling");
- body.style.backgroundColor = "rgba(1, 2, 3, .9)";
- yield awaitResize(browser);
+ yield alter(browser, () => {
+ content.document.body.style.backgroundColor = "rgba(1, 2, 3, .9)";
+ });
+ /* eslint-enable mozilla/no-cpows-in-tests */
checkArrow(null);
}
{
info("Test stand-alone browserAction popup");
clickBrowserAction(extension);
--- a/browser/components/extensions/test/browser/browser_ext_popup_corners.js
+++ b/browser/components/extensions/test/browser/browser_ext_popup_corners.js
@@ -37,27 +37,34 @@ add_task(function* testPopupBorderRadius
let panel = getPanelForNode(browser);
let arrowContent = document.getAnonymousElementByAttribute(panel, "class", "panel-arrowcontent");
let panelStyle = getComputedStyle(arrowContent);
let viewNode = browser.parentNode === panel ? browser : browser.parentNode;
let viewStyle = getComputedStyle(viewNode);
- let win = browser.contentWindow;
- let bodyStyle = win.getComputedStyle(win.document.body);
+ let props = ["borderTopLeftRadius", "borderTopRightRadius",
+ "borderBottomRightRadius", "borderBottomLeftRadius"];
- for (let prop of ["borderTopLeftRadius", "borderTopRightRadius",
- "borderBottomRightRadius", "borderBottomLeftRadius"]) {
+ /* eslint-disable mozilla/no-cpows-in-tests */
+ let bodyStyle = yield ContentTask.spawn(browser, props, function* (props) {
+ let bodyStyle = content.getComputedStyle(content.document.body);
+
+ return new Map(props.map(prop => [prop, bodyStyle[prop]]));
+ });
+ /* eslint-enable mozilla/no-cpows-in-tests */
+
+ for (let prop of props) {
if (standAlone) {
is(viewStyle[prop], panelStyle[prop], `Panel and view ${prop} should be the same`);
- is(bodyStyle[prop], panelStyle[prop], `Panel and body ${prop} should be the same`);
+ is(bodyStyle.get(prop), panelStyle[prop], `Panel and body ${prop} should be the same`);
} else {
is(viewStyle[prop], "0px", `View node ${prop} should be 0px`);
- is(bodyStyle[prop], "0px", `Body node ${prop} should be 0px`);
+ is(bodyStyle.get(prop), "0px", `Body node ${prop} should be 0px`);
}
}
}
{
info("Test stand-alone browserAction popup");
clickBrowserAction(extension);
--- a/browser/components/extensions/test/browser/head.js
+++ b/browser/components/extensions/test/browser/head.js
@@ -6,17 +6,18 @@
* getBrowserActionWidget
* clickBrowserAction clickPageAction
* getBrowserActionPopup getPageActionPopup
* closeBrowserAction closePageAction
* promisePopupShown promisePopupHidden
* openContextMenu closeContextMenu
* openExtensionContextMenu closeExtensionContextMenu
* imageBuffer getListStyleImage getPanelForNode
- * awaitExtensionPanel
+ * awaitExtensionPanel awaitPopupResize
+ * promiseContentDimensions
*/
var {AppConstants} = Cu.import("resource://gre/modules/AppConstants.jsm");
var {CustomizableUI} = Cu.import("resource:///modules/CustomizableUI.jsm");
// Bug 1239884: Our tests occasionally hit a long GC pause at unpredictable
// times in debug builds, which results in intermittent timeouts. Until we have
// a better solution, we force a GC after certain strategic tests, which tend to
@@ -79,36 +80,62 @@ function promisePopupHidden(popup) {
let onPopupHidden = event => {
popup.removeEventListener("popuphidden", onPopupHidden);
resolve();
};
popup.addEventListener("popuphidden", onPopupHidden);
});
}
+function promiseContentDimensions(browser) {
+ return ContentTask.spawn(browser, null, function* () {
+ function copyProps(obj, props) {
+ let res = {};
+ for (let prop of props) {
+ res[prop] = obj[prop];
+ }
+ return res;
+ }
+
+ return {
+ window: copyProps(content,
+ ["innerWidth", "innerHeight", "outerWidth", "outerHeight",
+ "scrollX", "scrollY", "scrollMaxX", "scrollMaxY"]),
+ body: copyProps(content.document.body,
+ ["clientWidth", "clientHeight", "scrollWidth", "scrollHeight"]),
+ root: copyProps(content.document.documentElement,
+ ["clientWidth", "clientHeight", "scrollWidth", "scrollHeight"]),
+
+ isStandards: content.document.compatMode !== "BackCompat",
+ };
+ });
+}
+
+function* awaitPopupResize(browser) {
+ // Debouncing code makes this a bit racy.
+ // Try to skip the first, early resize, and catch the resize event we're
+ // looking for, but don't wait longer than a few seconds.
+
+ return Promise.race([
+ BrowserTestUtils.waitForEvent(browser, "WebExtPopupResized", event => event.detail === "delayed"),
+ new Promise(resolve => setTimeout(resolve, 5000)),
+ ]);
+}
+
function getPanelForNode(node) {
while (node.localName != "panel") {
node = node.parentNode;
}
return node;
}
-var awaitExtensionPanel = Task.async(function* (extension, win = window, filename = "popup.html") {
- let {target} = yield BrowserTestUtils.waitForEvent(win.document, "load", true, (event) => {
- return event.target.location && event.target.location.href.endsWith(filename);
- });
-
- let browser = target.defaultView
- .QueryInterface(Ci.nsIInterfaceRequestor).getInterface(Ci.nsIDocShell)
- .chromeEventHandler;
-
- if (browser.matches(".webextension-preload-browser")) {
- let event = yield BrowserTestUtils.waitForEvent(browser, "SwapDocShells");
- browser = event.detail;
- }
+var awaitExtensionPanel = Task.async(function* (extension, win = window) {
+ let {originalTarget: browser} = yield BrowserTestUtils.waitForEvent(
+ win.document, "WebExtPopupLoaded", true,
+ event => event.detail.extension.id === extension.id);
yield promisePopupShown(getPanelForNode(browser));
return browser;
});
function getBrowserActionWidget(extension) {
return CustomizableUI.getWidget(makeWidgetId(extension.id) + "-browser-action");