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