https://bugs.webkit.org/show_bug.cgi?id=20342
Reviewed by Adam Barth.
WebCore:
Do not reload the page when submitting a form, using "GET" method, and the
form action url matches the location url, except for the fragment.
Test: fast/forms/submit-change-fragment.html
* loader/FrameLoader.cpp:
(WebCore::FrameLoader::loadURL):
(WebCore::FrameLoader::loadWithDocumentLoader):
(WebCore::FrameLoader::shouldScrollToAnchor):
* loader/FrameLoader.h:
LayoutTests:
* fast/forms/submit-change-fragment-expected.txt: Added.
* fast/forms/submit-change-fragment.html: Added.
* platform/mac/Skipped:
* platform/qt/Skipped:
git-svn-id: http://svn.webkit.org/repository/webkit/trunk@74801
268f45cc-cd09-0410-ab3c-
d52691b4dbfc
+2010-12-30 Yael Aharon <yael.aharon@nokia.com>
+
+ Reviewed by Adam Barth.
+
+ REGRESSION: fast/dom/cssTarget-crash.html fails
+ https://bugs.webkit.org/show_bug.cgi?id=20342
+
+ * fast/forms/submit-change-fragment-expected.txt: Added.
+ * fast/forms/submit-change-fragment.html: Added.
+ * platform/mac/Skipped:
+ * platform/qt/Skipped:
+
2010-12-30 Philippe Normand <pnormand@igalia.com>
Unreviewed, unskip the test, it's running fine locally.
--- /dev/null
+https://bugs.webkit.org/show_bug.cgi?id=20342
+Test that when the form method is get, and the form action is the same as the current location url, but with different fragment, we do not reload the page, and the onload handler is not called again.
+
+Also test that changing the form action after the form was submitted has no effect.
+
+
+PASS
--- /dev/null
+<html>
+<script>
+if (window.layoutTestController) {
+ layoutTestController.dumpAsText();
+ layoutTestController.waitUntilDone();
+}
+
+if (document.location.href.indexOf("n=v") == -1)
+ document.location.search = "?n=v";
+
+function runTest() {
+ document.forms.f.action="#firstaction";
+ document.forms.f.submit();
+ document.forms.f.action="#secondaction";
+}
+
+function hashChanged() {
+ if (document.location.href.indexOf("firstaction") != -1) {
+ document.getElementById("console").innerHTML="PASS";
+ if (window.layoutTestController)
+ layoutTestController.notifyDone();
+ }
+}
+
+
+</script>
+<body onhashchange="hashChanged();" onload="runTest();">
+<div><a href="https://bugs.webkit.org/show_bug.cgi?id=20342">https://bugs.webkit.org/show_bug.cgi?id=20342</a></div>
+<p>Test that when the form method is get, and the form action is the same as the current location url, but with different fragment, we do not reload the page, and the onload handler is not called again.</p>
+<p>Also test that changing the form action after the form was submitted has no effect.</p>
+
+<form name="f" method="GET" action="#action"><input name="n" value="v"></form>
+<div id="console">FAIL</div>
+<script>
+</script>
+</body>
+</html>
# Skip because fix for https://bugs.webkit.org/show_bug.cgi?id=26770 was reverted
compositing/animation/animated-composited-inside-hidden.html
-# https://bugs.webkit.org/show_bug.cgi?id=20342 REGRESSION: fast/dom/cssTarget-crash.html fails
-fast/dom/cssTarget-crash.html
-
# https://bugs.webkit.org/show_bug.cgi?id=21916 Pixel test doesn't repaint entire view so result is corrupted by previous test
tables/mozilla_expected_failures/bugs/bug178855.xml
# -- timedout with --platform mac --ignore-metrics
fast/events/5056619.html
fast/events/drag-in-frames.html
-fast/dom/cssTarget-crash.html
fast/loader/null-request-after-willSendRequest.html
fast/text/international/thai-line-breaks.html
+2010-12-30 Yael Aharon <yael.aharon@nokia.com>
+
+ Reviewed by Adam Barth.
+
+ REGRESSION: fast/dom/cssTarget-crash.html fails
+ https://bugs.webkit.org/show_bug.cgi?id=20342
+
+ Do not reload the page when submitting a form, using "GET" method, and the
+ form action url matches the location url, except for the fragment.
+
+ Test: fast/forms/submit-change-fragment.html
+
+ * loader/FrameLoader.cpp:
+ (WebCore::FrameLoader::loadURL):
+ (WebCore::FrameLoader::loadWithDocumentLoader):
+ (WebCore::FrameLoader::shouldScrollToAnchor):
+ * loader/FrameLoader.h:
+
2010-12-30 Darin Adler <darin@apple.com>
Reviewed by Adam Barth.
RefPtr<DocumentLoader> oldDocumentLoader = m_documentLoader;
bool sameURL = shouldTreatURLAsSameAsCurrent(newURL);
+ const String& httpMethod = request.httpMethod();
// Make sure to do scroll to anchor processing even if the URL is
// exactly the same so pages with '#' links and DHTML side effects
// work properly.
- if (shouldScrollToAnchor(isFormSubmission, newLoadType, newURL)) {
+ if (shouldScrollToAnchor(isFormSubmission, httpMethod, newLoadType, newURL)) {
oldDocumentLoader->setTriggeringAction(action);
policyChecker()->stopCheck();
policyChecker()->setLoadType(newLoadType);
bool isFormSubmission = formState;
const KURL& newURL = loader->request().url();
+ const String& httpMethod = loader->request().httpMethod();
- if (shouldScrollToAnchor(isFormSubmission, policyChecker()->loadType(), newURL)) {
+ if (shouldScrollToAnchor(isFormSubmission, httpMethod, policyChecker()->loadType(), newURL)) {
RefPtr<DocumentLoader> oldDocumentLoader = m_documentLoader;
NavigationAction action(newURL, policyChecker()->loadType(), isFormSubmission);
loadInSameDocument(request.url(), 0, !isRedirect);
}
-bool FrameLoader::shouldScrollToAnchor(bool isFormSubmission, FrameLoadType loadType, const KURL& url)
+bool FrameLoader::shouldScrollToAnchor(bool isFormSubmission, const String& httpMethod, FrameLoadType loadType, const KURL& url)
{
// Should we do anchor navigation within the existing content?
- // We don't do this if we are submitting a form, explicitly reloading,
+ // We don't do this if we are submitting a form with method other than "GET", explicitly reloading,
// currently displaying a frameset, or if the URL does not have a fragment.
// These rules were originally based on what KHTML was doing in KHTMLPart::openURL.
// FIXME: What about load types other than Standard and Reload?
- return !isFormSubmission
+ return (!isFormSubmission || equalIgnoringCase(httpMethod, "GET"))
&& loadType != FrameLoadTypeReload
&& loadType != FrameLoadTypeReloadFromOrigin
&& loadType != FrameLoadTypeSame
void continueLoadAfterNewWindowPolicy(const ResourceRequest&, PassRefPtr<FormState>, const String& frameName, const NavigationAction&, bool shouldContinue);
void continueFragmentScrollAfterNavigationPolicy(const ResourceRequest&, bool shouldContinue);
- bool shouldScrollToAnchor(bool isFormSubmission, FrameLoadType, const KURL&);
+ bool shouldScrollToAnchor(bool isFormSubmission, const String& httpMethod, FrameLoadType, const KURL&);
void checkLoadCompleteForThisFrame();