window.find() throws if focused on a textbox
Categories
(Core :: DOM: Core & HTML, defect)
Tracking
()
Tracking | Status | |
---|---|---|
firefox80 | --- | fixed |
People
(Reporter: emilio, Assigned: emilio)
Details
Attachments
(1 file)
Bug 1654683 - Avoid failing to set the search range for find due to nsRange security checks. r=smaug
47 bytes,
text/x-phabricator-request
|
Details | Review |
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.
Comment 1•5 years ago
|
||
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
Assignee | ||
Comment 2•5 years ago
|
||
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).
Comment 3•5 years ago
|
||
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?
Assignee | ||
Comment 4•5 years ago
|
||
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.
Assignee | ||
Comment 5•5 years ago
|
||
We should probably switch nsRange to use CallerType instead of implicit
JSContext checks?
Updated•5 years ago
|
Updated•5 years ago
|
Comment 7•5 years ago
|
||
bugherder |
Description
•