Cancel in onbeforeunload dialog sometime causes a button to stop working.
authoraestes@apple.com <aestes@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Fri, 12 Aug 2011 19:56:56 +0000 (19:56 +0000)
committeraestes@apple.com <aestes@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Fri, 12 Aug 2011 19:56:56 +0000 (19:56 +0000)
commitc580881838bb4a6af943fcd986d6db0bf614aecc
treedfd121b7cae760f302aeb69dcf9930aa67f77b47
parent3c5078969c870839074ae49e82ec8e7501a92dcc
Cancel in onbeforeunload dialog sometime causes a button to stop working.
https://bugs.webkit.org/show_bug.cgi?id=26211

Reviewed by Alexey Proskuryakov.

Source/WebCore:

Test: fast/loader/form-submission-after-beforeunload-cancel.html

If an onbeforeunload handler cancels a navigation that was triggered by
a form submission, WebCore's multiple form submission protection
prevents the form from being submitted a second time even though no
first submission actually took place. Fix this by clearing
m_submittedFormURL if the onbeforeunload handler cancels the load. This
allows the submission to be retried.

* loader/FrameLoader.cpp:
(WebCore::FrameLoader::shouldClose): Set m_submittedFormURL to KURL()
if shouldClose() will return false.

Tools:

Implement a new LayoutTestController method that a test can call to set
the return value of DumpRenderTree's beforeunload UI delegate.

* DumpRenderTree/LayoutTestController.cpp:
(LayoutTestController::LayoutTestController): Initialize
m_shouldStayOnPageAfterHandlingBeforeUnload.
(setShouldStayOnPageAfterHandlingBeforeUnloadCallback): Call
LayoutTestController::setShouldStayOnPageAfterHandlingBeforeUnload().
(LayoutTestController::staticFunctions): Register
'setShouldStayOnPageAfterHandlingBeforeUnload' as a static function.
* DumpRenderTree/LayoutTestController.h:
(LayoutTestController::shouldStayOnPageAfterHandlingBeforeUnload):
(LayoutTestController::setShouldStayOnPageAfterHandlingBeforeUnload):
* DumpRenderTree/chromium/LayoutTestController.cpp:
(LayoutTestController::LayoutTestController): Initialize
m_shouldStayOnPageAfterHandlingBeforeUnload and bind
'setShouldStayOnPageAfterHandlingBeforeUnload' to its c++ setter.
(LayoutTestController::reset): Reset
m_shouldStayOnPageAfterHandlingBeforeUnload to false.
(LayoutTestController::setShouldStayOnPageAfterHandlingBeforeUnload):
Set m_shouldStayOnPageAfterHandlingBeforeUnload to the value passed in
from JavaScript.
* DumpRenderTree/chromium/LayoutTestController.h:
(LayoutTestController::shouldStayOnPageAfterHandlingBeforeUnload):
* DumpRenderTree/chromium/WebViewHost.cpp:
(WebViewHost::runModalBeforeUnloadDialog): Add the correct logging and
return the inverse of
LayoutTestController::shouldStayOnPageAfterHandlingBeforeUnload().
* DumpRenderTree/mac/UIDelegate.mm:
(-[UIDelegate webView:runBeforeUnloadConfirmPanelWithMessage:initiatedByFrame:]): Ditto.
* DumpRenderTree/win/UIDelegate.cpp:
(UIDelegate::runBeforeUnloadConfirmPanelWithMessage): Ditto.
* WebKitTestRunner/InjectedBundle/Bindings/LayoutTestController.idl:
Define setShouldStayOnPageAfterHandlingBeforeUnload().
* WebKitTestRunner/InjectedBundle/InjectedBundle.cpp:
(WTR::InjectedBundle::postNewBeforeUnloadReturnValue): Post a message
to the Test Controller telling it what value it should return in its
onbeforeunload UI delegate.
* WebKitTestRunner/InjectedBundle/InjectedBundle.h:
* WebKitTestRunner/InjectedBundle/LayoutTestController.cpp:
(WTR::LayoutTestController::setShouldStayOnPageAfterHandlingBeforeUnload):
Call InjectedBundle::postNewBeforeUnloadReturnValue().
* WebKitTestRunner/InjectedBundle/LayoutTestController.h:
* WebKitTestRunner/TestController.cpp:
(WTR::TestController::TestController): Initialize
m_beforeUnloadReturnValue to true.
(WTR::runBeforeUnloadConfirmPanel): Add the correct logging and return
the value of TestController::beforeUnloadReturnValue().
(WTR::TestController::resetStateToConsistentValues): Reset
m_beforeUnloadReturnValue to true.
* WebKitTestRunner/TestController.h:
(WTR::TestController::beforeUnloadReturnValue):
(WTR::TestController::setBeforeUnloadReturnValue):
* WebKitTestRunner/TestInvocation.cpp:
(WTR::TestInvocation::didReceiveMessageFromInjectedBundle): Handle the
message posted from the injected bundle by retrieving the message body
as a WKBoolean and calling TestController::setBeforeUnloadReturnValue().

LayoutTests:

* fast/loader/form-submission-after-beforeunload-cancel-expected.txt: Added.
* fast/loader/form-submission-after-beforeunload-cancel.html: Added.

git-svn-id: https://svn.webkit.org/repository/webkit/trunk@92982 268f45cc-cd09-0410-ab3c-d52691b4dbfc
21 files changed:
LayoutTests/ChangeLog
LayoutTests/fast/loader/form-submission-after-beforeunload-cancel-expected.txt [new file with mode: 0644]
LayoutTests/fast/loader/form-submission-after-beforeunload-cancel.html [new file with mode: 0644]
Source/WebCore/ChangeLog
Source/WebCore/loader/FrameLoader.cpp
Tools/ChangeLog
Tools/DumpRenderTree/LayoutTestController.cpp
Tools/DumpRenderTree/LayoutTestController.h
Tools/DumpRenderTree/chromium/LayoutTestController.cpp
Tools/DumpRenderTree/chromium/LayoutTestController.h
Tools/DumpRenderTree/chromium/WebViewHost.cpp
Tools/DumpRenderTree/mac/UIDelegate.mm
Tools/DumpRenderTree/win/UIDelegate.cpp
Tools/WebKitTestRunner/InjectedBundle/Bindings/LayoutTestController.idl
Tools/WebKitTestRunner/InjectedBundle/InjectedBundle.cpp
Tools/WebKitTestRunner/InjectedBundle/InjectedBundle.h
Tools/WebKitTestRunner/InjectedBundle/LayoutTestController.cpp
Tools/WebKitTestRunner/InjectedBundle/LayoutTestController.h
Tools/WebKitTestRunner/TestController.cpp
Tools/WebKitTestRunner/TestController.h
Tools/WebKitTestRunner/TestInvocation.cpp