michael@0: /* This Source Code Form is subject to the terms of the Mozilla Public michael@0: * License, v. 2.0. If a copy of the MPL was not distributed with this michael@0: * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ michael@0: let tempScope = {}; michael@0: Cu.import("resource://gre/modules/devtools/Loader.jsm", tempScope); michael@0: Cu.import("resource://gre/modules/devtools/Console.jsm", tempScope); michael@0: const require = tempScope.devtools.require; michael@0: const console = tempScope.console; michael@0: tempScope = null; michael@0: const PATH = "browser/toolkit/devtools/server/tests/browser/"; michael@0: const MAIN_DOMAIN = "http://test1.example.org/" + PATH; michael@0: const ALT_DOMAIN = "http://sectest1.example.org/" + PATH; michael@0: const ALT_DOMAIN_SECURED = "https://sectest1.example.org:443/" + PATH; michael@0: michael@0: /** michael@0: * Open a new tab at a URL and call a callback on load michael@0: */ michael@0: function addTab(aURL, aCallback) { michael@0: waitForExplicitFinish(); michael@0: michael@0: gBrowser.selectedTab = gBrowser.addTab(); michael@0: content.location = aURL; michael@0: michael@0: let tab = gBrowser.selectedTab; michael@0: let browser = gBrowser.getBrowserForTab(tab); michael@0: michael@0: function onTabLoad(event) { michael@0: if (event.originalTarget.location.href != aURL) { michael@0: return; michael@0: } michael@0: browser.removeEventListener("load", onTabLoad, true); michael@0: aCallback(browser.contentDocument); michael@0: } michael@0: michael@0: browser.addEventListener("load", onTabLoad, true); michael@0: } michael@0: michael@0: /** michael@0: * Forces GC, CC and Shrinking GC to get rid of disconnected docshells and michael@0: * windows. michael@0: */ michael@0: function forceCollections() { michael@0: Cu.forceGC(); michael@0: Cu.forceCC(); michael@0: Cu.forceShrinkingGC(); michael@0: } michael@0: michael@0: registerCleanupFunction(function tearDown() { michael@0: while (gBrowser.tabs.length > 1) { michael@0: gBrowser.removeCurrentTab(); michael@0: } michael@0: });