Backed out changeset 81a6b32f2a8b (bug 1435562) for causing Bug 1512180. a=backout

This commit is contained in:
Csoregi Natalia 2018-12-06 14:20:20 +02:00
parent adec563403
commit 322dfaf9c2
7 changed files with 26 additions and 174 deletions

View File

@ -748,7 +748,7 @@ var BookmarksEventHandler = {
// is middle-clicked or when a non-bookmark item (except for Open in Tabs)
// in a bookmarks menupopup is middle-clicked.
if (target.localName == "menu" || target.localName == "toolbarbutton")
PlacesUIUtils.openMultipleLinksInTabs(target._placesNode, aEvent, aView);
PlacesUIUtils.openContainerNodeInTabs(target._placesNode, aEvent, aView);
} else if (aEvent.button == 1) {
// left-clicks with modifier are already served by onCommand
this.onCommand(aEvent);

View File

@ -626,38 +626,28 @@ var PlacesUIUtils = {
});
},
/**
* Loads a selected node's or nodes' URLs in tabs,
* warning the user when lots of URLs are being opened
*
* @param {object|array} nodeOrNodes
* Contains the node or nodes that we're opening in tabs
* @param {event} event
* The DOM mouse/key event with modifier keys set that track the
* user's preferred destination window or tab.
* @param {object} view
* The current view that contains the node or nodes selected for
* opening
*/
openMultipleLinksInTabs(nodeOrNodes, event, view) {
let window = view.ownerWindow;
let urlsToOpen = [];
openContainerNodeInTabs:
function PUIU_openContainerInTabs(aNode, aEvent, aView) {
let window = aView.ownerWindow;
if (PlacesUtils.nodeIsContainer(nodeOrNodes)) {
urlsToOpen = PlacesUtils.getURLsForContainerNode(nodeOrNodes);
} else {
for (var i = 0; i < nodeOrNodes.length; i++) {
// Skip over separators and folders.
if (PlacesUtils.nodeIsURI(nodeOrNodes[i])) {
urlsToOpen.push({uri: nodeOrNodes[i].uri, isBookmark: PlacesUtils.nodeIsBookmark(nodeOrNodes[i])});
}
}
}
let urlsToOpen = PlacesUtils.getURLsForContainerNode(aNode);
if (OpenInTabsUtils.confirmOpenInTabs(urlsToOpen.length, window)) {
this._openTabset(urlsToOpen, event, window);
this._openTabset(urlsToOpen, aEvent, window);
}
},
openURINodesInTabs: function PUIU_openURINodesInTabs(aNodes, aEvent, aView) {
let window = aView.ownerWindow;
let urlsToOpen = [];
for (var i = 0; i < aNodes.length; i++) {
// Skip over separators and folders.
if (PlacesUtils.nodeIsURI(aNodes[i]))
urlsToOpen.push({uri: aNodes[i].uri, isBookmark: PlacesUtils.nodeIsBookmark(aNodes[i])});
}
this._openTabset(urlsToOpen, aEvent, window);
},
/**
* Loads the node's URL in the appropriate tab or window given the
* user's preference specified by modifier keys tracked by a
@ -966,7 +956,7 @@ var PlacesUIUtils = {
} else if (!mouseInGutter && openInTabs &&
event.originalTarget.localName == "treechildren") {
tbo.view.selection.select(cell.row);
this.openMultipleLinksInTabs(tree.selectedNode, event, tree);
this.openContainerNodeInTabs(tree.selectedNode, event, tree);
} else if (!mouseInGutter && !isContainer &&
event.originalTarget.localName == "treechildren") {
// Clear all other selection since we're loading a link now. We must

View File

@ -646,7 +646,10 @@ PlacesController.prototype = {
if (!node && !nodes.length) {
node = this._view.result.root;
}
PlacesUIUtils.openMultipleLinksInTabs(node ? node : nodes, aEvent, this._view);
if (node && PlacesUtils.nodeIsContainer(node))
PlacesUIUtils.openContainerNodeInTabs(node, aEvent, this._view);
else
PlacesUIUtils.openURINodesInTabs(nodes, aEvent, this._view);
},
/**

View File

@ -353,7 +353,7 @@ var PlacesOrganizer = {
// The command execution function will take care of seeing if the
// selection is a folder or a different container type, and will
// load its contents in tabs.
PlacesUIUtils.openMultipleLinksInTabs(node, aEvent, this._places);
PlacesUIUtils.openContainerNodeInTabs(node, aEvent, this._places);
}
}
},
@ -1295,7 +1295,7 @@ var ContentTree = {
// The command execution function will take care of seeing if the
// selection is a folder or a different container type, and will
// load its contents in tabs.
PlacesUIUtils.openMultipleLinksInTabs(node, aEvent, this.view);
PlacesUIUtils.openContainerNodeInTabs(node, aEvent, this.view);
}
}
},

View File

@ -73,7 +73,6 @@ skip-if = (verify && debug && (os == 'mac' || os == 'linux'))
[browser_library_panel_leak.js]
[browser_library_search.js]
[browser_library_views_liveupdate.js]
[browser_library_warnOnOpen.js]
[browser_markPageAsFollowedLink.js]
[browser_panelview_bookmarks_delete.js]
[browser_paste_bookmarks.js]

View File

@ -1,140 +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/. */
/*
* Bug 1435562 - Test that browser.tabs.warnOnOpen is respected when
* opening multiple items from the Library. */
"use strict";
var gLibrary = null;
add_task(async function setup() {
// Temporarily disable history, so we won't record pages navigation.
await SpecialPowers.pushPrefEnv({set: [
["places.history.enabled", false],
]});
// Open Library window.
gLibrary = await promiseLibrary();
registerCleanupFunction(async () => {
// We must close "Other Bookmarks" ready for other tests.
gLibrary.PlacesOrganizer.selectLeftPaneBuiltIn("UnfiledBookmarks");
gLibrary.PlacesOrganizer._places.selectedNode.containerOpen = false;
await PlacesUtils.bookmarks.eraseEverything();
// Close Library window.
await promiseLibraryClosed(gLibrary);
});
});
add_task(async function test_warnOnOpenFolder() {
// Generate a list of links larger than browser.tabs.maxOpenBeforeWarn
const MAX_LINKS = 16;
let children = [];
for (let i = 0; i < MAX_LINKS; i++) {
children.push({
title: `Folder Target ${i}`,
url: `http://example${i}.com`,
});
}
// Create a new folder containing our links.
await PlacesUtils.bookmarks.insertTree({
guid: PlacesUtils.bookmarks.unfiledGuid,
children: [{
title: "bigFolder",
type: PlacesUtils.bookmarks.TYPE_FOLDER,
children,
}],
});
info("Pushed test folder into the bookmarks tree");
// Select unsorted bookmarks root in the left pane.
gLibrary.PlacesOrganizer.selectLeftPaneBuiltIn("UnfiledBookmarks");
info("Got selection in the Library left pane");
// Get our bookmark in the right pane.
gLibrary.ContentTree.view.view.nodeForTreeIndex(0);
info("Got bigFolder in the right pane");
gLibrary.PlacesOrganizer._places.selectedNode.containerOpen = true;
// Middle-click on folder (opens all links in folder) and then cancel opening in the dialog
let promiseLoaded = BrowserTestUtils.promiseAlertDialog("cancel");
let bookmarkedNode = gLibrary.PlacesOrganizer._places.selectedNode.getChild(0);
mouseEventOnCell(gLibrary.PlacesOrganizer._places,
gLibrary.PlacesOrganizer._places.view.treeIndexForNode(bookmarkedNode),
0,
{ button: 1 });
await promiseLoaded;
Assert.ok(true, "Expected dialog was shown when attempting to open folder with lots of links");
await PlacesUtils.bookmarks.eraseEverything();
});
add_task(async function test_warnOnOpenLinks() {
// Generate a list of links larger than browser.tabs.maxOpenBeforeWarn
const MAX_LINKS = 16;
let children = [];
for (let i = 0; i < MAX_LINKS; i++) {
children.push({
title: `Highlighted Target ${i}`,
url: `http://example${i}.com`,
});
}
// Insert the links into the tree
await PlacesUtils.bookmarks.insertTree({
guid: PlacesUtils.bookmarks.toolbarGuid,
children,
});
info("Pushed test folder into the bookmarks tree");
gLibrary.PlacesOrganizer.selectLeftPaneBuiltIn("BookmarksToolbar");
info("Got selection in the Library left pane");
// Select all the links
gLibrary.ContentTree.view.selectAll();
let placesContext = gLibrary.document.getElementById("placesContext");
let promiseContextMenu = BrowserTestUtils.waitForEvent(placesContext, "popupshown");
// Open up the context menu and select "Open All In Tabs" (the first item in the list)
synthesizeClickOnSelectedTreeCell(gLibrary.ContentTree.view, {
button: 2,
type: "contextmenu",
});
await promiseContextMenu;
info("Context menu opened as expected");
let openTabs = gLibrary.document.getElementById("placesContext_openLinks:tabs");
let promiseLoaded = BrowserTestUtils.promiseAlertDialog("cancel");
EventUtils.synthesizeMouseAtCenter(openTabs, {}, gLibrary);
await promiseLoaded;
Assert.ok(true, "Expected dialog was shown when attempting to open lots of selected links");
await PlacesUtils.bookmarks.eraseEverything();
});
function mouseEventOnCell(aTree, aRowIndex, aColumnIndex, aEventDetails) {
var selection = aTree.view.selection;
selection.select(aRowIndex);
aTree.treeBoxObject.ensureRowIsVisible(aRowIndex);
var column = aTree.columns[aColumnIndex];
// get cell coordinates
var rect = aTree.treeBoxObject.getCoordsForCellItem(aRowIndex, column, "text");
EventUtils.synthesizeMouse(aTree.body, rect.x, rect.y,
aEventDetails, gLibrary);
}

View File

@ -67,7 +67,7 @@ function promiseClipboard(aPopulateClipboardFn, aFlavor) {
function synthesizeClickOnSelectedTreeCell(aTree, aOptions) {
let tbo = aTree.treeBoxObject;
if (tbo.view.selection.count < 1)
if (tbo.view.selection.count != 1)
throw new Error("The test node should be successfully selected");
// Get selection rowID.
let min = {}, max = {};