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