|
1 /* vim: set ts=2 et sw=2 tw=80: */ |
|
2 /* Any copyright is dedicated to the Public Domain. |
|
3 http://creativecommons.org/publicdomain/zero/1.0/ */ |
|
4 |
|
5 function test() { |
|
6 Cu.import("resource://gre/modules/Services.jsm"); |
|
7 let temp = {} |
|
8 Cu.import("resource:///modules/devtools/gDevTools.jsm", temp); |
|
9 let DevTools = temp.DevTools; |
|
10 Cu.import("resource://gre/modules/devtools/LayoutHelpers.jsm", temp); |
|
11 let LayoutHelpers = temp.LayoutHelpers; |
|
12 |
|
13 Cu.import("resource://gre/modules/devtools/Loader.jsm", temp); |
|
14 let devtools = temp.devtools; |
|
15 |
|
16 let Toolbox = devtools.Toolbox; |
|
17 |
|
18 let toolbox, iframe, target, tab; |
|
19 |
|
20 waitForExplicitFinish(); |
|
21 |
|
22 gBrowser.selectedTab = gBrowser.addTab(); |
|
23 target = TargetFactory.forTab(gBrowser.selectedTab); |
|
24 |
|
25 window.addEventListener("message", onMessage); |
|
26 |
|
27 iframe = document.createElement("iframe"); |
|
28 document.documentElement.appendChild(iframe); |
|
29 |
|
30 gBrowser.selectedBrowser.addEventListener("load", function onLoad(evt) { |
|
31 gBrowser.selectedBrowser.removeEventListener(evt.type, onLoad, true); |
|
32 let options = {customIframe: iframe}; |
|
33 gDevTools.showToolbox(target, null, Toolbox.HostType.CUSTOM, options) |
|
34 .then(testCustomHost, console.error) |
|
35 .then(null, console.error); |
|
36 }, true); |
|
37 |
|
38 content.location = "data:text/html,test custom host"; |
|
39 |
|
40 function onMessage(event) { |
|
41 info("onMessage: " + event.data); |
|
42 let json = JSON.parse(event.data); |
|
43 if (json.name == "toolbox-close") { |
|
44 ok("Got the `toolbox-close` message"); |
|
45 cleanup(); |
|
46 } |
|
47 } |
|
48 |
|
49 function testCustomHost(toolbox) { |
|
50 is(toolbox.doc.defaultView.top, window, "Toolbox is included in browser.xul"); |
|
51 is(toolbox.doc, iframe.contentDocument, "Toolbox is in the custom iframe"); |
|
52 executeSoon(() => gBrowser.removeCurrentTab()); |
|
53 } |
|
54 |
|
55 function cleanup() { |
|
56 window.removeEventListener("message", onMessage); |
|
57 iframe.remove(); |
|
58 finish(); |
|
59 } |
|
60 } |