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. // Formats the 'Search <engine> for "<selection or link text>"' context menu.
formatSearchContextItem: function() { formatSearchContextItem: function() {
var menuItem = document.getElementById("context-searchselect"); 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 // Store searchTerms in context menu item so we know what to search onclick
menuItem.searchTerms = selectedText; menuItem.searchTerms = selectedText;

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

@ -94,6 +94,20 @@ function test() {
shouldBeShown: false, 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 // cleanup
document.popupNode = null; document.popupNode = null;
gBrowser.removeCurrentTab(); gBrowser.removeCurrentTab();

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

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