Closed Bug 1654683 Opened 5 years ago Closed 5 years ago

window.find() throws if focused on a textbox

Categories

(Core :: DOM: Core & HTML, defect)

defect

Tracking

()

RESOLVED FIXED
mozilla80
Tracking Status
firefox80 --- fixed

People

(Reporter: emilio, Assigned: emilio)

Details

Attachments

(1 file)

STR:

  • Go to https://searchfox.org
  • Ensure the search box is focused (should be by default).
  • Open devtools and write window.find("mozilla");

ER:

  • Probably we start searching and returning results past the textbox.

AR:

  • We throw NS_ERROR_ILLEGAL_VALUE to content, which is quite le sad.

MWRT:

data:text/html,<input id=i><script>i.focus();try{window.find('x')}catch(e){document.body.textContent=e.toString()}</script>

Expected outcome: Page with focused input.
Actual outcome: Page that reads [Exception... "Illegal value" nsresult: "0x80070057 (NS_ERROR_ILLEGAL_VALUE)" location: "JS frame :: etc.

This is presumably the cause of all those infamous "lebowskilebowski" Modernizr glitches that occurs only in Firefox.

https://github.com/Modernizr/Modernizr/issues/1052
https://github.com/Modernizr/Modernizr/blob/b621acefb0ffaadf59b121fc5f6c5791577852c4/feature-detects/css/hyphens.js#L162-L175
bug 1581592

That's different. That was fixed in https://github.com/Modernizr/Modernizr/pull/1514 and is because of this code, which is bug 1465387 (and bug 1358633, actually).

Yes, you are right about Modernizr being patched for a long time already (in fact I wanted to point to that pull request but messed up clipboards).

But to reiterate: outdated Modernizr still exhibit such broken behaviour in modern Firefox (tried today's Nightly 80.0a1 and stable on Windows) as well as those STR from above yields described error.

So is that so bug 1358633 has wrong description and is not Android-related after all?

So bug 1358633 is definitely android specific, and android unconditionally throws on window.find. There's this bug on top of that. I poked a bit and what's going on is that the find code returns the selection of the <input> here, and then these calls fail because of the security checks in nsRange::SetStart and so on which we ignore.

We should probably switch nsRange to use CallerType instead of implicit
JSContext checks?

Assignee: nobody → emilio
Status: NEW → ASSIGNED
Severity: -- → S3
Pushed by ealvarez@mozilla.com: https://hg.mozilla.org/integration/autoland/rev/3a145ddbf34a Avoid failing to set the search range for find due to nsRange security checks. r=smaug
Status: ASSIGNED → RESOLVED
Closed: 5 years ago
Resolution: --- → FIXED
Target Milestone: --- → mozilla80
You need to log in before you can comment on or make changes to this bug.

Attachment

General

Created:
Updated:
Size: