Bug 100932 - User can change a disabled select (drop down box)
Summary: User can change a disabled select (drop down box)
Status: RESOLVED FIXED
Alias: None
Product: WebKit
Classification: Unclassified
Component: Forms (show other bugs)
Version: 528+ (Nightly build)
Hardware: Unspecified All
: P2 Normal
Assignee: Nobody
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2012-11-01 02:27 PDT by Kunihiko Sakamoto
Modified: 2012-11-08 00:18 PST (History)
4 users (show)

See Also:


Attachments
Patch (4.41 KB, patch)
2012-11-01 02:41 PDT, Kunihiko Sakamoto
no flags Details | Formatted Diff | Diff
Patch 2 (6.50 KB, patch)
2012-11-07 18:07 PST, Kunihiko Sakamoto
no flags Details | Formatted Diff | Diff
Patch 3 (4.49 KB, patch)
2012-11-07 18:33 PST, Kunihiko Sakamoto
no flags Details | Formatted Diff | Diff
Patch 4 (4.38 KB, patch)
2012-11-07 19:35 PST, Kunihiko Sakamoto
no flags Details | Formatted Diff | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description Kunihiko Sakamoto 2012-11-01 02:27:44 PDT
Imported from http://crbug.com/158802

Focused select element is changeable even if it is disabled.
Example URL: http://jsfiddle.net/langdonx/ymEZR/

If focused element becomes disabled, the element should lose focus. This is expected behavior within HTML5 spec:
http://www.whatwg.org/specs/web-apps/current-work/multipage/editing.html#focus-management
Comment 1 Kunihiko Sakamoto 2012-11-01 02:41:45 PDT
Created attachment 171801 [details]
Patch
Comment 2 Kent Tamura 2012-11-01 03:19:12 PDT
Comment on attachment 171801 [details]
Patch

View in context: https://bugs.webkit.org/attachment.cgi?id=171801&action=review

> Source/WebCore/html/HTMLFormControlElement.cpp:154
> +    if (disabled() && focused())
> +        blur();
>      setNeedsWillValidateCheck();

Unfortunately, this is not acceptable.  blur() dispatches a 'blur' event, and Event handler JavaScript code can delete |this| object.

Probably we should make blur/focusout/DOMFocusOut/focus/focusin/DOMFocusIn events scoped-events, like I did in http://trac.webkit.org/changeset/132983
Comment 3 Alexey Proskuryakov 2012-11-01 10:08:15 PDT
When fixing this, please also add a test case for the issue Kent found in review.
Comment 4 Kunihiko Sakamoto 2012-11-07 18:07:57 PST
Created attachment 172905 [details]
Patch 2
Comment 5 Kent Tamura 2012-11-07 18:12:26 PST
Comment on attachment 172905 [details]
Patch 2

View in context: https://bugs.webkit.org/attachment.cgi?id=172905&action=review

> Source/WebCore/ChangeLog:15
> +        (WebCore::HTMLSelectElement::menuListDefaultEventHandler):
> +        (WebCore::HTMLSelectElement::listBoxDefaultEventHandler):
> +        (WebCore::HTMLSelectElement::defaultEventHandler):

You changes are correct, but I think checking disabled() in the beginning of HTMLSelectElement::defaultEventHandler is enough and simpler.
Comment 6 Kunihiko Sakamoto 2012-11-07 18:33:04 PST
Created attachment 172911 [details]
Patch 3
Comment 7 Kunihiko Sakamoto 2012-11-07 19:09:57 PST
Comment on attachment 172905 [details]
Patch 2

View in context: https://bugs.webkit.org/attachment.cgi?id=172905&action=review

>> Source/WebCore/ChangeLog:15
>> +        (WebCore::HTMLSelectElement::defaultEventHandler):
> 
> You changes are correct, but I think checking disabled() in the beginning of HTMLSelectElement::defaultEventHandler is enough and simpler.

Done, thanks.
Comment 8 Kent Tamura 2012-11-07 19:13:07 PST
Comment on attachment 172911 [details]
Patch 3

View in context: https://bugs.webkit.org/attachment.cgi?id=172911&action=review

> Source/WebCore/html/HTMLSelectElement.cpp:1443
> +    if (disabled() && (event->type() == eventNames().keydownEvent || event->type() == eventNames().keypressEvent)) {

if (disabled()) {
should be enough.
Comment 9 Kunihiko Sakamoto 2012-11-07 19:35:16 PST
Created attachment 172918 [details]
Patch 4
Comment 10 Kunihiko Sakamoto 2012-11-07 19:35:49 PST
Comment on attachment 172911 [details]
Patch 3

View in context: https://bugs.webkit.org/attachment.cgi?id=172911&action=review

>> Source/WebCore/html/HTMLSelectElement.cpp:1443
>> +    if (disabled() && (event->type() == eventNames().keydownEvent || event->type() == eventNames().keypressEvent)) {
> 
> if (disabled()) {
> should be enough.

Done.
Comment 11 Kent Tamura 2012-11-07 21:43:34 PST
Comment on attachment 172918 [details]
Patch 4

ok
Comment 12 WebKit Review Bot 2012-11-07 23:35:06 PST
Comment on attachment 172918 [details]
Patch 4

Rejecting attachment 172918 [details] from commit-queue.

New failing tests:
inspector-protocol/debugger-terminate-dedicated-worker-while-paused.html
Full output: http://queues.webkit.org/results/14766341
Comment 13 WebKit Review Bot 2012-11-08 00:18:18 PST
Comment on attachment 172918 [details]
Patch 4

Clearing flags on attachment: 172918

Committed r133860: <http://trac.webkit.org/changeset/133860>
Comment 14 WebKit Review Bot 2012-11-08 00:18:22 PST
All reviewed patches have been landed.  Closing bug.