Bug 1209689 - browser_crashedTabs.js fixes. r=felipe

--HG--
extra : commitid : HUgricZ9y07
extra : rebase_source : 506dfb198528c063782addbaf38bef20a93daf7e
This commit is contained in:
Mike Conley 2015-11-02 12:39:43 -05:00
Родитель 07388b22cc
Коммит 6515482435
1 изменённых файлов: 31 добавлений и 15 удалений

Просмотреть файл

@ -253,13 +253,16 @@ add_task(function test_revive_tab_from_session_store() {
// Crash the tab
yield BrowserTestUtils.crashBrowser(browser);
is(newTab2.getAttribute("crashed"), "true", "Second tab should be crashed too.");
// Background tabs should not be crashed, but should be in the "to be restored"
// state.
ok(!newTab2.hasAttribute("crashed"), "Second tab should not be crashed.");
ok(newTab2.hasAttribute("pending"), "Second tab should be pending.");
// Use SessionStore to revive the tab
// Use SessionStore to revive the first tab
clickButton(browser, "restoreTab");
yield promiseTabRestored(newTab);
ok(!newTab.hasAttribute("crashed"), "Tab shouldn't be marked as crashed anymore.");
is(newTab2.getAttribute("crashed"), "true", "Second tab should still be crashed though.");
ok(newTab2.hasAttribute("pending"), "Second tab should still be pending.");
// We can't just check browser.currentURI.spec, because from
// the outside, a crashed tab has the same URI as the page
@ -275,8 +278,8 @@ add_task(function test_revive_tab_from_session_store() {
});
/**
* Checks that we can revive a crashed tab back to the page that
* it was on when it crashed.
* Checks that we can revive multiple crashed tabs back to the pages
* that they were on when they crashed.
*/
add_task(function test_revive_all_tabs_from_session_store() {
let newTab = gBrowser.addTab();
@ -288,7 +291,12 @@ add_task(function test_revive_all_tabs_from_session_store() {
browser.loadURI(PAGE_1);
yield promiseBrowserLoaded(browser);
let newTab2 = gBrowser.addTab(PAGE_1);
// In order to see a second about:tabcrashed page, we'll need
// a second window, since only selected tabs will show
// about:tabcrashed.
let win2 = yield BrowserTestUtils.openNewBrowserWindow();
let newTab2 = win2.gBrowser.addTab(PAGE_1);
win2.gBrowser.selectedTab = newTab2;
let browser2 = newTab2.linkedBrowser;
ok(browser2.isRemoteBrowser, "Should be a remote browser");
yield promiseBrowserLoaded(browser2);
@ -304,7 +312,9 @@ add_task(function test_revive_all_tabs_from_session_store() {
// Crash the tab
yield BrowserTestUtils.crashBrowser(browser);
is(newTab2.getAttribute("crashed"), "true", "Second tab should be crashed too.");
// Both tabs should now be crashed.
is(newTab.getAttribute("crashed"), "true", "First tab should be crashed");
is(newTab2.getAttribute("crashed"), "true", "Second window tab should be crashed");
// Use SessionStore to revive all the tabs
clickButton(browser, "restoreAll");
@ -312,10 +322,6 @@ add_task(function test_revive_all_tabs_from_session_store() {
ok(!newTab.hasAttribute("crashed"), "Tab shouldn't be marked as crashed anymore.");
ok(!newTab.hasAttribute("pending"), "Tab shouldn't be pending.");
ok(!newTab2.hasAttribute("crashed"), "Second tab shouldn't be marked as crashed anymore.");
ok(newTab2.hasAttribute("pending"), "Second tab should be pending.");
gBrowser.selectedTab = newTab2;
yield promiseTabRestored(newTab2);
ok(!newTab2.hasAttribute("pending"), "Second tab shouldn't be pending.");
// We can't just check browser.currentURI.spec, because from
@ -328,8 +334,8 @@ add_task(function test_revive_all_tabs_from_session_store() {
// We should also have two entries in the browser history.
yield promiseHistoryLength(browser, 2);
yield BrowserTestUtils.closeWindow(win2);
gBrowser.removeTab(newTab);
gBrowser.removeTab(newTab2);
});
/**
@ -359,9 +365,10 @@ add_task(function test_close_tab_after_crash() {
is(gBrowser.tabs.length, 1, "Should have closed the tab");
});
/**
* Checks that "restore all" button is only shown if more than one tab
* has crashed.
* is showing about:tabcrashed
*/
add_task(function* test_hide_restore_all_button() {
let newTab = gBrowser.addTab();
@ -391,11 +398,19 @@ add_task(function* test_hide_restore_all_button() {
browser.loadURI(PAGE_2);
yield promiseBrowserLoaded(browser);
// Load up a second window so we can get another tab to show
// about:tabcrashed
let win2 = yield BrowserTestUtils.openNewBrowserWindow();
let newTab3 = win2.gBrowser.addTab(PAGE_2);
win2.gBrowser.selectedTab = newTab3;
let otherWinBrowser = newTab3.linkedBrowser;
yield promiseBrowserLoaded(otherWinBrowser);
// We'll need to make sure the second tab's browser has finished
// sending its AboutTabCrashedReady event before we know for
// sure whether or not we're showing the right Restore buttons.
let otherBrowserReady = promiseTabCrashedReady(newTab2.linkedBrowser);
// Crash the tab
let otherBrowserReady = promiseTabCrashedReady(otherWinBrowser);
// Crash the first tab.
yield BrowserTestUtils.crashBrowser(browser);
yield otherBrowserReady;
@ -406,6 +421,7 @@ add_task(function* test_hide_restore_all_button() {
ok(!restoreAllButton.hasAttribute("hidden"), "Restore All button should not be hidden");
ok(!(restoreOneButton.classList.contains("primary")), "Restore Tab button should not have the primary class");
yield BrowserTestUtils.closeWindow(win2);
gBrowser.removeTab(newTab);
gBrowser.removeTab(newTab2);
});