mirror of
https://github.com/mozilla/gecko-dev.git
synced 2024-11-29 15:52:07 +00:00
Bug 1307015 - Remove CPOWs from browser_bug623893.js r=felipe
It took me a little bit to understand what the test was doing. It was actually using the default tab to navigate to three pages. Then, it duplicated it immediatedly closed that tab. Finally, it duplicated the original tab, then duplicated the duplicate before closing both of those tabs. MozReview-Commit-ID: 85eY3FhZniA
This commit is contained in:
parent
732bc992ae
commit
f2b1e8dbda
@ -1,45 +1,37 @@
|
||||
function test() {
|
||||
waitForExplicitFinish();
|
||||
add_task(function* test() {
|
||||
yield BrowserTestUtils.withNewTab("data:text/plain;charset=utf-8,1", function* (browser) {
|
||||
BrowserTestUtils.loadURI(browser, "data:text/plain;charset=utf-8,2");
|
||||
yield BrowserTestUtils.browserLoaded(browser);
|
||||
|
||||
loadAndWait("data:text/plain,1", function() {
|
||||
loadAndWait("data:text/plain,2", function() {
|
||||
loadAndWait("data:text/plain,3", runTests);
|
||||
});
|
||||
BrowserTestUtils.loadURI(browser, "data:text/plain;charset=utf-8,3");
|
||||
yield BrowserTestUtils.browserLoaded(browser);
|
||||
|
||||
yield duplicate(0, "maintained the original index");
|
||||
yield BrowserTestUtils.removeTab(gBrowser.selectedTab);
|
||||
|
||||
yield duplicate(-1, "went back");
|
||||
yield duplicate(1, "went forward");
|
||||
yield BrowserTestUtils.removeTab(gBrowser.selectedTab);
|
||||
yield BrowserTestUtils.removeTab(gBrowser.selectedTab);
|
||||
});
|
||||
});
|
||||
|
||||
function promiseGetIndex(browser) {
|
||||
return ContentTask.spawn(browser, null, function() {
|
||||
let shistory = docShell.QueryInterface(Ci.nsIInterfaceRequestor)
|
||||
.getInterface(Ci.nsISHistory);
|
||||
return shistory.index;
|
||||
});
|
||||
}
|
||||
|
||||
function runTests() {
|
||||
duplicate(0, "maintained the original index", function() {
|
||||
gBrowser.removeCurrentTab();
|
||||
|
||||
duplicate(-1, "went back", function() {
|
||||
duplicate(1, "went forward", function() {
|
||||
gBrowser.removeCurrentTab();
|
||||
gBrowser.removeCurrentTab();
|
||||
gBrowser.addTab();
|
||||
gBrowser.removeCurrentTab();
|
||||
finish();
|
||||
});
|
||||
});
|
||||
});
|
||||
}
|
||||
|
||||
function duplicate(delta, msg, cb) {
|
||||
var start = gBrowser.sessionHistory.index;
|
||||
let duplicate = Task.async(function* (delta, msg, cb) {
|
||||
var startIndex = yield promiseGetIndex(gBrowser.selectedBrowser);
|
||||
|
||||
duplicateTabIn(gBrowser.selectedTab, "tab", delta);
|
||||
|
||||
let tab = gBrowser.selectedTab;
|
||||
yield BrowserTestUtils.waitForEvent(tab, "SSTabRestored");
|
||||
|
||||
tab.addEventListener("SSTabRestored", function() {
|
||||
is(gBrowser.sessionHistory.index, start + delta, msg);
|
||||
executeSoon(cb);
|
||||
}, {once: true});
|
||||
}
|
||||
|
||||
function loadAndWait(url, cb) {
|
||||
gBrowser.selectedBrowser.addEventListener("load", function() {
|
||||
executeSoon(cb);
|
||||
}, {capture: true, once: true});
|
||||
|
||||
gBrowser.loadURI(url);
|
||||
}
|
||||
let endIndex = yield promiseGetIndex(gBrowser.selectedBrowser);
|
||||
is(endIndex, startIndex + delta, msg);
|
||||
});
|
||||
|
Loading…
Reference in New Issue
Block a user