1.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000 1.2 +++ b/toolkit/devtools/server/tests/browser/head.js Wed Dec 31 06:09:35 2014 +0100 1.3 @@ -0,0 +1,52 @@ 1.4 +/* This Source Code Form is subject to the terms of the Mozilla Public 1.5 + * License, v. 2.0. If a copy of the MPL was not distributed with this 1.6 + * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ 1.7 +let tempScope = {}; 1.8 +Cu.import("resource://gre/modules/devtools/Loader.jsm", tempScope); 1.9 +Cu.import("resource://gre/modules/devtools/Console.jsm", tempScope); 1.10 +const require = tempScope.devtools.require; 1.11 +const console = tempScope.console; 1.12 +tempScope = null; 1.13 +const PATH = "browser/toolkit/devtools/server/tests/browser/"; 1.14 +const MAIN_DOMAIN = "http://test1.example.org/" + PATH; 1.15 +const ALT_DOMAIN = "http://sectest1.example.org/" + PATH; 1.16 +const ALT_DOMAIN_SECURED = "https://sectest1.example.org:443/" + PATH; 1.17 + 1.18 +/** 1.19 + * Open a new tab at a URL and call a callback on load 1.20 + */ 1.21 +function addTab(aURL, aCallback) { 1.22 + waitForExplicitFinish(); 1.23 + 1.24 + gBrowser.selectedTab = gBrowser.addTab(); 1.25 + content.location = aURL; 1.26 + 1.27 + let tab = gBrowser.selectedTab; 1.28 + let browser = gBrowser.getBrowserForTab(tab); 1.29 + 1.30 + function onTabLoad(event) { 1.31 + if (event.originalTarget.location.href != aURL) { 1.32 + return; 1.33 + } 1.34 + browser.removeEventListener("load", onTabLoad, true); 1.35 + aCallback(browser.contentDocument); 1.36 + } 1.37 + 1.38 + browser.addEventListener("load", onTabLoad, true); 1.39 +} 1.40 + 1.41 +/** 1.42 + * Forces GC, CC and Shrinking GC to get rid of disconnected docshells and 1.43 + * windows. 1.44 + */ 1.45 +function forceCollections() { 1.46 + Cu.forceGC(); 1.47 + Cu.forceCC(); 1.48 + Cu.forceShrinkingGC(); 1.49 +} 1.50 + 1.51 +registerCleanupFunction(function tearDown() { 1.52 + while (gBrowser.tabs.length > 1) { 1.53 + gBrowser.removeCurrentTab(); 1.54 + } 1.55 +});