use gBrowser instead of getBrowser() in browser chrome tests

This commit is contained in:
Dão Gottwald 2009-09-14 01:18:19 +02:00
parent 2d028b8e45
commit dfaaa87fe2
7 changed files with 17 additions and 21 deletions

View File

@ -42,8 +42,6 @@
const Cc = Components.classes;
const Ci = Components.interfaces;
var gPrefs = Cc["@mozilla.org/preferences-service;1"].
getService(Ci.nsIPrefBranch);
const DISABLE_HISTORY_PREF = "browser.history_expire_days";
var gLibrary = null;
@ -65,7 +63,7 @@ var gTabsListener = {
}
var tab = aEvent.target;
is(tab.ownerDocument.defaultView.getBrowser(), gBrowser,
is(tab.ownerDocument.defaultView, window,
"Tab has been opened in current browser window");
},
@ -264,7 +262,7 @@ function test() {
gBrowser.addTabsProgressListener(gTabsListener);
// Temporary disable history, so we won't record pages navigation.
gPrefs.setIntPref(DISABLE_HISTORY_PREF, 0);
gPrefService.setIntPref(DISABLE_HISTORY_PREF, 0);
// Window watcher for Library window.
var ww = Cc["@mozilla.org/embedcomp/window-watcher;1"].
@ -320,7 +318,7 @@ function runNextTest() {
gBrowser.removeTabsProgressListener(gTabsListener);
// Restore history.
gPrefs.setIntPref(DISABLE_HISTORY_PREF, 180);
gPrefService.clearUserPref(DISABLE_HISTORY_PREF);
finish();
}

View File

@ -45,9 +45,8 @@ function test() {
waitForExplicitFinish();
let tabAbout = gBrowser.addTab();
gBrowser.selectedTab = tabAbout;
let aboutBrowser = gBrowser.getBrowserForTab(tabAbout);
gBrowser.selectedTab = gBrowser.addTab();
let aboutBrowser = gBrowser.selectedBrowser;
aboutBrowser.addEventListener("load", function () {
aboutBrowser.removeEventListener("load", arguments.callee, true);
@ -62,7 +61,7 @@ function test() {
win.addEventListener("load", function() {
win.removeEventListener("load", arguments.callee, false);
let browser = win.document.defaultView.getBrowser();
let browser = win.getBrowser();
browser.addEventListener("load", function() {
browser.removeEventListener("load", arguments.callee, true);
@ -134,7 +133,7 @@ function test() {
win.addEventListener("load", function() {
win.removeEventListener("load", arguments.callee, false);
let browser = win.document.defaultView.getBrowser();
let browser = win.getBrowser();
browser.addEventListener("load", function() {
browser.removeEventListener("load", arguments.callee, true);
@ -169,16 +168,16 @@ function test() {
win.addEventListener("load", function() {
win.removeEventListener("load", arguments.callee, false);
let browser = win.document.defaultView.getBrowser();
let browser = win.getBrowser();
browser.addEventListener("load", function() {
browser.removeEventListener("load", arguments.callee, true);
is(browser.currentURI.spec, "view-source:about:",
is(win.content.location.href, "view-source:about:",
"The correct view source window should be restored");
// cleanup
win.close();
gBrowser.removeTab(gBrowser.selectedTab);
gBrowser.removeCurrentTab();
finish();
}, true);
}, false);

View File

@ -62,7 +62,7 @@ function test() {
"Invalid tab for setTabState throws");
ok(test(function() ss.duplicateTab({}, {})),
"Invalid tab for duplicateTab throws");
ok(test(function() ss.duplicateTab({}, getBrowser().selectedTab)),
ok(test(function() ss.duplicateTab({}, gBrowser.selectedTab)),
"Invalid window for duplicateTab throws");
ok(test(function() ss.getClosedTabData({})),
"Invalid window for getClosedTabData throws");
@ -80,6 +80,6 @@ function test() {
"Invalid window for deleteWindowValue throws");
ok(test(function() ss.deleteWindowValue(window, Date.now().toString())),
"Nonexistent value for deleteWindowValue throws");
ok(test(function() ss.deleteTabValue(getBrowser().selectedTab, Date.now().toString())),
ok(test(function() ss.deleteTabValue(gBrowser.selectedTab, Date.now().toString())),
"Nonexistent value for deleteTabValue throws");
}

View File

@ -89,7 +89,7 @@ function test() {
}
// test setup
let tabbrowser = getBrowser();
let tabbrowser = gBrowser;
waitForExplicitFinish();
// make sure we don't save form data at all (except for tab duplication)

View File

@ -10,7 +10,7 @@ function test() {
}
// test setup
let tabbrowser = getBrowser();
let tabbrowser = gBrowser;
waitForExplicitFinish();
// component

View File

@ -7,7 +7,7 @@ function test() {
}
catch (ex) { }
ok(ss, "SessionStore service is available");
let tabbrowser = getBrowser();
let tabbrowser = gBrowser;
waitForExplicitFinish();
/////////////////

View File

@ -40,14 +40,13 @@ function test() {
// test setup
let ss = Cc["@mozilla.org/browser/sessionstore;1"].getService(Ci.nsISessionStore);
let os = Cc["@mozilla.org/observer-service;1"].getService(Ci.nsIObserverService);
let tabbrowser = getBrowser();
waitForExplicitFinish();
let uniqueName = "bug 448741";
let uniqueValue = "as good as unique: " + Date.now();
// set a unique value on a new, blank tab
var tab = tabbrowser.addTab();
var tab = gBrowser.addTab();
ss.setTabValue(tab, uniqueName, uniqueValue);
let valueWasCleaned = false;
@ -84,7 +83,7 @@ function test() {
ok(aSubject.data.indexOf(uniqueValue) == -1, "data no longer contains our value?");
// clean up
tabbrowser.removeTab(tab);
gBrowser.removeTab(tab);
os.removeObserver(this, aTopic, false);
gPrefService.clearUserPref("browser.sessionstore.interval");
finish();