Bug 1451709 - Remove code for the "Restore Tabs From Last Time" button in the tab bar. r?mikedeboer
MozReview-Commit-ID: JMmkE6axBBK
--- a/browser/app/profile/firefox.js
+++ b/browser/app/profile/firefox.js
@@ -485,23 +485,16 @@ pref("browser.tabs.drawInTitlebar", fals
#else
pref("browser.tabs.drawInTitlebar", true);
#endif
// Offer additional drag space to the user. The drag space
// will only be shown if browser.tabs.drawInTitlebar is true.
pref("browser.tabs.extraDragSpace", false);
-// 0 - Disable the tabbar session restore button.
-// 1 - Enable the tabbar session restore button.
-// 2 - Control group. The tabbar session restore button is disabled,
-// but we will record data on other session restore usage.
-// To be enabled with shield.
-pref("browser.tabs.restorebutton", 0);
-
// When tabs opened by links in other tabs via a combination of
// browser.link.open_newwindow being set to 3 and target="_blank" etc are
// closed:
// true return to the tab that opened this tab (its owner)
// false return to the adjacent tab (old default)
pref("browser.tabs.selectOwnerOnClose", true);
pref("browser.tabs.showAudioPlayingIcon", true);
--- a/browser/base/content/browser.js
+++ b/browser/base/content/browser.js
@@ -8709,68 +8709,30 @@ function switchToTabHavingURI(aURI, aOpe
openUILinkIn(aURI.spec, "tab", aOpenParams);
}
return false;
}
var RestoreLastSessionObserver = {
init() {
- let browser_tabs_restorebutton_pref = Services.prefs.getIntPref("browser.tabs.restorebutton");
- Services.telemetry.scalarSet("browser.session.restore.browser_tabs_restorebutton", browser_tabs_restorebutton_pref);
- Services.telemetry.scalarSet("browser.session.restore.browser_startup_page", Services.prefs.getIntPref("browser.startup.page"));
if (SessionStore.canRestoreLastSession &&
!PrivateBrowsingUtils.isWindowPrivate(window)) {
- if (browser_tabs_restorebutton_pref == 1) {
- let {restoreTabsButton, restoreTabsButtonWrapperWidth} = gBrowser.tabContainer;
- let restoreTabsButtonWrapper = restoreTabsButton.parentNode;
- restoreTabsButtonWrapper.setAttribute("session-exists", "true");
- gBrowser.tabContainer.updateSessionRestoreVisibility();
- restoreTabsButton.style.maxWidth = `${restoreTabsButtonWrapperWidth}px`;
- gBrowser.tabContainer.addEventListener("TabOpen", this);
- Services.telemetry.scalarSet("browser.session.restore.tabbar_restore_available", true);
- restoreTabsButton.addEventListener("click", () => {
- Services.telemetry.scalarSet("browser.session.restore.tabbar_restore_clicked", true);
- });
- }
Services.obs.addObserver(this, "sessionstore-last-session-cleared", true);
goSetCommandEnabled("Browser:RestoreLastSession", true);
} else if (SessionStartup.isAutomaticRestoreEnabled()) {
document.getElementById("Browser:RestoreLastSession").setAttribute("hidden", true);
}
},
- handleEvent(event) {
- switch (event.type) {
- case "TabOpen":
- this.removeRestoreButton();
- break;
- }
- },
-
- removeRestoreButton() {
- let {restoreTabsButton} = gBrowser.tabContainer;
- let restoreTabsButtonWrapper = restoreTabsButton.parentNode;
- gBrowser.tabContainer.addEventListener("transitionend", function maxWidthTransitionHandler(e) {
- if (e.target == gBrowser.tabContainer && e.propertyName == "max-width") {
- gBrowser.tabContainer.updateSessionRestoreVisibility();
- gBrowser.tabContainer.removeEventListener("transitionend", maxWidthTransitionHandler);
- }
- });
- restoreTabsButtonWrapper.removeAttribute("session-exists");
- restoreTabsButton.style.maxWidth = 0;
- gBrowser.tabContainer.removeEventListener("TabOpen", this);
- },
-
observe() {
// The last session can only be restored once so there's
// no way we need to re-enable our menu item.
Services.obs.removeObserver(this, "sessionstore-last-session-cleared");
goSetCommandEnabled("Browser:RestoreLastSession", false);
- this.removeRestoreButton();
},
QueryInterface: XPCOMUtils.generateQI([Ci.nsIObserver,
Ci.nsISupportsWeakReference])
};
function restoreLastSession() {
SessionStore.restoreLastSession();
--- a/browser/base/content/tabbrowser.xml
+++ b/browser/base/content/tabbrowser.xml
@@ -90,36 +90,26 @@
button, necessary due to the previous hack.
-->
<children/>
<xul:toolbarbutton class="tabs-newtab-button toolbarbutton-1"
anonid="tabs-newtab-button"
command="cmd_newNavigatorTab"
onclick="checkForMiddleClick(this, event);"
tooltip="dynamic-shortcut-tooltip"/>
- <xul:hbox class="restore-tabs-button-wrapper"
- anonid="restore-tabs-button-wrapper">
- <xul:toolbarbutton anonid="restore-tabs-button"
- class="restore-tabs-button"
- onclick="SessionStore.restoreLastSession();"/>
- </xul:hbox>
-
<xul:spacer class="closing-tabs-spacer" anonid="closing-tabs-spacer"
style="width: 0;"/>
</xul:arrowscrollbox>
</content>
<implementation implements="nsIDOMEventListener, nsIObserver">
<constructor>
<![CDATA[
this._tabClipWidth = Services.prefs.getIntPref("browser.tabs.tabClipWidth");
- let { restoreTabsButton } = this;
- restoreTabsButton.setAttribute("label", gTabBrowserBundle.GetStringFromName("tabs.restoreLastTabs"));
-
let strId = PrivateBrowsingUtils.isWindowPrivate(window) ?
"emptyPrivateTabTitle" : "emptyTabTitle";
this.emptyTabTitle = gTabBrowserBundle.GetStringFromName("tabs." + strId);
var tab = this.firstChild;
tab.label = this.emptyTabTitle;
tab.setAttribute("onerror", "this.removeAttribute('image');");
@@ -170,76 +160,24 @@
</field>
<field name="_firstTab">null</field>
<field name="_lastTab">null</field>
<field name="_beforeSelectedTab">null</field>
<field name="_beforeHoveredTab">null</field>
<field name="_afterHoveredTab">null</field>
<field name="_hoveredTab">null</field>
- <field name="restoreTabsButton">
- document.getAnonymousElementByAttribute(this, "anonid", "restore-tabs-button");
- </field>
- <field name="_restoreTabsButtonWrapperWidth">0</field>
- <field name="windowUtils">
- window.QueryInterface(Ci.nsIInterfaceRequestor).getInterface(Ci.nsIDOMWindowUtils);
- </field>
<property name="_tabMinWidth">
<setter>
this.style.setProperty("--tab-min-width", val + "px");
return val;
</setter>
</property>
- <property name="restoreTabsButtonWrapperWidth" readonly="true">
- <getter>
- if (!this._restoreTabsButtonWrapperWidth) {
- this._restoreTabsButtonWrapperWidth = this.windowUtils
- .getBoundsWithoutFlushing(this.restoreTabsButton.parentNode)
- .width;
- }
- return this._restoreTabsButtonWrapperWidth;
- </getter>
- </property>
-
- <method name="updateSessionRestoreVisibility">
- <body><![CDATA[
- let {restoreTabsButton, restoreTabsButtonWrapperWidth, windowUtils} = this;
- let restoreTabsButtonWrapper = restoreTabsButton.parentNode;
-
- if (!restoreTabsButtonWrapper.getAttribute("session-exists")) {
- restoreTabsButtonWrapper.removeAttribute("shown");
- return;
- }
-
- let arrowScrollboxWidth = this.arrowScrollbox.clientWidth;
-
- let newTabButton = document.getAnonymousElementByAttribute(
- this, "anonid", "tabs-newtab-button");
-
- // If there are no pinned tabs it will multiply by 0 and result in 0
- let pinnedTabsWidth = windowUtils.getBoundsWithoutFlushing(this.firstChild).width * this._lastNumPinned;
-
- let numUnpinnedTabs = this.childNodes.length - this._lastNumPinned;
- let unpinnedTabsWidth = windowUtils.getBoundsWithoutFlushing(this.lastChild).width * numUnpinnedTabs;
-
- let tabbarUsedSpace = pinnedTabsWidth + unpinnedTabsWidth
- + windowUtils.getBoundsWithoutFlushing(newTabButton).width;
-
- // Subtract the elements' widths from the available space to ensure
- // that showing the restoreTabsButton won't cause any overflow.
- if (arrowScrollboxWidth - tabbarUsedSpace > restoreTabsButtonWrapperWidth) {
- restoreTabsButtonWrapper.setAttribute("shown", "true");
- } else {
- restoreTabsButtonWrapper.removeAttribute("shown");
- }
- ]]></body>
- </method>
-
<method name="observe">
<parameter name="aSubject"/>
<parameter name="aTopic"/>
<parameter name="aData"/>
<body><![CDATA[
switch (aTopic) {
case "nsPref:changed":
// This is has to deal with changes in
@@ -723,17 +661,16 @@
<body><![CDATA[
switch (aEvent.type) {
case "resize":
if (aEvent.target != window)
break;
this._updateCloseButtons();
this._handleTabSelect(true);
- this.updateSessionRestoreVisibility();
break;
case "mouseout":
// If the "related target" (the node to which the pointer went) is not
// a child of the current document, the mouse just left the window.
let relatedTarget = aEvent.relatedTarget;
if (relatedTarget && relatedTarget.ownerDocument == document)
break;
case "mousemove":
--- a/browser/components/sessionstore/SessionStore.jsm
+++ b/browser/components/sessionstore/SessionStore.jsm
@@ -3503,20 +3503,16 @@ var SessionStoreInternal = {
if (winData.tabs.length) {
this.restoreTabs(aWindow, tabs, winData.tabs, selectTab);
}
// set smoothScroll back to the original value
arrowScrollbox.smoothScroll = smoothScroll;
TelemetryStopwatch.finish("FX_SESSION_RESTORE_RESTORE_WINDOW_MS");
- if (Services.prefs.getIntPref("browser.tabs.restorebutton") != 0 ) {
- Services.telemetry.scalarAdd("browser.session.restore.number_of_tabs", winData.tabs.length);
- Services.telemetry.scalarAdd("browser.session.restore.number_of_win", 1);
- }
this._setWindowStateReady(aWindow);
this._sendWindowRestoredNotification(aWindow);
Services.obs.notifyObservers(aWindow, NOTIFY_SINGLE_WINDOW_RESTORED);
this._sendRestoreCompletedNotifications();
--- a/browser/locales/en-US/chrome/browser/tabbrowser.properties
+++ b/browser/locales/en-US/chrome/browser/tabbrowser.properties
@@ -1,13 +1,12 @@
# This Source Code Form is subject to the terms of the Mozilla Public
# License, v. 2.0. If a copy of the MPL was not distributed with this
# file, You can obtain one at http://mozilla.org/MPL/2.0/.
-tabs.restoreLastTabs=Restore Tabs From Last Time
tabs.emptyTabTitle=New Tab
tabs.emptyPrivateTabTitle=Private Browsing
tabs.closeTab=Close Tab
tabs.close=Close
tabs.closeWarningTitle=Confirm close
# LOCALIZATION NOTE (tabs.closeWarningMultiple):
# Semicolon-separated list of plural forms. See:
# http://developer.mozilla.org/en/docs/Localization_and_Plurals
--- a/browser/modules/BrowserUITelemetry.jsm
+++ b/browser/modules/BrowserUITelemetry.jsm
@@ -125,17 +125,16 @@ XPCOMUtils.defineLazyGetter(this, "ALL_B
"zoom-out-button",
"zoom-reset-button",
"zoom-in-button",
"BMB_bookmarksPopup",
"BMB_unsortedBookmarksPopup",
"BMB_bookmarksToolbarPopup",
"search-go-button",
"soundplaying-icon",
- "restore-tabs-button",
];
return DEFAULT_ITEMS.concat(PALETTE_ITEMS)
.concat(SPECIAL_CASES);
});
const OTHER_MOUSEUP_MONITORED_ITEMS = [
"PlacesChevron",
"PlacesToolbarItems",
--- a/browser/themes/linux/browser.css
+++ b/browser/themes/linux/browser.css
@@ -623,21 +623,16 @@ notification[value="translation"] menuli
overflow: hidden;
}
.webextension-popup-browser,
.webextension-popup-stack {
border-radius: inherit;
}
-/* Prevent movement in the restore-tabs-button when it's clicked. */
-.restore-tabs-button:hover:active:not([disabled="true"]) {
- padding: 3px;
-}
-
/* Hide the titlebar explicitly on versions of GTK+ where
* it's rendered by window manager. */
@media (-moz-gtk-csd-available: 0) {
#titlebar {
display: none;
}
}
--- a/browser/themes/shared/tabs.inc.css
+++ b/browser/themes/shared/tabs.inc.css
@@ -743,60 +743,8 @@
.alltabs-endimage[muted] {
list-style-image: url(chrome://browser/skin/tabbrowser/tab-audio-muted.svg);
}
.alltabs-endimage[activemedia-blocked] {
list-style-image: url(chrome://browser/skin/tabbrowser/tab-audio-blocked.svg);
}
-.restore-tabs-button-wrapper {
- visibility: hidden;
- position: fixed; /* so the button does not take up actual space and cause overflow buttons in the tabbar when hidden */
-}
-
-.restore-tabs-button-wrapper[shown] {
- visibility: visible;
- position: initial;
-}
-
-.restore-tabs-button {
- box-sizing: border-box;
- -moz-appearance: none;
- background-color: hsl(0,0%,0%,.04);
- border: 1px solid hsla(0,0%,16%,.2);
- border-radius: 3px;
- margin: 3px;
- margin-inline-start: 9px;
- transition: max-width 100ms;
- padding: 0 5px;
-}
-
-.restore-tabs-button:hover {
- background-color: hsl(0,0%,0%,.08);
-}
-
-.restore-tabs-button:active {
- background-color: hsl(0,0%,0%,.11);
-}
-
-#TabsToolbar[brighttext] .restore-tabs-button {
- background-color: hsl(0,0%,100%,.07);
- border-color:currentColor;
- color: currentColor;
- opacity: .7;
-}
-
-#TabsToolbar[brighttext] .restore-tabs-button:hover {
- background-color: hsl(0,0%,100%,.17);
-}
-
-#TabsToolbar[brighttext] .restore-tabs-button:active {
- background-color: hsl(0,0%,100%,.27);
-}
-
-.restore-tabs-button > .toolbarbutton-icon {
- display: none;
-}
-
-.restore-tabs-button > .toolbarbutton-text {
- display: -moz-box;
-}
--- a/browser/themes/windows/browser.css
+++ b/browser/themes/windows/browser.css
@@ -1110,12 +1110,8 @@ panel[touchmode] .PanelUI-subView #appMe
#ContentSelectDropdown > .isOpenedViaTouch > menucaption > .menu-iconic-text,
#ContentSelectDropdown > .isOpenedViaTouch > menuitem > .menu-iconic-text {
/* Touch padding should follow the 11/12 ratio, where 12px is the default
font-size with 11px being the preferred padding size. */
padding-top: .9167em;
padding-bottom: .9167em;
}
-/* Prevent movement in the restore-tabs-button when it's clicked. */
-.restore-tabs-button:hover:active:not([disabled="true"]) {
- padding: 3px;
-}
--- a/testing/firefox-ui/tests/functional/sessionstore/manifest.ini
+++ b/testing/firefox-ui/tests/functional/sessionstore/manifest.ini
@@ -1,6 +1,4 @@
[DEFAULT]
tags = local
-[test_tabbar_session_restore_button.py]
-skip-if = os == "mac" # Bug 1396803
[test_restore_windows_after_restart_and_quit.py]
deleted file mode 100644
--- a/testing/firefox-ui/tests/functional/sessionstore/test_tabbar_session_restore_button.py
+++ /dev/null
@@ -1,106 +0,0 @@
-# This Source Code Form is subject to the terms of the Mozilla Public
-# License, v. 2.0. If a copy of the MPL was not distributed with this
-# file, You can obtain one at http://mozilla.org/MPL/2.0/.
-from firefox_puppeteer import PuppeteerMixin
-from marionette_harness import MarionetteTestCase
-from marionette_driver import Wait
-
-
-class TestBaseTabbarSessionRestoreButton(PuppeteerMixin, MarionetteTestCase):
- def setUp(self, restore_button_pref=1):
- super(TestBaseTabbarSessionRestoreButton, self).setUp()
- self.marionette.enforce_gecko_prefs({'browser.tabs.restorebutton': restore_button_pref})
-
- # Each list element represents a window of tabs loaded at
- # some testing URL, the URLS are arbitrary.
- self.test_windows = set([
- (self.marionette.absolute_url('layout/mozilla_projects.html'),
- self.marionette.absolute_url('layout/mozilla.html'),
- self.marionette.absolute_url('layout/mozilla_mission.html')),
- ])
-
- self.open_windows(self.test_windows)
-
- self.marionette.quit(in_app=True)
- self.marionette.start_session()
- self.marionette.set_context('chrome')
-
- def open_windows(self, window_sets):
- win = self.browser
- for index, urls in enumerate(window_sets):
- if index > 0:
- win = self.browser.open_browser()
- win.switch_to()
- self.open_tabs(win, urls)
-
- def open_tabs(self, win, urls):
- # If there are any remaining URLs for this window,
- # open some new tabs and navigate to them.
- with self.marionette.using_context('content'):
- if isinstance(urls, str):
- self.marionette.navigate(urls)
- else:
- for index, url in enumerate(urls):
- if index > 0:
- with self.marionette.using_context('chrome'):
- win.tabbar.open_tab()
- self.marionette.navigate(url)
-
- def tearDown(self):
- try:
- # Create a fresh profile for subsequent tests.
- self.restart(clean=True)
- finally:
- super(TestBaseTabbarSessionRestoreButton, self).tearDown()
-
-
-class TestTabbarSessionRestoreButton(TestBaseTabbarSessionRestoreButton):
- def setUp(self):
- super(TestTabbarSessionRestoreButton, self).setUp()
-
- def test_session_exists(self):
- wrapper = self.puppeteer.windows.current.tabbar.restore_tabs_button_wrapper
-
- # A session-exists attribute has been added to the button,
- # which allows it to show.
- self.assertEqual(wrapper.get_attribute('session-exists'), 'true')
-
- def test_window_resizing(self):
- wrapper = self.puppeteer.windows.current.tabbar.restore_tabs_button_wrapper
-
- # Ensure the window is large enough to show the button.
- self.marionette.set_window_size(1200, 1200)
- self.assertEqual(wrapper.value_of_css_property('visibility'), 'visible')
-
- # Set the window small enough that the button disappears.
- self.marionette.set_window_size(335, 335)
- self.assertEqual(wrapper.value_of_css_property('visibility'), 'hidden')
-
- def test_click_restore(self):
- button = self.puppeteer.windows.current.tabbar.restore_tabs_button
-
- # The new browser window is not the same window as last time,
- # and did not automatically restore the session, so there is only one tab.
- self.assertEqual(len(self.puppeteer.windows.current.tabbar.tabs), 1)
-
- button.click()
-
- Wait(self.marionette, timeout=20).until(
- lambda _: len(self.puppeteer.windows.current.tabbar.tabs) > 1,
- message='there is only one tab, so the session was not restored')
-
- # After clicking the button to restore the session,
- # there is more than one tab.
- self.assertTrue(len(self.puppeteer.windows.current.tabbar.tabs) > 1)
-
-
-class TestNoTabbarSessionRestoreButton(TestBaseTabbarSessionRestoreButton):
- def setUp(self):
- super(TestNoTabbarSessionRestoreButton, self).setUp(restore_button_pref=0)
-
- def test_pref_off_button_does_not_show(self):
- wrapper = self.puppeteer.windows.current.tabbar.restore_tabs_button_wrapper
-
- # A session-exists attribute is not on the button,
- # since the button will never show itself with the pref off.
- self.assertEqual(wrapper.get_attribute('session-exists'), '')
--- a/testing/marionette/puppeteer/firefox/firefox_puppeteer/ui/browser/tabbar.py
+++ b/testing/marionette/puppeteer/firefox/firefox_puppeteer/ui/browser/tabbar.py
@@ -34,33 +34,16 @@ class TabBar(UIBaseLib):
def newtab_button(self):
"""The DOM element which represents the new tab button.
:returns: Reference to the new tab button.
"""
return self.toolbar.find_element(By.ANON_ATTRIBUTE, {'anonid': 'tabs-newtab-button'})
@property
- def restore_tabs_button(self):
- """The DOM element which represents the restore tabs button.
-
- :returns: Reference to the restore tabs button.
- """
- return self.toolbar.find_element(By.ANON_ATTRIBUTE, {'anonid': 'restore-tabs-button'})
-
- @property
- def restore_tabs_button_wrapper(self):
- """The DOM element which represents the restore tabs button wrapper.
-
- :returns: Reference to the restore tabs button wrapper.
- """
- return self.toolbar.find_element(
- By.ANON_ATTRIBUTE, {'anonid': 'restore-tabs-button-wrapper'})
-
- @property
def tabs(self):
"""List of all the :class:`Tab` instances of the current browser window.
:returns: List of :class:`Tab` instances.
"""
tabs = self.toolbar.find_elements(By.TAG_NAME, 'tab')
return [Tab(self.marionette, self.window, tab) for tab in tabs]
--- a/toolkit/components/telemetry/Scalars.yaml
+++ b/toolkit/components/telemetry/Scalars.yaml
@@ -356,98 +356,16 @@ browser.usage:
- bsmedberg@mozilla.com
release_channel_collection: opt-out
record_in_processes:
- 'main'
- 'content'
# The following section contains the session restore scalars.
browser.session.restore:
- number_of_win:
- bug_numbers:
- - 1379226
- description: The count of windows open after a session has been restored.
- expires: never
- kind: uint
- notification_emails:
- - bwinton@mozilla.com
- release_channel_collection: opt-out
- record_in_processes:
- - 'main'
-
- number_of_tabs:
- bug_numbers:
- - 1379226
- description: The count of tabs open after a session has been restored.
- expires: never
- kind: uint
- notification_emails:
- - bwinton@mozilla.com
- release_channel_collection: opt-out
- record_in_processes:
- - 'main'
-
- tabbar_restore_available:
- bug_numbers:
- - 1379226
- description: >
- Recorded on startup. Boolean stating whether the tabbar session
- restore button was ever available.
- expires: never
- kind: boolean
- notification_emails:
- - bwinton@mozilla.com
- release_channel_collection: opt-out
- record_in_processes:
- - 'main'
-
- tabbar_restore_clicked:
- bug_numbers:
- - 1379226
- description: >
- Recorded on click event. Boolean stating if the session restore button
- was clicked.
- expires: never
- kind: boolean
- notification_emails:
- - bwinton@mozilla.com
- release_channel_collection: opt-out
- record_in_processes:
- - 'main'
-
- browser_startup_page:
- bug_numbers:
- - 1379226
- description: >
- The value of the browser.startup.page pref.
- This pref restores the tabs and windows automatically when set to 3.
- expires: never
- kind: uint
- notification_emails:
- - bwinton@mozilla.com
- release_channel_collection: opt-out
- record_in_processes:
- - 'main'
-
- browser_tabs_restorebutton:
- bug_numbers:
- - 1379226
- description: >
- The value of the browser.tabs.restorebutton pref.
- 0 - the user is not a part of the experiment
- 1 - the user is a part of the experiment
- 2 - the user is part of the control group
- expires: never
- kind: uint
- notification_emails:
- - bwinton@mozilla.com
- release_channel_collection: opt-out
- record_in_processes:
- - 'main'
-
worker_restart_count:
bug_numbers:
- 1402267
description: >
A counter incremented every time the SessionFile worker is restarted due
to too many failures, as defined in the browser.sessionstore.max_write_failures
pref.
expires: "64"