Skip to content

Commit

Permalink
merge mozilla-inbound to mozilla-central a=merge
Browse files Browse the repository at this point in the history
  • Loading branch information
IrisHsiao committed May 2, 2017
2 parents d40a383 + 30484a2 commit 1401934
Show file tree
Hide file tree
Showing 65 changed files with 823 additions and 200 deletions.
35 changes: 27 additions & 8 deletions browser/base/content/browser.js
Original file line number Diff line number Diff line change
Expand Up @@ -4302,6 +4302,8 @@ function updateEditUIVisibility() {
let contextMenuPopupState = document.getElementById("contentAreaContextMenu").state;
let placesContextMenuPopupState = document.getElementById("placesContext").state;

let oldVisible = gEditUIVisible;

// The UI is visible if the Edit menu is opening or open, if the context menu
// is open, or if the toolbar has been customized to include the Cut, Copy,
// or Paste toolbar buttons.
Expand All @@ -4310,18 +4312,35 @@ function updateEditUIVisibility() {
contextMenuPopupState == "showing" ||
contextMenuPopupState == "open" ||
placesContextMenuPopupState == "showing" ||
placesContextMenuPopupState == "open" ||
document.getElementById("edit-controls") ? true : false;
placesContextMenuPopupState == "open";
if (!gEditUIVisible) {
// Now check the edit-controls toolbar buttons.
let placement = CustomizableUI.getPlacementOfWidget("edit-controls");
let areaType = placement ? CustomizableUI.getAreaType(placement.area) : "";
if (areaType == CustomizableUI.TYPE_MENU_PANEL) {
let panelUIMenuPopupState = document.getElementById("PanelUI-popup").state;
if (panelUIMenuPopupState == "showing" || panelUIMenuPopupState == "open") {
gEditUIVisible = true;
}
} else if (areaType == CustomizableUI.TYPE_TOOLBAR) {
// The edit controls are on a toolbar, so they are visible.
gEditUIVisible = true;
}
}

// No need to update commands if the edit UI visibility has not changed.
if (gEditUIVisible == oldVisible) {
return;
}

// If UI is visible, update the edit commands' enabled state to reflect
// whether or not they are actually enabled for the current focus/selection.
if (gEditUIVisible)
if (gEditUIVisible) {
goUpdateGlobalEditMenuItems();

// Otherwise, enable all commands, so that keyboard shortcuts still work,
// then lazily determine their actual enabled state when the user presses
// a keyboard shortcut.
else {
} else {
// Otherwise, enable all commands, so that keyboard shortcuts still work,
// then lazily determine their actual enabled state when the user presses
// a keyboard shortcut.
goSetCommandEnabled("cmd_undo", true);
goSetCommandEnabled("cmd_redo", true);
goSetCommandEnabled("cmd_cut", true);
Expand Down
6 changes: 6 additions & 0 deletions browser/base/content/tabbrowser.xml
Original file line number Diff line number Diff line change
Expand Up @@ -1065,6 +1065,8 @@
return;
if (!aForceUpdate) {
document.commandDispatcher.lock();
TelemetryStopwatch.start("FX_TAB_SWITCH_UPDATE_MS");
if (!gMultiProcessBrowser) {
// old way of measuring tab paint which is not valid with e10s.
Expand Down Expand Up @@ -1274,6 +1276,8 @@
this.tabContainer._setPositionalAttributes();
if (!gMultiProcessBrowser) {
document.commandDispatcher.unlock();
let event = new CustomEvent("TabSwitchDone", {
bubbles: true,
cancelable: true
Expand Down Expand Up @@ -3981,6 +3985,8 @@
fromBrowser.removeAttribute("primary");
}
document.commandDispatcher.unlock();
let event = new CustomEvent("TabSwitchDone", {
bubbles: true,
cancelable: true
Expand Down
1 change: 1 addition & 0 deletions browser/base/content/test/tabs/browser.ini
Original file line number Diff line number Diff line change
Expand Up @@ -16,4 +16,5 @@ skip-if = os == 'mac'
skip-if = !e10s # Pref and test only relevant for e10s.
[browser_opened_file_tab_navigated_to_web.js]
[browser_reload_deleted_file.js]
[browser_tabswitch_updatecommands.js]
[browser_viewsource_of_data_URI_in_file_process.js]
21 changes: 21 additions & 0 deletions browser/base/content/test/tabs/browser_tabswitch_updatecommands.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
// This test ensures that only one command update happens when switching tabs.

"use strict";

add_task(function* () {
const uri = "data:text/html,<body><input>";
let tab1 = yield BrowserTestUtils.openNewForegroundTab(gBrowser, uri);
let tab2 = yield BrowserTestUtils.openNewForegroundTab(gBrowser, uri);

let updates = 0;
function countUpdates(event) { updates++; }
let updater = document.getElementById("editMenuCommandSetAll");
updater.addEventListener("commandupdate", countUpdates, true);
yield BrowserTestUtils.switchTab(gBrowser, tab1);

is(updates, 1, "only one command update per tab switch");

updater.removeEventListener("commandupdate", countUpdates, true);
yield BrowserTestUtils.removeTab(tab1);
yield BrowserTestUtils.removeTab(tab2);
});
9 changes: 4 additions & 5 deletions browser/components/customizableui/content/panelUI.js
Original file line number Diff line number Diff line change
Expand Up @@ -160,11 +160,6 @@ const PanelUI = {
return;
}

let editControlPlacement = CustomizableUI.getPlacementOfWidget("edit-controls");
if (editControlPlacement && editControlPlacement.area == CustomizableUI.AREA_PANEL) {
updateEditUIVisibility();
}

let personalBookmarksPlacement = CustomizableUI.getPlacementOfWidget("personal-bookmarks");
if (personalBookmarksPlacement &&
personalBookmarksPlacement.area == CustomizableUI.AREA_PANEL) {
Expand Down Expand Up @@ -292,10 +287,14 @@ const PanelUI = {
switch (aEvent.type) {
case "popupshowing":
this._adjustLabelsForAutoHyphens();
updateEditUIVisibility();
// Fall through
case "popupshown":
// Fall through
case "popuphiding":
if (aEvent.type == "popuphiding") {
updateEditUIVisibility();
}
// Fall through
case "popuphidden":
this._updateNotifications();
Expand Down
2 changes: 2 additions & 0 deletions browser/components/customizableui/test/browser.ini
Original file line number Diff line number Diff line change
Expand Up @@ -155,3 +155,5 @@ skip-if = os == "mac"
[browser_switch_to_customize_mode.js]
[browser_synced_tabs_menu.js]
[browser_check_tooltips_in_navbar.js]
[browser_editcontrols_update.js]
subsuite = clipboard
162 changes: 162 additions & 0 deletions browser/components/customizableui/test/browser_editcontrols_update.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,162 @@
// This test checks that the edit command enabled state (cut/paste) is updated
// properly when the edit controls are on the toolbar, popup and not present.
// It also verifies that the performance optimiation implemented by
// updateEditUIVisibility in browser.js is applied.

let isMac = navigator.platform.indexOf("Mac") == 0;

function checkState(allowCut, desc, testWindow = window) {
is(testWindow.document.getElementById("cmd_cut").getAttribute("disabled") == "true", !allowCut, desc + " - cut");
is(testWindow.document.getElementById("cmd_paste").getAttribute("disabled") == "true", false, desc + " - paste");
}

// Add a special controller to the urlbar and browser to listen in on when
// commands are being updated. Return a promise that resolves when 'count'
// updates have occurred.
function expectCommandUpdate(count, testWindow = window) {
return new Promise((resolve, reject) => {
let overrideController = {
supportsCommand(cmd) { return cmd == "cmd_delete"; },
isCommandEnabled(cmd) {
if (!count) {
ok(false, "unexpected update");
reject();
}

if (!--count) {
testWindow.gURLBar.controllers.removeControllerAt(0, overrideController);
testWindow.gBrowser.selectedBrowser.controllers.removeControllerAt(0, overrideController);
resolve(true);
}
}
};

if (!count) {
SimpleTest.executeSoon(() => {
testWindow.gURLBar.controllers.removeControllerAt(0, overrideController);
testWindow.gBrowser.selectedBrowser.controllers.removeControllerAt(0, overrideController);
resolve(false);
});
}

testWindow.gURLBar.controllers.insertControllerAt(0, overrideController);
testWindow.gBrowser.selectedBrowser.controllers.insertControllerAt(0, overrideController);
});
}

add_task(function* test_init() {
// Put something on the clipboard to verify that the paste button is properly enabled during the test.
let clipboardHelper = Cc["@mozilla.org/widget/clipboardhelper;1"].getService(Ci.nsIClipboardHelper);
yield new Promise(resolve => {
SimpleTest.waitForClipboard("Sample", function() { clipboardHelper.copyString("Sample"); }, resolve);
});

// Open and close the panel first so that it is fully initialized.
yield PanelUI.show();
let hiddenPromise = promisePanelHidden(window);
PanelUI.hide();
yield hiddenPromise;
});

// Test updating when the panel is open with the edit-controls on the panel.
// Updates should occur.
add_task(function* test_panelui_opened() {
gURLBar.focus();
gURLBar.value = "test";

yield PanelUI.show();

checkState(false, "Update when edit-controls is on panel and visible");

let overridePromise = expectCommandUpdate(1);
gURLBar.select();
yield overridePromise;

checkState(true, "Update when edit-controls is on panel and selection changed");

overridePromise = expectCommandUpdate(0);
let hiddenPromise = promisePanelHidden(window);
PanelUI.hide();
yield hiddenPromise;
yield overridePromise;

// Check that updates do not occur after the panel has been closed.
checkState(true, "Update when edit-controls is on panel and hidden");

// Mac will update the enabled st1ate even when the panel is closed so that
// main menubar shortcuts will work properly.
overridePromise = expectCommandUpdate(isMac ? 1 : 0);
gURLBar.select();
yield overridePromise;
checkState(true, "Update when edit-controls is on panel, hidden and selection changed");
});

// Test updating when the edit-controls are moved to the toolbar.
add_task(function* test_panelui_customize_to_toolbar() {
yield startCustomizing();
let navbar = document.getElementById("nav-bar").customizationTarget;
simulateItemDrag(document.getElementById("edit-controls"), navbar);
yield endCustomizing();

// updateEditUIVisibility should be called when customization ends but isn't. See bug 1359790.
updateEditUIVisibility();

let overridePromise = expectCommandUpdate(1);
gURLBar.select();
gURLBar.focus();
gURLBar.value = "other";
yield overridePromise;
checkState(false, "Update when edit-controls on toolbar and focused");

overridePromise = expectCommandUpdate(1);
gURLBar.select();
yield overridePromise;
checkState(true, "Update when edit-controls on toolbar and selection changed");
});

// Test updating when the edit-controls are moved to the palette.
add_task(function* test_panelui_customize_to_palette() {
yield startCustomizing();
let palette = document.getElementById("customization-palette");
simulateItemDrag(document.getElementById("edit-controls"), palette);
yield endCustomizing();

// updateEditUIVisibility should be called when customization ends but isn't. See bug 1359790.
updateEditUIVisibility();

let overridePromise = expectCommandUpdate(isMac ? 1 : 0);
gURLBar.focus();
gURLBar.value = "other";
gURLBar.select();
yield overridePromise;

// If the UI isn't found, the command is set to be enabled.
checkState(true, "Update when edit-controls is on palette, hidden and selection changed");
});

add_task(function* finish() {
yield resetCustomization();
});

// Test updating in the initial state when the edit-controls are on the panel but
// have not yet been created. This needs to be done in a new window to ensure that
// other tests haven't opened the panel.
add_task(function* test_initial_state() {
let testWindow = yield BrowserTestUtils.openNewBrowserWindow();
yield SimpleTest.promiseFocus(testWindow);

let overridePromise = expectCommandUpdate(isMac, testWindow);

testWindow.gURLBar.focus();
testWindow.gURLBar.value = "test";

yield overridePromise;

// Commands won't update when no edit UI is present. They default to being
// enabled so that keyboard shortcuts will work. The real enabled state will
// be checked when shortcut is pressed.
checkState(!isMac, "No update when edit-controls is on panel and not visible", testWindow);

yield BrowserTestUtils.closeWindow(testWindow);
yield SimpleTest.promiseFocus(window);
});
2 changes: 2 additions & 0 deletions browser/config/mozconfigs/linux32/devedition
Original file line number Diff line number Diff line change
Expand Up @@ -12,5 +12,7 @@ STRIP_FLAGS="--strip-debug"

ac_add_options --with-branding=browser/branding/aurora

mk_add_options MOZ_PGO=1

. "$topsrcdir/build/mozconfig.common.override"
. "$topsrcdir/build/mozconfig.cache"
2 changes: 2 additions & 0 deletions browser/config/mozconfigs/linux64/devedition
Original file line number Diff line number Diff line change
Expand Up @@ -12,5 +12,7 @@ STRIP_FLAGS="--strip-debug"

ac_add_options --with-branding=browser/branding/aurora

mk_add_options MOZ_PGO=1

. "$topsrcdir/build/mozconfig.common.override"
. "$topsrcdir/build/mozconfig.cache"
2 changes: 2 additions & 0 deletions browser/config/mozconfigs/win32/devedition
Original file line number Diff line number Diff line change
Expand Up @@ -8,5 +8,7 @@ ac_add_options --enable-verify-mar

ac_add_options --with-branding=browser/branding/aurora

mk_add_options MOZ_PGO=1

. "$topsrcdir/build/mozconfig.common.override"
. "$topsrcdir/build/mozconfig.cache"
2 changes: 2 additions & 0 deletions browser/config/mozconfigs/win64/devedition
Original file line number Diff line number Diff line change
Expand Up @@ -9,5 +9,7 @@ ac_add_options --enable-verify-mar

ac_add_options --with-branding=browser/branding/aurora

mk_add_options MOZ_PGO=1

. "$topsrcdir/build/mozconfig.common.override"
. "$topsrcdir/build/mozconfig.cache"
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,8 @@ function setConditionalBreakpoint(dbg, index, condition) {
selectMenuItem(dbg, 2);
yield waitForElement(dbg, ".conditional-breakpoint-panel input");
findElementWithSelector(dbg, ".conditional-breakpoint-panel input").focus();
// Position cursor reliably at the end of the text.
pressKey(dbg, "End")
type(dbg, condition);
pressKey(dbg, "Enter");
});
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,8 @@ async function addExpression(dbg, input) {
async function editExpression(dbg, input) {
info("updating the expression");
dblClickElement(dbg, "expressionNode", 1);
// Position cursor reliably at the end of the text.
pressKey(dbg, "End")
type(dbg, input);
pressKey(dbg, "Enter");
await waitForDispatch(dbg, "EVALUATE_EXPRESSION");
Expand Down
4 changes: 4 additions & 0 deletions devtools/client/debugger/new/test/mochitest/head.js
Original file line number Diff line number Diff line change
Expand Up @@ -560,6 +560,10 @@ const keyMappings = {
Enter: { code: "VK_RETURN" },
Up: { code: "VK_UP" },
Down: { code: "VK_DOWN" },
Right: { code: "VK_RIGHT" },
Left: { code: "VK_LEFT" },
End: { code: "VK_RIGHT", modifiers: cmdOrCtrl },
Start: { code: "VK_LEFT", modifiers: cmdOrCtrl },
Tab: { code: "VK_TAB" },
Escape: { code: "VK_ESCAPE" },
pauseKey: { code: "VK_F8" },
Expand Down
5 changes: 5 additions & 0 deletions dom/base/nsContentUtils.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -297,6 +297,7 @@ bool nsContentUtils::sUseActivityCursor = false;
bool nsContentUtils::sAnimationsAPICoreEnabled = false;
bool nsContentUtils::sAnimationsAPIElementAnimateEnabled = false;
bool nsContentUtils::sGetBoxQuadsEnabled = false;
bool nsContentUtils::sSkipCursorMoveForSameValueSet = false;

int32_t nsContentUtils::sPrivacyMaxInnerWidth = 1000;
int32_t nsContentUtils::sPrivacyMaxInnerHeight = 1000;
Expand Down Expand Up @@ -645,6 +646,10 @@ nsContentUtils::Init()
Preferences::AddBoolVarCache(&sGetBoxQuadsEnabled,
"layout.css.getBoxQuads.enabled", false);

Preferences::AddBoolVarCache(&sSkipCursorMoveForSameValueSet,
"dom.input.skip_cursor_move_for_same_value_set",
true);

Element::InitCCCallbacks();

nsCOMPtr<nsIUUIDGenerator> uuidGenerator =
Expand Down
Loading

0 comments on commit 1401934

Please sign in to comment.