REGRESSION: (r251677) imported/w3c/web-platform-tests/html/semantics/forms/form-submission-0/form-double-submit-3.html is a flaky failure
https://bugs.webkit.org/show_bug.cgi?id=205164
<rdar://problem/57879042>

Reviewed by Ryosuke Niwa.

LayoutTests/imported/w3c:

Rebaseline tests that are now passing.

* web-platform-tests/html/semantics/forms/form-submission-0/form-double-submit-3-expected.txt:
* web-platform-tests/html/semantics/forms/form-submission-0/form-double-submit-expected.txt:

Source/WebCore:

Submitting a form should cancel any pending navigation scheduled by a previous submission of this form:
- https://html.spec.whatwg.org/multipage/form-control-infrastructure.html#form-submission-algorithm (step 22.3)

No new tests, rebaselined existing tests.

Test: fast/forms/form-double-submission.html

* html/HTMLFormElement.cpp:
(WebCore::HTMLFormElement::submit):
* html/HTMLFormElement.h:
* loader/FormSubmission.h:
(WebCore::FormSubmission::cancel):
(WebCore::FormSubmission::wasCancelled const):

* loader/FrameLoader.cpp:
(WebCore::FrameLoader::submitForm):
Drop previous non-standard compliant logic to avoid double-form submission.

* loader/NavigationScheduler.cpp:

LayoutTests:

* fast/forms/form-double-submission-expected.txt: Added.
* fast/forms/form-double-submission.html: Added.
* fast/forms/resources/form-double-submission-frame.html: Added.
Add layout test for the regression that was introduced the first time this patch landed.

* http/tests/misc/multiple-submit-expected.txt:
Rebaseline test due to behavior change. I have verified that our new behavior on this test is
aligned with Firefox 71 and Chrome 79.

* platform/mac/TestExpectations:
Unskip tests that are no longer flaky.


git-svn-id: http://svn.webkit.org/repository/webkit/trunk@253799 268f45cc-cd09-0410-ab3c-d52691b4dbfc
diff --git a/Source/WebCore/loader/NavigationScheduler.cpp b/Source/WebCore/loader/NavigationScheduler.cpp
index 3c2c252..80ded79 100644
--- a/Source/WebCore/loader/NavigationScheduler.cpp
+++ b/Source/WebCore/loader/NavigationScheduler.cpp
@@ -277,6 +277,9 @@
 
     void fire(Frame& frame) override
     {
+        if (m_submission->wasCancelled())
+            return;
+
         UserGestureIndicator gestureIndicator(userGestureToForward());
 
         // The submitForm function will find a target frame before using the redirection timer.