Bug 985824 - Search for link text context menu item should pay attention to selection. r=Unfocused

This commit is contained in:
Valentin Tsatskin 2014-04-01 08:57:24 -04:00
Родитель 7ce174faf5
Коммит 179f4cb0aa
3 изменённых файлов: 21 добавлений и 5 удалений

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

@ -1668,7 +1668,7 @@ nsContextMenu.prototype = {
// Formats the 'Search <engine> for "<selection or link text>"' context menu.
formatSearchContextItem: function() {
var menuItem = document.getElementById("context-searchselect");
var selectedText = this.onLink ? this.linkText() : this.textSelected;
var selectedText = this.isTextSelected ? this.textSelected : this.linkText();
// Store searchTerms in context menu item so we know what to search onclick
menuItem.searchTerms = selectedText;

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

@ -4,7 +4,7 @@ function test() {
waitForExplicitFinish();
gBrowser.selectedTab = gBrowser.addTab();
gBrowser.selectedBrowser.addEventListener("load", function() {
gBrowser.selectedBrowser.removeEventListener("load", arguments.callee, true);
@ -16,7 +16,7 @@ function test() {
// given query string of an element. Tests to make sure label includes the proper search terms.
//
// Options:
//
//
// id: The id of the element to test.
// isSelected: Flag to enable selection (text hilight) the contents of the element
// shouldBeShown: The display state of the menu item
@ -94,6 +94,20 @@ function test() {
shouldBeShown: false,
});
testElement({
id: "partialLink",
isSelected: true,
shouldBeShown: true,
expectedLabelContents: "link selection",
});
testElement({
id: "partialLink",
isSelected: false,
shouldBeShown: true,
expectedLabelContents: "A partial link " + ellipsis,
});
// cleanup
document.popupNode = null;
gBrowser.removeCurrentTab();
@ -101,4 +115,4 @@ function test() {
}, true);
content.location = "http://mochi.test:8888/browser/browser/base/content/test/general/browser_bug970746.xhtml";
}
}

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

@ -10,5 +10,7 @@
<span id="mixedContent">
I'm some text, and <a href="http://mozilla.org">I'm a link!</a>
</span>
<a href="http://mozilla.org">A partial <span id="partialLink">link selection</span></a>
</body>
</html>
</html>