Closed Bug 360331 Opened 15 years ago Closed 8 years ago

getBrowserSelection() (context menu search) does not get text from input or textarea

Categories

(Firefox :: Search, defect)

defect
Not set
normal

Tracking

()

RESOLVED DUPLICATE of bug 565717

People

(Reporter: bugzilla, Assigned: bugzilla)

Details

Attachments

(1 file)

The browser.js function getBrowserSelection() does not return text from either input or textarea nodes, and this is limiting the scope of "Search <Engine> for <String>" on the context menu.

An easy fix would be something like this (untested, but I've implemented the same behaviour for the next release of Context Search):

var fElm = document.commandDispatcher.focusedElement;
if ((fElm instanceof HtmlInputElement && String.toLowerCase(fElm.type) == "text) || fElm instanceof HTMLTextAreaElement) {
  return (fElm.selectionStart < fElm.selectionEnd) ? fElm.value.substring(fElm.selectionStart, fElm.selectionEnd) : null;
}
No need for the toLowerCase, the .type getter will always return a lowercased string.
Hardware: PC → All
Summary: getBrowserSelection() does not get text from input or textarea → getBrowserSelection() (context menu search) does not get text from input or textarea
Version: unspecified → Trunk
Ah, I didn't know - thanks.
reported also in bug 125487 (at that time for suite of course)
First stab at suggestion above.
Assignee: nobody → cusser.bugs
Status: NEW → ASSIGNED
Ben, you need to request review and/or cc someone on the bug if you want patch to be examined
Status: ASSIGNED → RESOLVED
Closed: 8 years ago
Resolution: --- → DUPLICATE
Duplicate of bug: 565717
You need to log in before you can comment on or make changes to this bug.