RESOLVED DUPLICATE of bug 243594 53296
Implicit form submission shouldn’t work when the default button is disabled
https://bugs.webkit.org/show_bug.cgi?id=53296
Summary Implicit form submission shouldn’t work when the default button is disabled
Mathias Bynens
Reported 2011-01-28 04:34:54 PST
From http://www.whatwg.org/specs/web-apps/current-work/multipage/association-of-controls-and-forms.html#implicit-submission: > […] if the default button is disabled, the form is not submitted when such an implicit submission mechanism is used. (A button has no activation behavior when disabled.) Currently it is possible to submit a form by pressing `Enter` even if the default button is disabled in WebKit.
Attachments
Testcase (62 bytes, text/plain)
2011-01-28 04:43 PST, Mathias Bynens
no flags
Proposed patch (1.67 KB, patch)
2011-01-29 08:56 PST, Mathias Bynens
dglazkov: review-
Revised patch (6.28 KB, patch)
2011-01-31 04:25 PST, Mathias Bynens
dglazkov: review-
Revised patch (8.13 KB, patch)
2011-01-31 16:44 PST, Mathias Bynens
no flags
Patch (8.13 KB, patch)
2011-01-31 17:30 PST, Mathias Bynens
no flags
Patch (10.59 KB, patch)
2011-02-01 11:57 PST, Mathias Bynens
eric: review-
Mathias Bynens
Comment 1 2011-01-28 04:43:16 PST
Created attachment 80438 [details] Testcase
Dimitri Glazkov (Google)
Comment 2 2011-01-28 13:57:02 PST
This should be a super-easy fix. Mathias, wanna give it a whirl? :)
Mathias Bynens
Comment 3 2011-01-29 05:49:51 PST
I call dibs as per comment #2.
Mathias Bynens
Comment 4 2011-01-29 08:56:12 PST
Created attachment 80564 [details] Proposed patch Needs review.
Dimitri Glazkov (Google)
Comment 5 2011-01-29 09:06:51 PST
Comment on attachment 80564 [details] Proposed patch Looks reasonable. All that it's missing to be a good patch is: a) Layout test -- use your reduction to create one. Read up layout tests on webkit.org/blog. b) ChangeLog. -- use Tools/Scripts/webkit-patch to upload the patch. It will ensure your patch has the proper log.
Mathias Bynens
Comment 6 2011-01-31 04:25:49 PST
Created attachment 80632 [details] Revised patch Am I doing this right?
Dimitri Glazkov (Google)
Comment 7 2011-01-31 09:00:52 PST
Comment on attachment 80632 [details] Revised patch View in context: https://bugs.webkit.org/attachment.cgi?id=80632&action=review > Source/WebCore/ChangeLog:5 > + Implicit form submission shouldnât work when the default button is disabled https://bugs.webkit.org/show_bug.cgi?id=53296 What's that odd character in shouldn't? Bug URL should go on a different line. > Source/WebCore/ChangeLog:6 > + There is usually a mention of a test here. Like so: Test: fast/forms/implicit-submission.html > Source/WebCore/html/HTMLFormElement.cpp:188 > + if (formElement->getAttribute(typeAttr).lower() == "submit" || formElement->hasLocalName(buttonTag)) { This is horrible. We shouldn't need to reach into attributes at this level. Why did you change this? > LayoutTests/ChangeLog:5 > + Implicit form submission shouldnât work when the default button is disabled https://bugs.webkit.org/show_bug.cgi?id=53296 Same here. > LayoutTests/fast/forms/implicit-submission.html:-19 > - [ "Text input and text area and a disabled submit, text input focused", "!text,textarea,-submit", "y" ], // match IE, not FF. Aha. This is interesting. So this change may break sites, expecting IE behavior?
Mathias Bynens
Comment 8 2011-01-31 09:44:17 PST
Comment on attachment 80632 [details] Revised patch View in context: https://bugs.webkit.org/attachment.cgi?id=80632&action=review >> Source/WebCore/html/HTMLFormElement.cpp:188 >> + if (formElement->getAttribute(typeAttr).lower() == "submit" || formElement->hasLocalName(buttonTag)) { > > This is horrible. We shouldn't need to reach into attributes at this level. Why did you change this? I didn’t change this — it’s new code. Why did I write it like this? I simply don’t know of a better way. There’s no `isSubmitButton()` method. Should I add one? Any suggestions? >> LayoutTests/fast/forms/implicit-submission.html:-19 >> - [ "Text input and text area and a disabled submit, text input focused", "!text,textarea,-submit", "y" ], // match IE, not FF. > > Aha. This is interesting. So this change may break sites, expecting IE behavior? The spec states that if the only submit button in a form is disabled, it shouldn’t submit implicitly. If there are no submit buttons at all, implicit submission should still work. This patch would make it so. So yes, it would break sites that rely on IE-style behavior for forms that only have disabled submit buttons. (Not that it matters, but that sure sounds like an edge case to me.) For this particular case, it would instead match Firefox and Opera’s behavior, which happens to conform to the HTML spec and also makes much more sense. Would this change be acceptable or not?
Dimitri Glazkov (Google)
Comment 9 2011-01-31 10:06:02 PST
Comment on attachment 80632 [details] Revised patch View in context: https://bugs.webkit.org/attachment.cgi?id=80632&action=review >>> Source/WebCore/html/HTMLFormElement.cpp:188 >>> + if (formElement->getAttribute(typeAttr).lower() == "submit" || formElement->hasLocalName(buttonTag)) { >> >> This is horrible. We shouldn't need to reach into attributes at this level. Why did you change this? > > I didn’t change this — it’s new code. > Why did I write it like this? I simply don’t know of a better way. There’s no `isSubmitButton()` method. Should I add one? Any suggestions? Yes -- you can plumb HTMLInputElement::isSubmitButton() and remove the use of isSuccessfulSubmitButton altogether. Just check for disabled(). Also, you don't need two variables here. Increment when found, decrement if disabled. You only need to make sure that there's at least one non-disabled submit button. >>> LayoutTests/fast/forms/implicit-submission.html:-19 >>> - [ "Text input and text area and a disabled submit, text input focused", "!text,textarea,-submit", "y" ], // match IE, not FF. >> >> Aha. This is interesting. So this change may break sites, expecting IE behavior? > > The spec states that if the only submit button in a form is disabled, it shouldn’t submit implicitly. If there are no submit buttons at all, implicit submission should still work. This patch would make it so. > > So yes, it would break sites that rely on IE-style behavior for forms that only have disabled submit buttons. (Not that it matters, but that sure sounds like an edge case to me.) For this particular case, it would instead match Firefox and Opera’s behavior, which happens to conform to the HTML spec and also makes much more sense. > > Would this change be acceptable or not? I think the change is acceptable, but we should watch for the reactions from the Web and be ready to revert this if it proves drastic. Also, would love to see a test added with multiple submit buttons (some disabled), just to test your newly added code.
Mathias Bynens
Comment 10 2011-01-31 10:12:39 PST
Comment on attachment 80632 [details] Revised patch View in context: https://bugs.webkit.org/attachment.cgi?id=80632&action=review Thanks for your feedback! I’ll tweak the code as per your suggestions and submit another patch later tonight. >>>> LayoutTests/fast/forms/implicit-submission.html:-19 >>>> - [ "Text input and text area and a disabled submit, text input focused", "!text,textarea,-submit", "y" ], // match IE, not FF. >>> >>> Aha. This is interesting. So this change may break sites, expecting IE behavior? >> >> The spec states that if the only submit button in a form is disabled, it shouldn’t submit implicitly. If there are no submit buttons at all, implicit submission should still work. This patch would make it so. >> >> So yes, it would break sites that rely on IE-style behavior for forms that only have disabled submit buttons. (Not that it matters, but that sure sounds like an edge case to me.) For this particular case, it would instead match Firefox and Opera’s behavior, which happens to conform to the HTML spec and also makes much more sense. >> >> Would this change be acceptable or not? > > I think the change is acceptable, but we should watch for the reactions from the Web and be ready to revert this if it proves drastic. > > Also, would love to see a test added with multiple submit buttons (some disabled), just to test your newly added code. I believe there’s already a test for this: “Multiple text inputs and multiple submits, first submit disabled”. Let me know if I’m missing something.
Alexey Proskuryakov
Comment 11 2011-01-31 10:14:31 PST
I think that a somewhat deeper look is needed here. The HTML spec is more a reflection of reality than a mandate, and if it doesn't match IE and WebKit (engines with largest market share in desktop and mobile space), maybe it just needs to change. Some questions that I would like to see answers for: - We have a regression test for this behavior. Was it added as part of fixing a real life bug? This test is pretty new, so perhaps Dimitri will remember where this particular subtest came from. - Was this ever discussed on WhatWG or W3C HTML5 mailing lists? Forms are pretty common on web sites, and we've learned that even edge cases matter a lot.
Dimitri Glazkov (Google)
Comment 12 2011-01-31 10:17:11 PST
(In reply to comment #11) > I think that a somewhat deeper look is needed here. The HTML spec is more a reflection of reality than a mandate, and if it doesn't match IE and WebKit (engines with largest market share in desktop and mobile space), maybe it just needs to change. Some questions that I would like to see answers for: > - We have a regression test for this behavior. Was it added as part of fixing a real life bug? This test is pretty new, so perhaps Dimitri will remember where this particular subtest came from. I added this test while testing the edge cases of implicit form submission. It wasn't part of the bug per se. > - Was this ever discussed on WhatWG or W3C HTML5 mailing lists? > > Forms are pretty common on web sites, and we've learned that even edge cases matter a lot. I agree with Alexey here. I've learned it the hard way :) Even though "no implicit submission on disabled inputs" makes good logical sense.
Mathias Bynens
Comment 13 2011-01-31 16:44:11 PST
Comment on attachment 80632 [details] Revised patch View in context: https://bugs.webkit.org/attachment.cgi?id=80632&action=review >>>> Source/WebCore/html/HTMLFormElement.cpp:188 >>>> + if (formElement->getAttribute(typeAttr).lower() == "submit" || formElement->hasLocalName(buttonTag)) { >>> >>> This is horrible. We shouldn't need to reach into attributes at this level. Why did you change this? >> >> I didn’t change this — it’s new code. >> Why did I write it like this? I simply don’t know of a better way. There’s no `isSubmitButton()` method. Should I add one? Any suggestions? > > Yes -- you can plumb HTMLInputElement::isSubmitButton() and remove the use of isSuccessfulSubmitButton altogether. Just check for disabled(). > > Also, you don't need two variables here. Increment when found, decrement if disabled. You only need to make sure that there's at least one non-disabled submit button. …or none at all, in which case implicit submission should still work. This is why I used two variables. Am I missing something?
Mathias Bynens
Comment 14 2011-01-31 16:44:47 PST
Created attachment 80699 [details] Revised patch
Mathias Bynens
Comment 15 2011-01-31 17:30:35 PST
Dimitri Glazkov (Google)
Comment 16 2011-02-01 10:32:58 PST
Comment on attachment 80702 [details] Patch I think you forgot to change HTMLInputElement to plumb isSubmitButton, too? Also, before this patch can land, you need to persuade Alexey that it should :)
Darin Adler
Comment 17 2011-02-01 10:44:28 PST
(In reply to comment #16) > Also, before this patch can land, you need to persuade Alexey that it should :) I think Alexey’s feedback is critically important and I think we must do what he asks before making this change.
Dimitri Glazkov (Google)
Comment 18 2011-02-01 10:46:48 PST
Comment on attachment 80702 [details] Patch I didn't meant to r+ this. It was an accident! :)
Alexey Proskuryakov
Comment 19 2011-02-01 10:57:20 PST
Dimitri explained that the test case doesn't have long or interesting history. Besides searching html5 discussion archives, a good thing to do is to search bugzilla.mozilla.org for related bugs (including WONTFIX and INVALID). If there are actual sites broken in Firefox due to this, a spec change is the most straightforward answer. If you do the research and nothing comes up, this looks like a fine change to me. + [ "Single text input with submit disabled", "!text,-submit", "n" ], // match spec I would have either said that we're matching HTML5 and Firefox instead of IE, or make no comment at all. Matching relevant specifications doesn't need further explanation unless there are complications!
Mathias Bynens
Comment 20 2011-02-01 11:57:34 PST
Mathias Bynens
Comment 21 2011-02-01 12:06:11 PST
Searching for “implicit submission” in Mozilla’s bug tracker doesn’t seem to help, but https://bugzilla.mozilla.org/buglist.cgi?quicksearch=submit+enter returns some very interesting results. Especially: * https://bugzilla.mozilla.org/show_bug.cgi?id=190563 * https://bugzilla.mozilla.org/show_bug.cgi?id=104449 * https://bugzilla.mozilla.org/show_bug.cgi?id=104211
Chang Shu
Comment 22 2011-05-16 12:27:53 PDT
Comment on attachment 80799 [details] Patch I am not sure why the code change in HTMLInputElement.cpp and .h is necessary.
Chang Shu
Comment 23 2011-05-16 12:35:10 PDT
(In reply to comment #22) > (From update of attachment 80799 [details]) > I am not sure why the code change in HTMLInputElement.cpp and .h is necessary. Ok, I see the conflicts now. :)
Eric Seidel (no email)
Comment 24 2011-05-23 13:40:40 PDT
Comment on attachment 80799 [details] Patch Marking r- based on Ap's commentary. This patch hasn't been touched in over 3 months and likely not longer applies.
Daniel Compton
Comment 25 2023-04-12 20:01:46 PDT
Both Chrome and Firefox disable implicit form submission when the default button is disabled, I'd argue that Webkit should follow suit.
Sam Sneddon [:gsnedders]
Comment 26 2023-04-13 09:37:05 PDT
(In reply to Daniel Compton from comment #25) > Both Chrome and Firefox disable implicit form submission when the default > button is disabled, I'd argue that Webkit should follow suit. This doesn't seem to trivially reproduce with the linked test case http://krijnhoetmer.nl/stuff/html/form-submit-disabled-button/, and likewise https://wpt.fyi/results/html/semantics/forms/form-submission-0/implicit-submission.optional.html?run_id=5191742251335680&run_id=5172360246722560&run_id=5152321699315712 seems to test this and be passing. Do you have a test case where this still happens?
Darin Adler
Comment 27 2023-04-13 09:47:22 PDT
Pretty sure this was fixed a long time ago.
Daniel Compton
Comment 28 2023-04-13 12:41:13 PDT
> This doesn't seem to trivially reproduce with the linked test case http://krijnhoetmer.nl/stuff/html/form-submit-disabled-button/ I can reproduce this in Safari 16.3 but not in Safari 16.4 or Safari STP 167 (16.4). It looks like this was fixed in August 2022 with https://github.com/WebKit/WebKit/commit/7f2b47eeff03586875c526e4e5763c8a52c033f8 via https://bugs.webkit.org/show_bug.cgi?id=243594. I'll make sure to test on the newest Safari next time. Thanks, and sorry for the noise!
Alexey Proskuryakov
Comment 29 2023-04-13 13:36:25 PDT
*** This bug has been marked as a duplicate of bug 243594 ***
Note You need to log in before you can comment on or make changes to this bug.