Closed Bug 1172086 Opened 5 years ago Closed 5 years ago

Empty, but disabled <input> with associated <datalist> incorrectly allows input

Categories

(Firefox for Android :: General, defect)

ARM
Android
defect
Not set
normal

Tracking

()

RESOLVED FIXED
Firefox 41
Tracking Status
firefox41 --- fixed

People

(Reporter: capella, Assigned: p.calligaris.code, Mentored)

Details

(Whiteboard: [lang=js][good first bug])

Attachments

(1 file, 2 obsolete files)

See the example testcase [0]

Initially tapping the disabled <input> provides the dropdown datalist, and allows item selection via tap.

Interestingly, once the field is populated, subsequent tapping behaviour is as expected (not allowed).

[0] https://www.dropbox.com/s/5xl2sm7ehcpdu95/bug_Disabled_Input_wDatalist.html?dl=0
This is a fairly simple bug for a new contributor with basic Javascript skills, to learn the Mozilla development process.

You should have an android device for testing your solution locally, and should be able to build Firefox Mobile on your desktop. See [1] for instructions if this is new to you, and ask questions on irc channels #introduction or #mobile.

After building and testing to confirm that you can reproduce the issue, you can review the method / code that is at play here [2]. You should be able to enhance the first method it calls |_isAutoComplete()| [3] to fail in this additional situation, to solve the problem.

[1] https://wiki.mozilla.org/Mobile/Fennec/Android
[2] http://mxr.mozilla.org/mozilla-central/source/mobile/android/chrome/content/browser.js?rev=8c37c4b99d99&mark=5929-5929#5924
[3] http://mxr.mozilla.org/mozilla-central/source/mobile/android/chrome/content/browser.js?rev=8c37c4b99d99#5851
Mentor: markcapella
Whiteboard: [lang=js][good first bug]
Can I take it?
The bug will be assigned to whoever can attach a viable patch for review. If you've completed the requirements as in comment #1, please post your work.
Attached patch Proposed Patch (obsolete) — Splinter Review
Here there is a proposed patch. 

The attribute disabled (http://www.w3.org/TR/html5/forms.html#attr-fe-disabled) is a boolean attribute (http://www.w3.org/TR/html5/infrastructure.html#boolean-attribute). I quote 

"The presence of a boolean attribute on an element represents the true value, and the absence of the attribute represents the false value."   

Then it is sufficient to check if there is or not the attribute using the method .hasAttribute .

Is it right?

I built and check the patch on my android device and seems to work.
Close! We normally prefer the use of the element property vs. it's attribute ... can you try
|aElement.disabled| ?

This is normally preferred as simpler and easier to quickly read, and also sometimes for visible controls actually more correct. See additional reading [0], and [1].

[0] https://developer.mozilla.org/en-US/docs/Mozilla/Tech/XUL/Attribute/disabled
[1] https://developer.mozilla.org/en-US/docs/Web/HTML/Attributes#Content_versus_IDL_attributes

Also, a slight style "nit" for your patch, I don't think it'll be necessary to wrap the new condition in parens
|(aElement.hasAttribute("disabled"))| vs. |aElement.hasAttribute("disabled")|

(See the earlier free-standing condition for |aElement.readOnly|)
Assignee: nobody → p.calligaris.code
Status: NEW → ASSIGNED
Attached patch Updated Proposed Patch (obsolete) — Splinter Review
I updated the patch as you suggested. Thank you for the useful links!
Attachment #8616384 - Attachment is obsolete: true
This looks fine, and wfm locally ... let's push to TRY / automated test-farm.
https://treeherder.mozilla.org/#/jobs?repo=try&revision=f6a286029b55

If this works ok, we'll have you change |r=reviewers| to |r=margaret| in your patch commit message, and re-post flagging her for review=?
Ok, (as expected), this looks fine. As mentioned in the previous comment, go ahead and:

1) change |r=reviewers| to |r=margaret| in your patch commit message
2) repost the new patch, and flag it for her review
Last proposed patch. Thanks for the help Mark!
Attachment #8616451 - Attachment is obsolete: true
Attachment #8616875 - Flags: review?(margaret.leibovic)
Comment on attachment 8616875 [details] [diff] [review]
bug1172086_input_element_disabled_property_issue.patch

Review of attachment 8616875 [details] [diff] [review]:
-----------------------------------------------------------------

Looks great, thanks! And thanks to capella for mentoring!
Attachment #8616875 - Flags: review?(margaret.leibovic) → review+
Keywords: checkin-needed
https://hg.mozilla.org/integration/fx-team/rev/99660e46937c
Whiteboard: [lang=js][good first bug] → [lang=js][good first bug][fixed-in-fx-team]
https://hg.mozilla.org/mozilla-central/rev/99660e46937c
Status: ASSIGNED → RESOLVED
Closed: 5 years ago
Resolution: --- → FIXED
Whiteboard: [lang=js][good first bug][fixed-in-fx-team] → [lang=js][good first bug]
Target Milestone: --- → Firefox 41
You need to log in before you can comment on or make changes to this bug.