From afe1d260d84023f1e31aad20778a8c20ae8eb725 Mon Sep 17 00:00:00 2001 From: Bill McCloskey Date: Thu, 24 Sep 2015 13:32:09 -0700 Subject: [PATCH] Bug 967873 - Test changes for async removeTab (r=Gijs) --- browser/base/content/browser.xul | 2 +- browser/base/content/tabbrowser.xml | 3 ++- browser/base/content/test/general/browser.ini | 1 - .../content/test/general/browser_bug406216.js | 8 ++++---- .../content/test/general/browser_bug432599.js | 2 +- .../content/test/general/browser_bug455852.js | 8 ++++++-- .../content/test/general/browser_bug521216.js | 11 +++++++---- .../content/test/general/browser_bug533232.js | 10 +++++----- .../content/test/general/browser_bug676619.js | 1 + .../test/general/browser_selectTabAtIndex.js | 2 +- browser/base/content/test/social/head.js | 2 +- devtools/client/netmonitor/test/head.js | 3 ++- .../test/helper_codemirror_runner.js | 4 ++-- docshell/test/browser/head.js | 2 +- .../serviceworkers/browser_force_refresh.js | 5 +++++ testing/mochitest/browser-test.js | 2 +- .../tests/browser/browser_Addons_sample.xpi | Bin 2133 -> 2134 bytes .../tests/browser/browser_compartments.js | 2 +- .../mozapps/extensions/test/xpinstall/head.js | 2 +- 19 files changed, 42 insertions(+), 28 deletions(-) diff --git a/browser/base/content/browser.xul b/browser/base/content/browser.xul index 5924f84649f..22ec16f5ffd 100644 --- a/browser/base/content/browser.xul +++ b/browser/base/content/browser.xul @@ -119,7 +119,7 @@ accesskey="&bookmarkAllTabs.accesskey;" command="Browser:BookmarkAllTabs"/> + oncommand="gBrowser.removeTabsToTheEndFrom(TabContextMenu.contextTab, {animate: true});"/> diff --git a/browser/base/content/tabbrowser.xml b/browser/base/content/tabbrowser.xml index 4ba99fb67ed..1b3872097fb 100644 --- a/browser/base/content/tabbrowser.xml +++ b/browser/base/content/tabbrowser.xml @@ -2070,12 +2070,13 @@ + = 0; --i) { - this.removeTab(tabs[i], {animate: true}); + this.removeTab(tabs[i], aParams); } } ]]> diff --git a/browser/base/content/test/general/browser.ini b/browser/base/content/test/general/browser.ini index e3ce99447d2..9d308d576cf 100644 --- a/browser/base/content/test/general/browser.ini +++ b/browser/base/content/test/general/browser.ini @@ -148,7 +148,6 @@ skip-if = e10s # Bug 1101993 - times out for unknown reasons when run in the dir [browser_backButtonFitts.js] skip-if = os == "mac" # The Fitt's Law back button is not supported on OS X [browser_beforeunload_duplicate_dialogs.js] -skip-if = e10s # bug 967873 means permitUnload doesn't work in e10s mode [browser_blob-channelname.js] [browser_bookmark_titles.js] skip-if = buildapp == 'mulet' || toolkit == "windows" # Disabled on Windows due to frequent failures (bugs 825739, 841341) diff --git a/browser/base/content/test/general/browser_bug406216.js b/browser/base/content/test/general/browser_bug406216.js index db3b1bffac9..e1bd3839599 100644 --- a/browser/base/content/test/general/browser_bug406216.js +++ b/browser/base/content/test/general/browser_bug406216.js @@ -22,7 +22,7 @@ function test() { function addTab(aURI, aIndex) { var tab = gBrowser.addTab(aURI); if (aIndex == 0) - gBrowser.removeTab(gBrowser.tabs[0]); + gBrowser.removeTab(gBrowser.tabs[0], {skipPermitUnload: true}); tab.linkedBrowser.addEventListener("load", function (event) { event.currentTarget.removeEventListener("load", arguments.callee, true); @@ -41,14 +41,14 @@ function doTabsTest() { var scheme = closedTab.linkedBrowser.currentURI.scheme; Array.slice(gBrowser.tabs).forEach(function (aTab) { if (aTab != closedTab && aTab.linkedBrowser.currentURI.scheme == scheme) - gBrowser.removeTab(aTab); + gBrowser.removeTab(aTab, {skipPermitUnload: true}); }); }, true); - gBrowser.removeTab(gBrowser.tabs[0]); + gBrowser.removeTab(gBrowser.tabs[0], {skipPermitUnload: true}); is(gBrowser.tabs.length, 1, "Related tabs are not closed unexpectedly"); gBrowser.addTab("about:blank"); - gBrowser.removeTab(gBrowser.tabs[0]); + gBrowser.removeTab(gBrowser.tabs[0], {skipPermitUnload: true}); finish(); } diff --git a/browser/base/content/test/general/browser_bug432599.js b/browser/base/content/test/general/browser_bug432599.js index 4989faae0ca..a5f7c0b5e7d 100644 --- a/browser/base/content/test/general/browser_bug432599.js +++ b/browser/base/content/test/general/browser_bug432599.js @@ -99,7 +99,7 @@ function checkBookmarksPanel(invoker, phase) if (currentInvoker < invokers.length) { checkBookmarksPanel(invokers[currentInvoker], 1); } else { - gBrowser.removeCurrentTab(); + gBrowser.removeTab(gBrowser.selectedTab, {skipPermitUnload: true}); PlacesUtils.bookmarks.removeItem(bookmarkId); executeSoon(finish); } diff --git a/browser/base/content/test/general/browser_bug455852.js b/browser/base/content/test/general/browser_bug455852.js index 52798f10299..ce883b5819f 100644 --- a/browser/base/content/test/general/browser_bug455852.js +++ b/browser/base/content/test/general/browser_bug455852.js @@ -1,4 +1,4 @@ -function test() { +add_task(function*() { is(gBrowser.tabs.length, 1, "one tab is open"); gBrowser.selectedBrowser.focus(); @@ -6,11 +6,15 @@ function test() { var tab = gBrowser.selectedTab; gPrefService.setBoolPref("browser.tabs.closeWindowWithLastTab", false); + + let tabClosedPromise = BrowserTestUtils.removeTab(tab, {dontRemove: true}); EventUtils.synthesizeKey("w", { accelKey: true }); + yield tabClosedPromise; + is(tab.parentNode, null, "ctrl+w removes the tab"); is(gBrowser.tabs.length, 1, "a new tab has been opened"); is(document.activeElement, gURLBar.inputField, "location bar is focused for the new tab"); if (gPrefService.prefHasUserValue("browser.tabs.closeWindowWithLastTab")) gPrefService.clearUserPref("browser.tabs.closeWindowWithLastTab"); -} +}); diff --git a/browser/base/content/test/general/browser_bug521216.js b/browser/base/content/test/general/browser_bug521216.js index 5156c4c60cf..735ae92f628 100644 --- a/browser/base/content/test/general/browser_bug521216.js +++ b/browser/base/content/test/general/browser_bug521216.js @@ -18,10 +18,13 @@ function record(aName) { if (actual.length == expected.length) { is(actual.toString(), expected.toString(), "got events and progress notifications in expected order"); - gBrowser.removeTab(tab); - gBrowser.removeTabsProgressListener(progressListener); - gBrowser.tabContainer.removeEventListener("TabOpen", TabOpen, false); - finish(); + + executeSoon(function(tab) { + gBrowser.removeTab(tab); + gBrowser.removeTabsProgressListener(progressListener); + gBrowser.tabContainer.removeEventListener("TabOpen", TabOpen, false); + finish(); + }.bind(null, tab)); } } diff --git a/browser/base/content/test/general/browser_bug533232.js b/browser/base/content/test/general/browser_bug533232.js index fdee75ba266..6c7a0e51fd7 100644 --- a/browser/base/content/test/general/browser_bug533232.js +++ b/browser/base/content/test/general/browser_bug533232.js @@ -6,14 +6,14 @@ function test() { childTab1 = gBrowser.addTab("about:blank", { relatedToCurrent: true }); gBrowser.selectedTab = childTab1; - gBrowser.removeCurrentTab(); + gBrowser.removeTab(gBrowser.selectedTab, { skipPermitUnload: true }); is(idx(gBrowser.selectedTab), idx(tab1), "closing a tab next to its parent selects the parent"); childTab1 = gBrowser.addTab("about:blank", { relatedToCurrent: true }); gBrowser.selectedTab = tab2; gBrowser.selectedTab = childTab1; - gBrowser.removeCurrentTab(); + gBrowser.removeTab(gBrowser.selectedTab, { skipPermitUnload: true }); is(idx(gBrowser.selectedTab), idx(tab2), "closing a tab next to its parent doesn't select the parent if another tab had been selected ad interim"); @@ -21,14 +21,14 @@ function test() { childTab1 = gBrowser.addTab("about:blank", { relatedToCurrent: true }); childTab2 = gBrowser.addTab("about:blank", { relatedToCurrent: true }); gBrowser.selectedTab = childTab1; - gBrowser.removeCurrentTab(); + gBrowser.removeTab(gBrowser.selectedTab, { skipPermitUnload: true }); is(idx(gBrowser.selectedTab), idx(childTab2), "closing a tab next to its parent selects the next tab with the same parent"); - gBrowser.removeCurrentTab(); + gBrowser.removeTab(gBrowser.selectedTab, { skipPermitUnload: true }); is(idx(gBrowser.selectedTab), idx(tab2), "closing the last tab in a set of child tabs doesn't go back to the parent"); - gBrowser.removeTab(tab2); + gBrowser.removeTab(tab2, { skipPermitUnload: true }); } function idx(tab) { diff --git a/browser/base/content/test/general/browser_bug676619.js b/browser/base/content/test/general/browser_bug676619.js index 03211f9698a..f2dff376c40 100644 --- a/browser/base/content/test/general/browser_bug676619.js +++ b/browser/base/content/test/general/browser_bug676619.js @@ -1,4 +1,5 @@ function test () { + requestLongerTimeout(2); waitForExplicitFinish(); var isHTTPS = false; diff --git a/browser/base/content/test/general/browser_selectTabAtIndex.js b/browser/base/content/test/general/browser_selectTabAtIndex.js index d84682e68c5..a1306afbc83 100644 --- a/browser/base/content/test/general/browser_selectTabAtIndex.js +++ b/browser/base/content/test/general/browser_selectTabAtIndex.js @@ -18,5 +18,5 @@ function test() { "gBrowser.selectTabAtIndex(-3) selects expected tab"); for (let i = 0; i < 9; i++) - gBrowser.removeCurrentTab(); + gBrowser.removeTab(gBrowser.selectedTab, {skipPermitUnload: true}); } diff --git a/browser/base/content/test/social/head.js b/browser/base/content/test/social/head.js index 4de6785a2ee..7c7aac5540b 100644 --- a/browser/base/content/test/social/head.js +++ b/browser/base/content/test/social/head.js @@ -416,7 +416,7 @@ function loadIntoTab(tab, url, callback) { function ensureBrowserTabClosed(tab) { let promise = ensureEventFired(gBrowser.tabContainer, "TabClose"); - gBrowser.removeTab(tab); + gBrowser.removeTab(tab, {skipPermitUnload: true}); return promise; } diff --git a/devtools/client/netmonitor/test/head.js b/devtools/client/netmonitor/test/head.js index 3233a3e4813..be133768648 100644 --- a/devtools/client/netmonitor/test/head.js +++ b/devtools/client/netmonitor/test/head.js @@ -107,7 +107,8 @@ function removeTab(aTab, aWindow) { let targetWindow = aWindow || window; let targetBrowser = targetWindow.gBrowser; - targetBrowser.removeTab(aTab); + // browser_net_pane-toggle.js relies on synchronous removeTab behavior. + targetBrowser.removeTab(aTab, {skipPermitUnload: true}); } function waitForNavigation(aTarget) { diff --git a/devtools/client/sourceeditor/test/helper_codemirror_runner.js b/devtools/client/sourceeditor/test/helper_codemirror_runner.js index b5eba5d40e8..4759c54185b 100644 --- a/devtools/client/sourceeditor/test/helper_codemirror_runner.js +++ b/devtools/client/sourceeditor/test/helper_codemirror_runner.js @@ -28,8 +28,8 @@ function runCodeMirrorTest(browser) { 'function check() { ' + ' var doc = content.document; var out = doc.getElementById("status"); ' + ' if (!out || !out.classList.contains("done")) { return setTimeout(check, 100); }' + - ' sendSyncMessage("done", { failed: content.wrappedJSObject.failed });' + + ' sendAsyncMessage("done", { failed: content.wrappedJSObject.failed });' + '}' + 'check();' , true); -} \ No newline at end of file +} diff --git a/docshell/test/browser/head.js b/docshell/test/browser/head.js index 29df446d6c1..ae4be398142 100644 --- a/docshell/test/browser/head.js +++ b/docshell/test/browser/head.js @@ -31,8 +31,8 @@ function makeTimelineTest(frameScriptName, url) { info(message.data.message); }); mm.addMessageListener("browser:test:finish", function(ignore) { - finish(); gBrowser.removeCurrentTab(); + finish(); }); }); } diff --git a/dom/workers/test/serviceworkers/browser_force_refresh.js b/dom/workers/test/serviceworkers/browser_force_refresh.js index c6a7d70c3db..2121e1e4053 100644 --- a/dom/workers/test/serviceworkers/browser_force_refresh.js +++ b/dom/workers/test/serviceworkers/browser_force_refresh.js @@ -29,6 +29,11 @@ function test() { function eventHandler(event) { if (event.type === 'base-load') { if (cachedLoad) { + removeEventListener('base-load', eventHandler, true); + removeEventListener('base-register', eventHandler, true); + removeEventListener('base-sw-ready', eventHandler, true); + removeEventListener('cached-load', eventHandler, true); + gBrowser.removeTab(tab); executeSoon(finish); } diff --git a/testing/mochitest/browser-test.js b/testing/mochitest/browser-test.js index 1a823b006a8..e59adf04072 100644 --- a/testing/mochitest/browser-test.js +++ b/testing/mochitest/browser-test.js @@ -288,7 +288,7 @@ Tester.prototype = { // Replace the last tab with a fresh one if (window.gBrowser) { gBrowser.addTab("about:blank", { skipAnimation: true }); - gBrowser.removeCurrentTab(); + gBrowser.removeTab(gBrowser.selectedTab, { skipPermitUnload: true }); gBrowser.stop(); } diff --git a/toolkit/components/perfmonitoring/tests/browser/browser_Addons_sample.xpi b/toolkit/components/perfmonitoring/tests/browser/browser_Addons_sample.xpi index 92e0019d6c7e9ce8cb479628fd1332ddd9d8406f..4b5ca3c1aca0464554485690c0736a6befe6d644 100644 GIT binary patch delta 713 zcmcaAa7}Q$s%WR9;p2zx)BTvP)9IuFaQ<0 zd9C@~WWdP4Z~%zK7-S|3a7fm3GBAVm&cf6i+V7Zs$U&g>{cml#Mkf(pmlv+D7e;Wg zE_LEw+R=VCZBkC>?oHO28z%j~=X-UU+_c2|d%mCbu{x5y)HW{Xu}ETO@u9_~)huVt zZ?bE$MHjdx6jk#_|Ean5&HMV+Bg;-^tz~J8$gFogc9~;7=dzP32ZI?oQ~8hIKay7Jtn2mWa zUt&2N(y`)Wi`*KES=@mpZX36;MLs@L^!bk%e}RyLuT0D(L$QhpKAjtLZDzzfAPyQ;NoLl1d%{O^&7zf`_suFpA-nB?2uzF9`8J6^M0j&=AOUY(Xd)J0f<^kS}OmfV?NT0ln%}fRq z>nJe}iVm29A8e*FplHXbz?0ol2^8&E6>u?t04VO4uf~LFInVFqR%p7TEV~obp!(k!;y|$ zx2pMb^YnqX9|vMF2ARo%9Fp~%49p+6m_z>qF^cmT7(ypFW*>48Xnp@vwBJFoOHJv^ zqOSoutxZ7-TZ4`qPBZr0c0~5(T$3A*>ff)rdg-vinb|Yn8&3ZEF-p2$Ja4YrnVkwY zn{F#*>^p1k!QG;0>Ubj8c886q_dg@w#T&9dAA7-3tJ9-a|2nhbyvXB{DUVjRG(Eff zZ`bCi1;KLDSX)0n^0~()`l9Db;(;H^%S?O|_7rok)v*vyb=t(Dy27<=vd-;!dxOhD z#b!hnoDTZ3S)(i3-=b;jk;@vNQo5`6Z?E#ax4LUm#EH`ZqO7<5I@g`#{o1#?bEDfM z#(n&XN(%XN=dPc3Uri$CGwfx?XPl^Uz9A<^p`)tn~_P585rl2 zm$RA4fFd0&L=g&pvYE<&VjZUfFLp~MP^@EBz{LOppr~KUuA>8rdaTNTE callback(count)); }, // Window open handling