зеркало из https://github.com/mozilla/gecko-dev.git
Bug 1550662 - Make "Reload All Tabs" simply discard browsers when switching Content Blocking modes. r=mconley,johannh
Differential Revision: https://phabricator.services.mozilla.com/D34524 --HG-- extra : moz-landing-system : lando
This commit is contained in:
Родитель
0b7007a23b
Коммит
0cdf73ebb1
|
@ -1150,19 +1150,26 @@ var gPrivacyPane = {
|
|||
},
|
||||
|
||||
/**
|
||||
* Reload all tabs in all windows, except the active Preferences tab.
|
||||
* Discard the browsers of all tabs in all windows. Pinned tabs, as
|
||||
* well as tabs for which discarding doesn't succeed (e.g. selected
|
||||
* tabs, tabs with beforeunload listeners), are reloaded.
|
||||
*/
|
||||
reloadAllOtherTabs() {
|
||||
let activeWindow = window.BrowserWindowTracker.getTopWindow();
|
||||
let selectedPrefTab = activeWindow.gBrowser.selectedTab;
|
||||
for (let win of window.BrowserWindowTracker.orderedWindows) {
|
||||
let tabbrowser = win.gBrowser;
|
||||
let tabsToReload = [...tabbrowser.tabs];
|
||||
if (win == activeWindow ) {
|
||||
tabsToReload = tabsToReload.filter(tab => tab !== selectedPrefTab);
|
||||
let ourTab = BrowserWindowTracker.getTopWindow().gBrowser.selectedTab;
|
||||
BrowserWindowTracker.orderedWindows.forEach(win => {
|
||||
let otherGBrowser = win.gBrowser;
|
||||
for (let tab of otherGBrowser.tabs) {
|
||||
if (tab == ourTab) {
|
||||
// Don't reload our preferences tab.
|
||||
continue;
|
||||
}
|
||||
|
||||
if (tab.pinned || !otherGBrowser.discardBrowser(tab)) {
|
||||
otherGBrowser.reloadTab(tab);
|
||||
}
|
||||
}
|
||||
tabbrowser.reloadTabs(tabsToReload);
|
||||
}
|
||||
});
|
||||
|
||||
for (let notification of document.querySelectorAll(".reload-tabs")) {
|
||||
notification.hidden = true;
|
||||
}
|
||||
|
|
|
@ -525,6 +525,8 @@ add_task(async function testContentBlockingReloadWarning() {
|
|||
add_task(async function testReloadTabsMessage() {
|
||||
Services.prefs.setStringPref(CAT_PREF, "strict");
|
||||
let exampleTab = await BrowserTestUtils.openNewForegroundTab(gBrowser, "http://example.com");
|
||||
let examplePinnedTab = await BrowserTestUtils.openNewForegroundTab(gBrowser, "http://example.com");
|
||||
gBrowser.pinTab(examplePinnedTab);
|
||||
await openPreferencesViaOpenPreferencesAPI("privacy", {leaveOpen: true});
|
||||
let doc = gBrowser.contentDocument;
|
||||
let standardWarning = doc.querySelector("#contentBlockingOptionStandard .content-blocking-warning.reload-tabs");
|
||||
|
@ -533,14 +535,19 @@ add_task(async function testReloadTabsMessage() {
|
|||
Services.prefs.setStringPref(CAT_PREF, "standard");
|
||||
ok(!BrowserTestUtils.is_hidden(standardWarning), "The warning in the standard section should be showing");
|
||||
|
||||
let exampleTabBrowserDiscardedPromise = BrowserTestUtils.waitForEvent(exampleTab, "TabBrowserDiscarded");
|
||||
let examplePinnedTabLoadPromise = BrowserTestUtils.browserLoaded(examplePinnedTab.linkedBrowser);
|
||||
standardReloadButton.click();
|
||||
// The example page had a load event
|
||||
await BrowserTestUtils.browserLoaded(exampleTab.linkedBrowser);
|
||||
// The pinned example page had a load event
|
||||
await examplePinnedTabLoadPromise;
|
||||
// The other one had its browser discarded
|
||||
await exampleTabBrowserDiscardedPromise;
|
||||
|
||||
ok(BrowserTestUtils.is_hidden(standardWarning), "The warning in the standard section should have hidden after being clicked");
|
||||
|
||||
// cleanup
|
||||
Services.prefs.setStringPref(CAT_PREF, "standard");
|
||||
gBrowser.removeTab(exampleTab);
|
||||
gBrowser.removeTab(examplePinnedTab);
|
||||
gBrowser.removeCurrentTab();
|
||||
});
|
||||
|
|
Загрузка…
Ссылка в новой задаче