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