mirror of
https://gitlab.winehq.org/wine/wine-gecko.git
synced 2024-09-13 09:24:08 -07:00
Bug 997406 - Default to Link context menu items in context menus. r=bnicholson
This commit is contained in:
parent
d6b7a6b944
commit
d57d41647d
@ -10,7 +10,7 @@ public class testPictureLinkContextMenu extends ContentContextMenuTest {
|
||||
private static final String tabs [] = { "Image", "Link" };
|
||||
private static final String photoMenuItems [] = { "Copy Image Location", "Share Image", "Set Image As", "Save Image" };
|
||||
private static final String linkMenuItems [] = { "Open Link in New Tab", "Open Link in Private Tab", "Copy Link", "Share Link", "Bookmark Link"};
|
||||
private static final String linkTitle = "^Link$";
|
||||
private static final String imageTitle = "^Image$";
|
||||
|
||||
public void testPictureLinkContextMenu() {
|
||||
blockForGeckoReady();
|
||||
@ -20,21 +20,19 @@ public class testPictureLinkContextMenu extends ContentContextMenuTest {
|
||||
loadAndPaint(PICTURE_PAGE_URL);
|
||||
verifyPageTitle(PICTURE_PAGE_TITLE);
|
||||
|
||||
switchTabs(imageTitle);
|
||||
verifyContextMenuItems(photoMenuItems);
|
||||
verifyTabs(tabs);
|
||||
switchTabs(imageTitle);
|
||||
verifyCopyOption(photoMenuItems[0], "Firefox.jpg"); // Test the "Copy Image Location" option
|
||||
switchTabs(imageTitle);
|
||||
verifyShareOption(photoMenuItems[1], PICTURE_PAGE_TITLE); // Test the "Share Image" option
|
||||
|
||||
switchTabs(linkTitle);
|
||||
verifyContextMenuItems(linkMenuItems);
|
||||
openTabFromContextMenu(linkMenuItems[0],2); // Test the "Open in New Tab" option - expecting 2 tabs: the original and the new one
|
||||
switchTabs(linkTitle);
|
||||
openTabFromContextMenu(linkMenuItems[1],2); // Test the "Open in Private Tab" option - expecting only 2 tabs in normal mode
|
||||
switchTabs(linkTitle);
|
||||
verifyCopyOption(linkMenuItems[2], BLANK_PAGE_URL); // Test the "Copy Link" option
|
||||
switchTabs(linkTitle);
|
||||
verifyShareOption(linkMenuItems[3], PICTURE_PAGE_TITLE); // Test the "Share Link" option
|
||||
switchTabs(linkTitle);
|
||||
verifyBookmarkLinkOption(linkMenuItems[4],BLANK_PAGE_URL); // Test the "Bookmark Link" option
|
||||
}
|
||||
|
||||
|
@ -2102,6 +2102,11 @@ var NativeWindow = {
|
||||
else this._targetRef = null;
|
||||
},
|
||||
|
||||
get defaultContext() {
|
||||
delete this.defaultContext;
|
||||
return this.defaultContext = Strings.browser.GetStringFromName("browser.menu.context.default");
|
||||
},
|
||||
|
||||
/* Gets menuitems for an arbitrary node
|
||||
* Parameters:
|
||||
* element - The element to look at. If this element has a contextmenu attribute, the
|
||||
@ -2183,7 +2188,7 @@ var NativeWindow = {
|
||||
} catch(ex) { }
|
||||
|
||||
// Fallback to the default
|
||||
return Strings.browser.GetStringFromName("browser.menu.context.default");
|
||||
return this.defaultContext;
|
||||
},
|
||||
|
||||
// Adds context menu items added through the add-on api
|
||||
@ -2338,7 +2343,8 @@ var NativeWindow = {
|
||||
*/
|
||||
_reformatList: function(target) {
|
||||
let contexts = Object.keys(this.menus);
|
||||
if (contexts.length == 1) {
|
||||
|
||||
if (contexts.length === 1) {
|
||||
// If there's only one context, we'll only show a single flat single select list
|
||||
return this._reformatMenuItems(target, this.menus[contexts[0]]);
|
||||
}
|
||||
@ -2357,12 +2363,24 @@ var NativeWindow = {
|
||||
*/
|
||||
_reformatListAsTabs: function(target, menus) {
|
||||
let itemArray = [];
|
||||
for (let context in menus) {
|
||||
|
||||
// Sort the keys so that "link" is always first
|
||||
let contexts = Object.keys(this.menus);
|
||||
contexts.sort((context1, context2) => {
|
||||
if (context1 === this.defaultContext) {
|
||||
return -1;
|
||||
} else if (context2 === this.defaultContext) {
|
||||
return 1;
|
||||
}
|
||||
return 0;
|
||||
});
|
||||
|
||||
contexts.forEach(context => {
|
||||
itemArray.push({
|
||||
label: context,
|
||||
items: this._reformatMenuItems(target, menus[context])
|
||||
});
|
||||
}
|
||||
});
|
||||
|
||||
return itemArray;
|
||||
},
|
||||
@ -8386,8 +8404,10 @@ HTMLContextMenuItem.prototype = Object.create(ContextMenuItem.prototype, {
|
||||
}
|
||||
|
||||
var items = NativeWindow.contextmenus._getHTMLContextMenuItemsForMenu(elt, target);
|
||||
// This menu will always only have one context, but we still make sure its the "right" one.
|
||||
var context = NativeWindow.contextmenus._getContextType(target);
|
||||
if (items.length > 0) {
|
||||
NativeWindow.contextmenus._addMenuItems(items, "link");
|
||||
NativeWindow.contextmenus._addMenuItems(items, context);
|
||||
}
|
||||
|
||||
} catch(ex) {
|
||||
|
Loading…
Reference in New Issue
Block a user