mirror of
https://github.com/HeyPuter/firefox.git
synced 2026-11-25 02:40:22 -10:00
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
49 lines
1.3 KiB
JavaScript
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;
|
|
});
|