зеркало из https://github.com/mozilla/gecko-dev.git
Bug 1398992 = Make 'Recently Bookmarked' in Photon panels support browser.bookmarks.openInTabClosesMenu pref. r=jaws
MozReview-Commit-ID: 3Rio9EjwilT --HG-- extra : rebase_source : dde522b0eb65b22ee74d8dfb6d5f1d1a5489237f
This commit is contained in:
Родитель
be5209e3f2
Коммит
a33fa6a1f2
|
@ -36,7 +36,7 @@ add_task(async function() {
|
|||
let historyItems = document.getElementById("appMenu_historyMenu");
|
||||
let historyItemForURL = historyItems.querySelector("toolbarbutton.bookmark-item[label='Happy History Hero']");
|
||||
ok(historyItemForURL, "Should have a history item for the history we just made.");
|
||||
historyItemForURL.click();
|
||||
EventUtils.synthesizeMouseAtCenter(historyItemForURL, {});
|
||||
await browserLoaded;
|
||||
is(gBrowser.currentURI.spec, TEST_PATH + "dummy_history_item.html", "Should have expected page load");
|
||||
|
||||
|
|
|
@ -2124,8 +2124,8 @@ this.PlacesPanelview = class extends PlacesViewBase {
|
|||
handleEvent(event) {
|
||||
switch (event.type) {
|
||||
case "click":
|
||||
// For left and middle clicks, fall through to the command handler.
|
||||
if (event.button >= 2) {
|
||||
// For middle clicks, fall through to the command handler.
|
||||
if (event.button != 1) {
|
||||
break;
|
||||
}
|
||||
case "command":
|
||||
|
@ -2154,9 +2154,23 @@ this.PlacesPanelview = class extends PlacesViewBase {
|
|||
if (!button._placesNode)
|
||||
return;
|
||||
|
||||
let modifKey = AppConstants.platform === "macosx" ? event.metaKey
|
||||
: event.ctrlKey;
|
||||
if (!PlacesUIUtils.openInTabClosesMenu && modifKey) {
|
||||
// If 'Recent Bookmarks' in Bookmarks Panel.
|
||||
if (button.parentNode.id == "panelMenu_bookmarksMenu") {
|
||||
button.setAttribute("closemenu", "none");
|
||||
}
|
||||
} else {
|
||||
button.removeAttribute("closemenu");
|
||||
}
|
||||
PlacesUIUtils.openNodeWithEvent(button._placesNode, event);
|
||||
// Unlike left-click, middle-click requires manual menu closing.
|
||||
if (button.parentNode.id != "panelMenu_bookmarksMenu" ||
|
||||
(event.type == "click" && event.button == 1 && PlacesUIUtils.openInTabClosesMenu)) {
|
||||
this.panelMultiView.closest("panel").hidePopup();
|
||||
}
|
||||
}
|
||||
|
||||
_onDragEnd() {
|
||||
this._draggedElt = null;
|
||||
|
|
|
@ -5,20 +5,14 @@
|
|||
// and contextmenu's "Open in a new tab" click.
|
||||
|
||||
async function locateBookmarkAndTestCtrlClick(menupopup) {
|
||||
let menuitem = null;
|
||||
for (let node of menupopup.childNodes) {
|
||||
if (node.label == "Test1") {
|
||||
menuitem = node;
|
||||
let testMenuitem = [...menupopup.childNodes].find(node => node.label == "Test1");
|
||||
ok(testMenuitem, "Found test bookmark.");
|
||||
let promiseTabOpened = BrowserTestUtils.waitForNewTab(gBrowser, null);
|
||||
EventUtils.synthesizeMouseAtCenter(menuitem,
|
||||
AppConstants.platform === "macosx" ? {metaKey: true} : {ctrlKey: true});
|
||||
EventUtils.synthesizeMouseAtCenter(testMenuitem, {accelKey: true});
|
||||
let newTab = await promiseTabOpened;
|
||||
ok(true, "Bookmark ctrl-click opened new tab.");
|
||||
await BrowserTestUtils.removeTab(newTab);
|
||||
break;
|
||||
}
|
||||
}
|
||||
return menuitem;
|
||||
return testMenuitem;
|
||||
}
|
||||
|
||||
async function testContextmenu(menuitem) {
|
||||
|
@ -122,6 +116,43 @@ add_task(async function testStayopenBookmarksClicks() {
|
|||
info("Closing menu");
|
||||
await BrowserTestUtils.removeTab(newTab);
|
||||
|
||||
// Test App Menu's Bookmarks Library stayopen clicks.
|
||||
let appMenu = document.getElementById("PanelUI-menu-button");
|
||||
let appMenuPopup = document.getElementById("appMenu-popup");
|
||||
let PopupShownPromise = BrowserTestUtils.waitForEvent(appMenuPopup, "popupshown");
|
||||
appMenu.click();
|
||||
await PopupShownPromise;
|
||||
let libView = document.getElementById("appMenu-libraryView");
|
||||
let libraryBtn = document.getElementById("appMenu-library-button");
|
||||
let ViewShownPromise = BrowserTestUtils.waitForEvent(libView, "ViewShown");
|
||||
libraryBtn.click();
|
||||
await ViewShownPromise;
|
||||
info("Library panel shown.");
|
||||
let bookmarks = document.getElementById("appMenu-library-bookmarks-button");
|
||||
let BMview = document.getElementById("PanelUI-bookmarks");
|
||||
ViewShownPromise = BrowserTestUtils.waitForEvent(BMview, "ViewShown");
|
||||
bookmarks.click();
|
||||
await ViewShownPromise;
|
||||
info("Library's bookmarks panel shown.");
|
||||
|
||||
// Test App Menu's Bookmarks Library stayopen clicks: Ctrl-click.
|
||||
let menu = document.getElementById("panelMenu_bookmarksMenu");
|
||||
var testMenuitem = await locateBookmarkAndTestCtrlClick(menu);
|
||||
ok(appMenu.open, "Menu should remain open.");
|
||||
|
||||
// Test App Menu's Bookmarks Library stayopen clicks: middle-click.
|
||||
promiseTabOpened = BrowserTestUtils.waitForNewTab(gBrowser, null);
|
||||
EventUtils.synthesizeMouseAtCenter(testMenuitem, {button: 1});
|
||||
newTab = await promiseTabOpened;
|
||||
ok(true, "Bookmark middle-click opened new tab.");
|
||||
await BrowserTestUtils.removeTab(newTab);
|
||||
is(PanelUI.multiView.current.id, "PanelUI-bookmarks", "Should still show the bookmarks subview");
|
||||
ok(appMenu.open, "Menu should remain open.");
|
||||
|
||||
// Close the App Menu
|
||||
appMenuPopup.hidePopup();
|
||||
ok(!appMenu.open, "The menu should now be closed.");
|
||||
|
||||
// Disable the rest of the tests on Mac due to Mac's handling of menus being
|
||||
// slightly different to the other platforms.
|
||||
if (AppConstants.platform === "macosx") {
|
||||
|
|
Загрузка…
Ссылка в новой задаче