Merge mozilla-central to mozilla-inbound. a=merge on a CLOSED TREE

This commit is contained in:
Andreea Pavel 2018-07-08 00:54:23 +03:00
Родитель 9456afdee0 c815b24ed0
Коммит 2ef6a9ab83
15 изменённых файлов: 216 добавлений и 219 удалений

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

@ -4563,12 +4563,6 @@ function updateFileMenuUserContextUIVisibility(id) {
menu.setAttribute("disabled", "true");
}
}
function updateTabMenuUserContextUIVisibility(id) {
let menu = document.getElementById(id);
// Visibility of Tab menu item can change frequently.
menu.hidden = !Services.prefs.getBoolPref("privacy.userContext.enabled", false) ||
PrivateBrowsingUtils.isWindowPrivate(window);
}
/**
* Updates the User Context UI indicators if the browser is in a non-default context
@ -4601,44 +4595,6 @@ function updateUserContextUIIndicator() {
hbox.hidden = false;
}
/**
* Fill 'Reopen in Container' menu.
*/
function createReopenInContainerMenu(event) {
let currentid = TabContextMenu.contextTab.getAttribute("usercontextid");
return createUserContextMenu(event, {
isContextMenu: true,
excludeUserContextId: currentid,
});
}
/**
* Reopen the tab in another container.
*/
function reopenInContainer(event) {
let userContextId = parseInt(event.target.getAttribute("data-usercontextid"));
let currentTab = TabContextMenu.contextTab;
let isSelected = (gBrowser.selectedTab == currentTab);
let uri = currentTab.linkedBrowser.currentURI.spec;
let newTab = gBrowser.addTab(uri, {
userContextId,
pinned: currentTab.pinned,
index: currentTab._tPos + 1,
});
// Carry over some configuration.
if (isSelected) {
gBrowser.selectedTab = newTab;
}
if (currentTab.muted) {
if (!newTab.muted) {
newTab.toggleMuteAudio(currentTab.muteReason);
}
}
}
/**
* Makes the Character Encoding menu enabled or disabled as appropriate.
* To be called when the View menu or the app menu is opened.
@ -7843,136 +7799,6 @@ var MenuTouchModeObserver = {
},
};
var TabContextMenu = {
contextTab: null,
_updateToggleMuteMenuItems(aTab, aConditionFn) {
["muted", "soundplaying"].forEach(attr => {
if (!aConditionFn || aConditionFn(attr)) {
if (aTab.hasAttribute(attr)) {
aTab.toggleMuteMenuItem.setAttribute(attr, "true");
aTab.toggleMultiSelectMuteMenuItem.setAttribute(attr, "true");
} else {
aTab.toggleMuteMenuItem.removeAttribute(attr);
aTab.toggleMultiSelectMuteMenuItem.removeAttribute(attr);
}
}
});
},
updateContextMenu: function updateContextMenu(aPopupMenu) {
this.contextTab = aPopupMenu.triggerNode.localName == "tab" ?
aPopupMenu.triggerNode : gBrowser.selectedTab;
let disabled = gBrowser.tabs.length == 1;
let multiselectionContext = this.contextTab.multiselected;
var menuItems = aPopupMenu.getElementsByAttribute("tbattr", "tabbrowser-multiple");
for (let menuItem of menuItems)
menuItem.disabled = disabled;
if (this.contextTab.hasAttribute("customizemode"))
document.getElementById("context_openTabInWindow").disabled = true;
disabled = gBrowser.visibleTabs.length == 1;
menuItems = aPopupMenu.getElementsByAttribute("tbattr", "tabbrowser-multiple-visible");
for (let menuItem of menuItems)
menuItem.disabled = disabled;
// Session store
document.getElementById("context_undoCloseTab").disabled =
SessionStore.getClosedTabCount(window) == 0;
// Only one of Reload_Tab/Reload_Selected_Tabs should be visible.
document.getElementById("context_reloadTab").hidden = multiselectionContext;
document.getElementById("context_reloadSelectedTabs").hidden = !multiselectionContext;
// Only one of pin/unpin/multiselect-pin/multiselect-unpin should be visible
let contextPinTab = document.getElementById("context_pinTab");
contextPinTab.hidden = this.contextTab.pinned || multiselectionContext;
let contextUnpinTab = document.getElementById("context_unpinTab");
contextUnpinTab.hidden = !this.contextTab.pinned || multiselectionContext;
let contextPinSelectedTabs = document.getElementById("context_pinSelectedTabs");
contextPinSelectedTabs.hidden = this.contextTab.pinned || !multiselectionContext;
let contextUnpinSelectedTabs = document.getElementById("context_unpinSelectedTabs");
contextUnpinSelectedTabs.hidden = !this.contextTab.pinned || !multiselectionContext;
// Disable "Close Tabs to the Right" if there are no tabs
// following it.
document.getElementById("context_closeTabsToTheEnd").disabled =
gBrowser.getTabsToTheEndFrom(this.contextTab).length == 0;
// Disable "Close other Tabs" if there are no unpinned tabs.
let unpinnedTabsToClose = gBrowser.visibleTabs.length - gBrowser._numPinnedTabs;
if (!this.contextTab.pinned) {
unpinnedTabsToClose--;
}
document.getElementById("context_closeOtherTabs").disabled = unpinnedTabsToClose < 1;
// Only one of close_tab/close_selected_tabs should be visible
document.getElementById("context_closeTab").hidden = multiselectionContext;
document.getElementById("context_closeSelectedTabs").hidden = !multiselectionContext;
// Hide "Bookmark All Tabs" for a pinned tab. Update its state if visible.
let bookmarkAllTabs = document.getElementById("context_bookmarkAllTabs");
bookmarkAllTabs.hidden = this.contextTab.pinned;
if (!bookmarkAllTabs.hidden)
PlacesCommandHook.updateBookmarkAllTabsCommand();
let toggleMute = document.getElementById("context_toggleMuteTab");
let toggleMultiSelectMute = document.getElementById("context_toggleMuteSelectedTabs");
// Only one of mute_unmute_tab/mute_unmute_selected_tabs should be visible
toggleMute.hidden = multiselectionContext;
toggleMultiSelectMute.hidden = !multiselectionContext;
// Adjust the state of the toggle mute menu item.
if (this.contextTab.hasAttribute("activemedia-blocked")) {
toggleMute.label = gNavigatorBundle.getString("playTab.label");
toggleMute.accessKey = gNavigatorBundle.getString("playTab.accesskey");
} else if (this.contextTab.hasAttribute("muted")) {
toggleMute.label = gNavigatorBundle.getString("unmuteTab.label");
toggleMute.accessKey = gNavigatorBundle.getString("unmuteTab.accesskey");
} else {
toggleMute.label = gNavigatorBundle.getString("muteTab.label");
toggleMute.accessKey = gNavigatorBundle.getString("muteTab.accesskey");
}
// Adjust the state of the toggle mute menu item for multi-selected tabs.
if (this.contextTab.hasAttribute("activemedia-blocked")) {
toggleMultiSelectMute.label = gNavigatorBundle.getString("playTabs.label");
toggleMultiSelectMute.accessKey = gNavigatorBundle.getString("playTabs.accesskey");
} else if (this.contextTab.hasAttribute("muted")) {
toggleMultiSelectMute.label = gNavigatorBundle.getString("unmuteSelectedTabs.label");
toggleMultiSelectMute.accessKey = gNavigatorBundle.getString("unmuteSelectedTabs.accesskey");
} else {
toggleMultiSelectMute.label = gNavigatorBundle.getString("muteSelectedTabs.label");
toggleMultiSelectMute.accessKey = gNavigatorBundle.getString("muteSelectedTabs.accesskey");
}
this.contextTab.toggleMuteMenuItem = toggleMute;
this.contextTab.toggleMultiSelectMuteMenuItem = toggleMultiSelectMute;
this._updateToggleMuteMenuItems(this.contextTab);
this.contextTab.addEventListener("TabAttrModified", this);
aPopupMenu.addEventListener("popuphiding", this);
gSync.updateTabContextMenu(aPopupMenu, this.contextTab);
updateTabMenuUserContextUIVisibility("context_reopenInContainer");
},
handleEvent(aEvent) {
switch (aEvent.type) {
case "popuphiding":
gBrowser.removeEventListener("TabAttrModified", this);
aEvent.target.removeEventListener("popuphiding", this);
break;
case "TabAttrModified":
let tab = aEvent.target;
this._updateToggleMuteMenuItems(tab,
attr => aEvent.detail.changed.includes(attr));
break;
}
}
};
// Prompt user to restart the browser in safe mode
function safeModeRestart() {
if (Services.appinfo.inSafeMode) {

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

@ -114,8 +114,8 @@
label="&reopenInContainer.label;"
accesskey="&reopenInContainer.accesskey;"
hidden="true">
<menupopup oncommand="reopenInContainer(event);"
onpopupshowing="return createReopenInContainerMenu(event);" />
<menupopup oncommand="TabContextMenu.reopenInContainer(event);"
onpopupshowing="TabContextMenu.createReopenInContainerMenu(event);"/>
</menu>
<menuitem id="context_openTabInWindow" label="&moveToNewWindow.label;"
accesskey="&moveToNewWindow.accesskey;"

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

@ -4934,3 +4934,162 @@ var TabBarVisibility = {
TabsInTitlebar.allowedBy("tabs-visible", !collapse);
}
};
var TabContextMenu = {
contextTab: null,
_updateToggleMuteMenuItems(aTab, aConditionFn) {
["muted", "soundplaying"].forEach(attr => {
if (!aConditionFn || aConditionFn(attr)) {
if (aTab.hasAttribute(attr)) {
aTab.toggleMuteMenuItem.setAttribute(attr, "true");
aTab.toggleMultiSelectMuteMenuItem.setAttribute(attr, "true");
} else {
aTab.toggleMuteMenuItem.removeAttribute(attr);
aTab.toggleMultiSelectMuteMenuItem.removeAttribute(attr);
}
}
});
},
updateContextMenu(aPopupMenu) {
this.contextTab = aPopupMenu.triggerNode.localName == "tab" ?
aPopupMenu.triggerNode : gBrowser.selectedTab;
let disabled = gBrowser.tabs.length == 1;
let multiselectionContext = this.contextTab.multiselected;
var menuItems = aPopupMenu.getElementsByAttribute("tbattr", "tabbrowser-multiple");
for (let menuItem of menuItems) {
menuItem.disabled = disabled;
}
if (this.contextTab.hasAttribute("customizemode")) {
document.getElementById("context_openTabInWindow").disabled = true;
}
disabled = gBrowser.visibleTabs.length == 1;
menuItems = aPopupMenu.getElementsByAttribute("tbattr", "tabbrowser-multiple-visible");
for (let menuItem of menuItems) {
menuItem.disabled = disabled;
}
// Session store
document.getElementById("context_undoCloseTab").disabled =
SessionStore.getClosedTabCount(window) == 0;
// Only one of Reload_Tab/Reload_Selected_Tabs should be visible.
document.getElementById("context_reloadTab").hidden = multiselectionContext;
document.getElementById("context_reloadSelectedTabs").hidden = !multiselectionContext;
// Only one of pin/unpin/multiselect-pin/multiselect-unpin should be visible
let contextPinTab = document.getElementById("context_pinTab");
contextPinTab.hidden = this.contextTab.pinned || multiselectionContext;
let contextUnpinTab = document.getElementById("context_unpinTab");
contextUnpinTab.hidden = !this.contextTab.pinned || multiselectionContext;
let contextPinSelectedTabs = document.getElementById("context_pinSelectedTabs");
contextPinSelectedTabs.hidden = this.contextTab.pinned || !multiselectionContext;
let contextUnpinSelectedTabs = document.getElementById("context_unpinSelectedTabs");
contextUnpinSelectedTabs.hidden = !this.contextTab.pinned || !multiselectionContext;
// Disable "Close Tabs to the Right" if there are no tabs
// following it.
document.getElementById("context_closeTabsToTheEnd").disabled =
gBrowser.getTabsToTheEndFrom(this.contextTab).length == 0;
// Disable "Close other Tabs" if there are no unpinned tabs.
let unpinnedTabsToClose = gBrowser.visibleTabs.length - gBrowser._numPinnedTabs;
if (!this.contextTab.pinned) {
unpinnedTabsToClose--;
}
document.getElementById("context_closeOtherTabs").disabled = unpinnedTabsToClose < 1;
// Only one of close_tab/close_selected_tabs should be visible
document.getElementById("context_closeTab").hidden = multiselectionContext;
document.getElementById("context_closeSelectedTabs").hidden = !multiselectionContext;
// Hide "Bookmark All Tabs" for a pinned tab. Update its state if visible.
let bookmarkAllTabs = document.getElementById("context_bookmarkAllTabs");
bookmarkAllTabs.hidden = this.contextTab.pinned;
if (!bookmarkAllTabs.hidden) {
PlacesCommandHook.updateBookmarkAllTabsCommand();
}
let toggleMute = document.getElementById("context_toggleMuteTab");
let toggleMultiSelectMute = document.getElementById("context_toggleMuteSelectedTabs");
// Only one of mute_unmute_tab/mute_unmute_selected_tabs should be visible
toggleMute.hidden = multiselectionContext;
toggleMultiSelectMute.hidden = !multiselectionContext;
// Adjust the state of the toggle mute menu item.
if (this.contextTab.hasAttribute("activemedia-blocked")) {
toggleMute.label = gNavigatorBundle.getString("playTab.label");
toggleMute.accessKey = gNavigatorBundle.getString("playTab.accesskey");
} else if (this.contextTab.hasAttribute("muted")) {
toggleMute.label = gNavigatorBundle.getString("unmuteTab.label");
toggleMute.accessKey = gNavigatorBundle.getString("unmuteTab.accesskey");
} else {
toggleMute.label = gNavigatorBundle.getString("muteTab.label");
toggleMute.accessKey = gNavigatorBundle.getString("muteTab.accesskey");
}
// Adjust the state of the toggle mute menu item for multi-selected tabs.
if (this.contextTab.hasAttribute("activemedia-blocked")) {
toggleMultiSelectMute.label = gNavigatorBundle.getString("playTabs.label");
toggleMultiSelectMute.accessKey = gNavigatorBundle.getString("playTabs.accesskey");
} else if (this.contextTab.hasAttribute("muted")) {
toggleMultiSelectMute.label = gNavigatorBundle.getString("unmuteSelectedTabs.label");
toggleMultiSelectMute.accessKey = gNavigatorBundle.getString("unmuteSelectedTabs.accesskey");
} else {
toggleMultiSelectMute.label = gNavigatorBundle.getString("muteSelectedTabs.label");
toggleMultiSelectMute.accessKey = gNavigatorBundle.getString("muteSelectedTabs.accesskey");
}
this.contextTab.toggleMuteMenuItem = toggleMute;
this.contextTab.toggleMultiSelectMuteMenuItem = toggleMultiSelectMute;
this._updateToggleMuteMenuItems(this.contextTab);
this.contextTab.addEventListener("TabAttrModified", this);
aPopupMenu.addEventListener("popuphiding", this);
gSync.updateTabContextMenu(aPopupMenu, this.contextTab);
document.getElementById("context_reopenInContainer").hidden =
!Services.prefs.getBoolPref("privacy.userContext.enabled", false) ||
PrivateBrowsingUtils.isWindowPrivate(window);
},
handleEvent(aEvent) {
switch (aEvent.type) {
case "popuphiding":
gBrowser.removeEventListener("TabAttrModified", this);
aEvent.target.removeEventListener("popuphiding", this);
break;
case "TabAttrModified":
let tab = aEvent.target;
this._updateToggleMuteMenuItems(tab,
attr => aEvent.detail.changed.includes(attr));
break;
}
},
createReopenInContainerMenu(event) {
createUserContextMenu(event, {
isContextMenu: true,
excludeUserContextId: this.contextTab.getAttribute("usercontextid"),
});
},
reopenInContainer(event) {
let newTab = gBrowser.addTab(this.contextTab.linkedBrowser.currentURI.spec, {
userContextId: parseInt(event.target.getAttribute("data-usercontextid")),
pinned: this.contextTab.pinned,
index: this.contextTab._tPos + 1,
});
if (gBrowser.selectedTab == this.contextTab) {
gBrowser.selectedTab = newTab;
}
if (this.contextTab.muted) {
if (!newTab.muted) {
newTab.toggleMuteAudio(this.contextTab.muteReason);
}
}
}
};

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

@ -56,10 +56,8 @@
// Ignore overflow events:
// - from nested scrollable elements
// - for vertical orientation
// - when the window is tiny initially
if (event.originalTarget != this._scrollbox ||
event.detail == 0 ||
window.outerWidth <= 1) {
event.detail == 0) {
return;
}

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

@ -18,7 +18,7 @@ function updateTabContextMenu(tab) {
var evt = new Event("");
tab.dispatchEvent(evt);
menu.openPopup(tab, "end_after", 0, 0, true, false, evt);
is(TabContextMenu.contextTab, tab, "TabContextMenu context is the expected tab");
is(window.TabContextMenu.contextTab, tab, "TabContextMenu context is the expected tab");
menu.hidePopup();
}

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

@ -5,7 +5,7 @@ function updateTabContextMenu(tab) {
var evt = new Event("");
tab.dispatchEvent(evt);
menu.openPopup(tab, "end_after", 0, 0, true, false, evt);
is(TabContextMenu.contextTab, tab, "TabContextMenu context is the expected tab");
is(window.TabContextMenu.contextTab, tab, "TabContextMenu context is the expected tab");
menu.hidePopup();
}

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

@ -65,29 +65,33 @@ function executeSoon(fn) {
// We wait 3 seconds, just to be safe.
//
function checkWatchdog(expectInterrupt, continuation) {
function checkWatchdog(expectInterrupt) {
var oldTimeout = setScriptTimeout(1);
var lastWatchdogWakeup = Cu.getWatchdogTimestamp("WatchdogWakeup");
setInterruptCallback(function() {
// If the watchdog didn't actually trigger the operation callback, ignore
// this call. This allows us to test the actual watchdog behavior without
// interference from other sites where we trigger the operation callback.
if (lastWatchdogWakeup == Cu.getWatchdogTimestamp("WatchdogWakeup")) {
return true;
}
Assert.ok(expectInterrupt);
setInterruptCallback(undefined);
setScriptTimeout(oldTimeout);
// Schedule our continuation before we kill this script.
executeSoon(continuation);
return false;
});
executeSoon(function() {
busyWait(3000);
Assert.ok(!expectInterrupt);
setInterruptCallback(undefined);
setScriptTimeout(oldTimeout);
continuation();
return new Promise(resolve => {
setInterruptCallback(function() {
// If the watchdog didn't actually trigger the operation callback, ignore
// this call. This allows us to test the actual watchdog behavior without
// interference from other sites where we trigger the operation callback.
if (lastWatchdogWakeup == Cu.getWatchdogTimestamp("WatchdogWakeup")) {
return true;
}
Assert.ok(expectInterrupt, "Interrupt callback fired");
setInterruptCallback(undefined);
setScriptTimeout(oldTimeout);
// Schedule the promise for resolution before we kill this script.
executeSoon(resolve);
return false;
});
executeSoon(function() {
busyWait(3000);
Assert.ok(!expectInterrupt, "Interrupt callback didn't fire");
setInterruptCallback(undefined);
setScriptTimeout(oldTimeout);
resolve();
});
});
}

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

@ -2,8 +2,8 @@
* 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/. */
async function testBody() {
function testBody() {
// Check that we properly implement whatever behavior is specified by the
// default profile for this configuration.
await checkWatchdog(isWatchdogEnabled());
return checkWatchdog(isWatchdogEnabled());
}

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

@ -2,7 +2,7 @@
* 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/. */
async function testBody() {
function testBody() {
setWatchdogEnabled(false);
await checkWatchdog(false);
return checkWatchdog(false);
}

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

@ -2,7 +2,7 @@
* 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/. */
async function testBody() {
function testBody() {
setWatchdogEnabled(true);
await checkWatchdog(true);
return checkWatchdog(true);
}

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

@ -15,8 +15,8 @@ async function testBody() {
do_log_info("now: " + now / 1000000);
do_log_info("startHibernation: " + startHibernation / 1000000);
do_log_info("stopHibernation: " + stopHibernation / 1000000);
Assert.ok(startHibernation < now);
Assert.ok(stopHibernation < now);
Assert.ok(startHibernation < now, "startHibernation ok");
Assert.ok(stopHibernation < now, "stopHibernation ok");
// When the watchdog runs, it hibernates if there's been no activity for the
// last 2 seconds, otherwise it sleeps for 1 second. As such, given perfect
@ -44,8 +44,8 @@ async function testBody() {
// making sure this behavior is roughly as expected on the macro scale,
// so we add a 1 second fuzz factor here.
const FUZZ_FACTOR = 1 * 1000 * 1000;
Assert.ok(stateChange > now + 10*1000*1000 - FUZZ_FACTOR);
Assert.ok(startHibernation > now + 2*1000*1000 - FUZZ_FACTOR);
Assert.ok(startHibernation < now + 5*1000*1000 + FUZZ_FACTOR);
Assert.ok(stopHibernation > now + 10*1000*1000 - FUZZ_FACTOR);
Assert.ok(stateChange > now + 10*1000*1000 - FUZZ_FACTOR, "stateChange ok");
Assert.ok(startHibernation > now + 2*1000*1000 - FUZZ_FACTOR, "startHibernation ok");
Assert.ok(startHibernation < now + 5*1000*1000 + FUZZ_FACTOR, "startHibernation ok");
Assert.ok(stopHibernation > now + 10*1000*1000 - FUZZ_FACTOR, "stopHibernation ok");
}

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

@ -2,9 +2,9 @@
* 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/. */
async function testBody() {
function testBody() {
var defaultBehavior = isWatchdogEnabled();
setWatchdogEnabled(!defaultBehavior);
setWatchdogEnabled(defaultBehavior);
await checkWatchdog(defaultBehavior);
return checkWatchdog(defaultBehavior);
}

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

@ -9838,6 +9838,8 @@ PaintTelemetry::AutoRecordPaint::~AutoRecordPaint()
recordSmall(NS_LITERAL_CSTRING("fr"), frMs);
recordSmall(NS_LITERAL_CSTRING("r"), rMs);
}
Telemetry::Accumulate(Telemetry::PAINT_BUILD_LAYERS_TIME, flbMs);
}
PaintTelemetry::AutoRecord::AutoRecord(Metric aMetric)

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

@ -3381,6 +3381,16 @@
"high": 1000,
"n_buckets": 50
},
"PAINT_BUILD_LAYERS_TIME" : {
"record_in_processes": ["content"],
"alert_emails": ["gfx-telemetry-alerts@mozilla.com","mwoodrow@mozilla.com"],
"bug_numbers": [1473908],
"expires_in_version": "never",
"description": "Time spent in building layers in milliseconds",
"kind": "exponential",
"high": 1000,
"n_buckets": 50
},
"PAINT_RASTERIZE_TIME" : {
"record_in_processes": ["main", "content"],
"expires_in_version": "never",

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

@ -570,9 +570,7 @@
<handler event="overflow" phase="capturing"><![CDATA[
// Ignore overflow events:
// - from nested scrollable elements
// - when the window is tiny initially
if (event.target != this ||
window.outerWidth <= 1) {
if (event.target != this) {
return;
}