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)

1.9.2 Branch
x86
Windows 7
defect
Not set
normal

Tracking

()

RESOLVED DUPLICATE of bug 178258

People

(Reporter: bugzilla33, Unassigned)

References

()

Details

Attachments

(1 file)

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>
Attached file source (deleted) —
Datails:
therefore => through
Sorry :)
therefore => though
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
Component: General → Layout
Product: Firefox → Core
Version: 3.6 Branch → 1.9.2 Branch
QA Contact: general → layout
(In reply to comment #4)
> This seems a duplicate of Bug 42553.

Not based on that bug's summary, it doesn't.
Component: Layout → Layout: Form Controls
QA Contact: layout → layout.form-controls
Summary: selectable input → calling event.preventDefault() on key events in a text input should prevent the text from showing up
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
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.
Status: RESOLVED → UNCONFIRMED
Resolution: WORKSFORME → ---
> Did you tried this on Win7 ??

No, I tried it on Mac.  I'll try it on win7 in a bit.
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 ago15 years ago
Resolution: --- → DUPLICATE
You need to log in before you can comment on or make changes to this bug.

Attachment

General

Creator:
Created:
Updated:
Size: