Files
firefox/devtools/client/framework/test/browser_toolbox_custom_host.js
T
Julian Descottes 85f2527a0c Bug 1583444 - Stop using win.top in DevTools tests r=nchevobbe
Depends on D46959

For those tests, using win.top was the same as using win, and did not have any impact on the asserts performed in the test.
In particular, the AutocompletePopup constructor calls for a "toolboxDoc", so passing the host document is actually more correct.

Differential Revision: https://phabricator.services.mozilla.com/D46960
2019-09-30 09:53:26 +00:00

49 lines
1.3 KiB
JavaScript

/* Any copyright is dedicated to the Public Domain.
* http://creativecommons.org/publicdomain/zero/1.0/ */
const TEST_URL = "data:text/html,test custom host";
add_task(async function() {
const { Toolbox } = require("devtools/client/framework/toolbox");
const messageReceived = new Promise(resolve => {
function onMessage(event) {
if (!event.data) {
return;
}
const msg = event.data;
info(`onMessage: ${JSON.stringify(msg)}`);
switch (msg.name) {
case "toolbox-close":
ok(true, "Got the `toolbox-close` message");
window.removeEventListener("message", onMessage);
resolve();
break;
}
}
window.addEventListener("message", onMessage);
});
let iframe = document.createXULElement("iframe");
document.documentElement.appendChild(iframe);
const tab = await addTab(TEST_URL);
let target = await TargetFactory.forTab(tab);
const options = { customIframe: iframe };
let toolbox = await gDevTools.showToolbox(
target,
null,
Toolbox.HostType.CUSTOM,
options
);
is(toolbox.topWindow, window, "Toolbox is included in browser.xhtml");
is(toolbox.doc, iframe.contentDocument, "Toolbox is in the custom iframe");
iframe.remove();
await toolbox.destroy();
await messageReceived;
iframe = toolbox = target = null;
});