Closed
Bug 530344
Opened 15 years ago
Closed 15 years ago
calling event.preventDefault() on key events in a text input should prevent the text from showing up
Categories
(Core :: Layout: Form Controls, defect)
Tracking
()
RESOLVED
DUPLICATE
of bug 178258
People
(Reporter: bugzilla33, Unassigned)
References
()
Details
Attachments
(1 file)
(deleted),
text/html
|
Details |
User-Agent: Mozilla/5.0 (Windows; U; Windows NT 6.1; en-US; rv:1.9.2b3) Gecko/20091115 Firefox/3.6b3 Build Identifier: Mozilla/5.0 (Windows; U; Windows NT 6.1; en-US; rv:1.9.2b3) Gecko/20091115 Firefox/3.6b3 Text in Input is selectable therefore keydown preventDefault(). Reproducible: Always Steps to Reproduce: 1. run attachment 2 [review]. input is read-only by preventDefault() 3. text should not be selectable Actual Results: Text in Input is selectable. Expected Results: Text in Input is not selectable. <!DOCTYPE html> <div><input id="in_el" /></div> <script> try{ document.getElementById('in_el').addEventListener('keydown',function(e){e.preventDefault()},false) document.getElementById('in_el').addEventListener('keypress',function(e){e.preventDefault()},false) }catch(e){ document.getElementById('in_el').attachEvent('onkeydown',function(){event.returnValue=false}) document.getElementById('in_el').attachEvent('onkeypress',function(){event.returnValue=false}) } </script> <div>Try type in input above.</div> <div>It should not be possible because input is read-only by preventDefault()</div> <div style="color:red;padding-top:1em">Firefox 3.6: FAILS</div> <div style="color:green">Safari: OK</div> <div style="color:green">Chrome: OK</div> <div style="color:green">Opera: OK</div> <div style="color:green">Konqueror: OK</div> <div style="color:green">IE: OK</div>
Reporter | ||
Comment 1•15 years ago
|
||
Reporter | ||
Comment 2•15 years ago
|
||
Datails: therefore => through
Reporter | ||
Comment 3•15 years ago
|
||
Sorry :) therefore => though
Comment 4•15 years ago
|
||
Confirmed with Mozilla/5.0 (Windows; U; Windows NT 6.0; en-US; rv:1.9.3a1pre) Gecko/20091122 Minefield/3.7a1pre This seems a duplicate of Bug 42553.
Version: unspecified → 3.6 Branch
Reporter | ||
Updated•15 years ago
|
Component: General → Layout
Product: Firefox → Core
Version: 3.6 Branch → 1.9.2 Branch
Updated•15 years ago
|
QA Contact: general → layout
Comment 5•15 years ago
|
||
(In reply to comment #4) > This seems a duplicate of Bug 42553. Not based on that bug's summary, it doesn't.
Updated•15 years ago
|
Component: Layout → Layout: Form Controls
QA Contact: layout → layout.form-controls
Updated•15 years ago
|
Summary: selectable input → calling event.preventDefault() on key events in a text input should prevent the text from showing up
Comment 6•15 years ago
|
||
Testcase in comment 1 works for me; nothing is added to the input as I try to type in it, as expected.
Status: UNCONFIRMED → RESOLVED
Closed: 15 years ago
Resolution: --- → WORKSFORME
Reporter | ||
Comment 7•15 years ago
|
||
Boris Zbarsky: Did you tried this on Win7 ?? I'm now trying with FF 3.6 b4 Win7 and I can add to the input.
Reporter | ||
Updated•15 years ago
|
Status: RESOLVED → UNCONFIRMED
Resolution: WORKSFORME → ---
Comment 8•15 years ago
|
||
> Did you tried this on Win7 ??
No, I tried it on Mac. I'll try it on win7 in a bit.
Comment 9•15 years ago
|
||
OK. I can't reproduce on win7 either with my normal browsing profile, but I _can_ reproduce if I turn off the html5 parser (so go back to the default setting). The problem is that <input> doesn't force a <body> in the old parser and the <script> ends up in <head> as a result, so runs before the <input> has been parsed and added to the DOM. So the getElementById returns null (as your error console should be telling you).
Status: UNCONFIRMED → RESOLVED
Closed: 15 years ago → 15 years ago
Resolution: --- → DUPLICATE
You need to log in
before you can comment on or make changes to this bug.
Description
•