michael@0: /* vim: set ts=2 et sw=2 tw=80: */ michael@0: /* Any copyright is dedicated to the Public Domain. michael@0: http://creativecommons.org/publicdomain/zero/1.0/ */ michael@0: michael@0: function test() { michael@0: Cu.import("resource://gre/modules/Services.jsm"); michael@0: let temp = {} michael@0: Cu.import("resource:///modules/devtools/gDevTools.jsm", temp); michael@0: let DevTools = temp.DevTools; michael@0: Cu.import("resource://gre/modules/devtools/LayoutHelpers.jsm", temp); michael@0: let LayoutHelpers = temp.LayoutHelpers; michael@0: michael@0: Cu.import("resource://gre/modules/devtools/Loader.jsm", temp); michael@0: let devtools = temp.devtools; michael@0: michael@0: let Toolbox = devtools.Toolbox; michael@0: michael@0: let toolbox, iframe, target, tab; michael@0: michael@0: waitForExplicitFinish(); michael@0: michael@0: gBrowser.selectedTab = gBrowser.addTab(); michael@0: target = TargetFactory.forTab(gBrowser.selectedTab); michael@0: michael@0: window.addEventListener("message", onMessage); michael@0: michael@0: iframe = document.createElement("iframe"); michael@0: document.documentElement.appendChild(iframe); michael@0: michael@0: gBrowser.selectedBrowser.addEventListener("load", function onLoad(evt) { michael@0: gBrowser.selectedBrowser.removeEventListener(evt.type, onLoad, true); michael@0: let options = {customIframe: iframe}; michael@0: gDevTools.showToolbox(target, null, Toolbox.HostType.CUSTOM, options) michael@0: .then(testCustomHost, console.error) michael@0: .then(null, console.error); michael@0: }, true); michael@0: michael@0: content.location = "data:text/html,test custom host"; michael@0: michael@0: function onMessage(event) { michael@0: info("onMessage: " + event.data); michael@0: let json = JSON.parse(event.data); michael@0: if (json.name == "toolbox-close") { michael@0: ok("Got the `toolbox-close` message"); michael@0: cleanup(); michael@0: } michael@0: } michael@0: michael@0: function testCustomHost(toolbox) { michael@0: is(toolbox.doc.defaultView.top, window, "Toolbox is included in browser.xul"); michael@0: is(toolbox.doc, iframe.contentDocument, "Toolbox is in the custom iframe"); michael@0: executeSoon(() => gBrowser.removeCurrentTab()); michael@0: } michael@0: michael@0: function cleanup() { michael@0: window.removeEventListener("message", onMessage); michael@0: iframe.remove(); michael@0: finish(); michael@0: } michael@0: }