toolkit/devtools/server/tests/browser/head.js

Wed, 31 Dec 2014 06:09:35 +0100

author
Michael Schloh von Bennewitz <michael@schloh.com>
date
Wed, 31 Dec 2014 06:09:35 +0100
changeset 0
6474c204b198
permissions
-rw-r--r--

Cloned upstream origin tor-browser at tor-browser-31.3.0esr-4.5-1-build1
revision ID fc1c9ff7c1b2defdbc039f12214767608f46423f for hacking purpose.

michael@0 1 /* This Source Code Form is subject to the terms of the Mozilla Public
michael@0 2 * License, v. 2.0. If a copy of the MPL was not distributed with this
michael@0 3 * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
michael@0 4 let tempScope = {};
michael@0 5 Cu.import("resource://gre/modules/devtools/Loader.jsm", tempScope);
michael@0 6 Cu.import("resource://gre/modules/devtools/Console.jsm", tempScope);
michael@0 7 const require = tempScope.devtools.require;
michael@0 8 const console = tempScope.console;
michael@0 9 tempScope = null;
michael@0 10 const PATH = "browser/toolkit/devtools/server/tests/browser/";
michael@0 11 const MAIN_DOMAIN = "http://test1.example.org/" + PATH;
michael@0 12 const ALT_DOMAIN = "http://sectest1.example.org/" + PATH;
michael@0 13 const ALT_DOMAIN_SECURED = "https://sectest1.example.org:443/" + PATH;
michael@0 14
michael@0 15 /**
michael@0 16 * Open a new tab at a URL and call a callback on load
michael@0 17 */
michael@0 18 function addTab(aURL, aCallback) {
michael@0 19 waitForExplicitFinish();
michael@0 20
michael@0 21 gBrowser.selectedTab = gBrowser.addTab();
michael@0 22 content.location = aURL;
michael@0 23
michael@0 24 let tab = gBrowser.selectedTab;
michael@0 25 let browser = gBrowser.getBrowserForTab(tab);
michael@0 26
michael@0 27 function onTabLoad(event) {
michael@0 28 if (event.originalTarget.location.href != aURL) {
michael@0 29 return;
michael@0 30 }
michael@0 31 browser.removeEventListener("load", onTabLoad, true);
michael@0 32 aCallback(browser.contentDocument);
michael@0 33 }
michael@0 34
michael@0 35 browser.addEventListener("load", onTabLoad, true);
michael@0 36 }
michael@0 37
michael@0 38 /**
michael@0 39 * Forces GC, CC and Shrinking GC to get rid of disconnected docshells and
michael@0 40 * windows.
michael@0 41 */
michael@0 42 function forceCollections() {
michael@0 43 Cu.forceGC();
michael@0 44 Cu.forceCC();
michael@0 45 Cu.forceShrinkingGC();
michael@0 46 }
michael@0 47
michael@0 48 registerCleanupFunction(function tearDown() {
michael@0 49 while (gBrowser.tabs.length > 1) {
michael@0 50 gBrowser.removeCurrentTab();
michael@0 51 }
michael@0 52 });

mercurial