зеркало из https://github.com/mozilla/gecko-dev.git
Bug 1451709 - Remove code for the "Restore Tabs From Last Time" button in the tab bar. r=mikedeboer
MozReview-Commit-ID: JMmkE6axBBK --HG-- extra : rebase_source : 2449c9fd6fe8f59280dbdfe5a1a55bcd2867a665
This commit is contained in:
Родитель
cbf9e7b900
Коммит
f8110c1b6a
|
@ -490,13 +490,6 @@ pref("browser.tabs.drawInTitlebar", true);
|
|||
// 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:
|
||||
|
|
|
@ -8712,23 +8712,8 @@ function switchToTabHavingURI(aURI, aOpenNew, aOpenParams = {}) {
|
|||
|
||||
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()) {
|
||||
|
@ -8736,34 +8721,11 @@ var RestoreLastSessionObserver = {
|
|||
}
|
||||
},
|
||||
|
||||
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,
|
||||
|
|
|
@ -95,13 +95,6 @@
|
|||
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>
|
||||
|
@ -112,9 +105,6 @@
|
|||
<![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);
|
||||
|
@ -175,13 +165,6 @@
|
|||
<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>
|
||||
|
@ -190,51 +173,6 @@
|
|||
</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"/>
|
||||
|
@ -728,7 +666,6 @@
|
|||
|
||||
this._updateCloseButtons();
|
||||
this._handleTabSelect(true);
|
||||
this.updateSessionRestoreVisibility();
|
||||
break;
|
||||
case "mouseout":
|
||||
// If the "related target" (the node to which the pointer went) is not
|
||||
|
|
|
@ -3514,10 +3514,6 @@ var SessionStoreInternal = {
|
|||
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);
|
||||
|
||||
|
|
|
@ -2,7 +2,6 @@
|
|||
# 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
|
||||
|
|
|
@ -128,7 +128,6 @@ XPCOMUtils.defineLazyGetter(this, "ALL_BUILTIN_ITEMS", function() {
|
|||
"BMB_bookmarksToolbarPopup",
|
||||
"search-go-button",
|
||||
"soundplaying-icon",
|
||||
"restore-tabs-button",
|
||||
];
|
||||
return DEFAULT_ITEMS.concat(PALETTE_ITEMS)
|
||||
.concat(SPECIAL_CASES);
|
||||
|
|
|
@ -628,11 +628,6 @@ notification[value="translation"] menulist > .menulist-dropmarker {
|
|||
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) {
|
||||
|
|
|
@ -748,55 +748,3 @@
|
|||
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;
|
||||
}
|
||||
|
|
|
@ -1115,7 +1115,3 @@ panel[touchmode] .PanelUI-subView #appMenu-zoom-controls > .subviewbutton-iconic
|
|||
padding-bottom: .9167em;
|
||||
}
|
||||
|
||||
/* Prevent movement in the restore-tabs-button when it's clicked. */
|
||||
.restore-tabs-button:hover:active:not([disabled="true"]) {
|
||||
padding: 3px;
|
||||
}
|
||||
|
|
|
@ -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]
|
||||
|
|
|
@ -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'), '')
|
|
@ -38,23 +38,6 @@ class TabBar(UIBaseLib):
|
|||
"""
|
||||
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.
|
||||
|
|
|
@ -361,88 +361,6 @@ browser.usage:
|
|||
|
||||
# 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
|
||||
|
|
Загрузка…
Ссылка в новой задаче