WebCore:
authorggaren@apple.com <ggaren@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Fri, 30 Jan 2009 23:09:43 +0000 (23:09 +0000)
committerggaren@apple.com <ggaren@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Fri, 30 Jan 2009 23:09:43 +0000 (23:09 +0000)
2009-01-30  Geoffrey Garen  <ggaren@apple.com>

        Reviewed by Darin Adler.

        More scaffolding for redirect tracking. No behavior change yet.

        * bindings/js/JSHTMLFormElementCustom.cpp:
        (WebCore::JSHTMLFormElement::submit): Added scaffolding necessary for
        redirect checking in a form submission through JS. (Currently, we
        just specify "no redirect.")

        * bindings/js/ScriptController.h:
        * bindings/js/ScriptController.cpp:
        (WebCore::ScriptController::processingUserGesture):
        (WebCore::ScriptController::processingUserGestureEvent):
        (WebCore::ScriptController::isJavaScriptAnchorNavigation): Refactored
        user gesture check to make it more clear.

        (WebCore::ScriptController::pageIsProcessingUserGesture): Added a helper
        for checking if there's a user gesture in any frame on the page (a more
        relaxed rule than our popup blocking rule, which requires the user
        gesture to occur in the frame that's executing JavaScript.)

        * html/HTMLFormElement.h:
        * html/HTMLFormElement.cpp:
        (WebCore::HTMLFormElement::submit): Added scaffolding necessary for
        redirect checking in a form submission through the DOM. (Currently, we
        just specify "no redirect.")

        * html/HTMLFormElement.idl: Made submit custom so it can participate
        in redirect checking.

        * loader/FrameLoader.h:
        * loader/FrameLoader.cpp:
        (WebCore::FormSubmission::FormSubmission): Clarified some names, and
        added a "lockHistory" parameter to form submissions, to match other
        navigations.

        (WebCore::FrameLoader::submitFormAgain):
        (WebCore::FrameLoader::submitForm): Use the lockHistory parameter.

        (WebCore::FrameLoader::userGestureHint): Refactored this function for
        clarity, and added a FIXME for a change I was too scared to make myself.
        (Really, we should just get rid of this function.)

        (WebCore::FrameLoader::loadFrameRequestWithFormAndValues): Refactored
        to pass a FrameLoadType to form posts, too, so they can participate in
        redirect tracking.

        (WebCore::FrameLoader::loadPostRequest):
        (WebCore::FrameLoader::continueFragmentScrollAfterNavigationPolicy):
        (WebCore::FrameLoader::loadItem): Use the lockHistory parameter.

LayoutTests:

2009-01-30  Geoffrey Garen  <ggaren@apple.com>

        Reviewed by Darin Adler.

        More redirect layout test work.

        Added tests (expected to fail) for form submission via JavaScript:

        * http/tests/history/redirect-js-form-submit-0-seconds-expected.txt: Added.
        * http/tests/history/redirect-js-form-submit-0-seconds.html: Added.
        * http/tests/history/redirect-js-form-submit-2-seconds-expected.txt: Added.
        * http/tests/history/redirect-js-form-submit-2-seconds.html: Added.
        * http/tests/history/redirect-js-form-submit-before-load-expected.txt: Added.
        * http/tests/history/redirect-js-form-submit-before-load.html: Added.

        Updated these tests to dump their back/forward lists, to check for
        back/forward regressions, and to use # instead of ? to communicate between
        URLs, since, to my surprise, form submissions can't use query strings.

        * http/tests/history/redirect-200-refresh-0-seconds-expected.txt:
        * http/tests/history/redirect-200-refresh-0-seconds.pl:
        * http/tests/history/redirect-200-refresh-2-seconds-expected.txt:
        * http/tests/history/redirect-200-refresh-2-seconds.pl:
        * http/tests/history/redirect-301-expected.txt:
        * http/tests/history/redirect-301.pl:
        * http/tests/history/redirect-302-expected.txt:
        * http/tests/history/redirect-302.pl:
        * http/tests/history/redirect-303-expected.txt:
        * http/tests/history/redirect-303.pl:
        * http/tests/history/redirect-307-expected.txt:
        * http/tests/history/redirect-307.pl:
        * http/tests/history/redirect-js-document-location-0-seconds-expected.txt:
        * http/tests/history/redirect-js-document-location-0-seconds.html:
        * http/tests/history/redirect-js-document-location-2-seconds-expected.txt:
        * http/tests/history/redirect-js-document-location-2-seconds.html:
        * http/tests/history/redirect-js-document-location-before-load-expected.txt:
        * http/tests/history/redirect-js-document-location-before-load.html:
        * http/tests/history/redirect-js-location-0-seconds-expected.txt:
        * http/tests/history/redirect-js-location-0-seconds.html:
        * http/tests/history/redirect-js-location-2-seconds-expected.txt:
        * http/tests/history/redirect-js-location-2-seconds.html:
        * http/tests/history/redirect-js-location-assign-0-seconds-expected.txt:
        * http/tests/history/redirect-js-location-assign-0-seconds.html:
        * http/tests/history/redirect-js-location-assign-2-seconds-expected.txt:
        * http/tests/history/redirect-js-location-assign-2-seconds.html:
        * http/tests/history/redirect-js-location-assign-before-load-expected.txt:
        * http/tests/history/redirect-js-location-assign-before-load.html:
        * http/tests/history/redirect-js-location-before-load-expected.txt:
        * http/tests/history/redirect-js-location-before-load.html:
        * http/tests/history/redirect-js-location-href-0-seconds-expected.txt:
        * http/tests/history/redirect-js-location-href-0-seconds.html:
        * http/tests/history/redirect-js-location-href-2-seconds-expected.txt:
        * http/tests/history/redirect-js-location-href-2-seconds.html:
        * http/tests/history/redirect-js-location-href-before-load-expected.txt:
        * http/tests/history/redirect-js-location-href-before-load.html:
        * http/tests/history/redirect-js-location-replace-0-seconds-expected.txt:
        * http/tests/history/redirect-js-location-replace-0-seconds.html:
        * http/tests/history/redirect-js-location-replace-2-seconds-expected.txt:
        * http/tests/history/redirect-js-location-replace-2-seconds.html:
        * http/tests/history/redirect-js-location-replace-before-load-expected.txt:
        * http/tests/history/redirect-js-location-replace-before-load.html:
        * http/tests/history/redirect-meta-refresh-0-seconds-expected.txt:
        * http/tests/history/redirect-meta-refresh-0-seconds.html:
        * http/tests/history/redirect-meta-refresh-2-seconds-expected.txt:
        * http/tests/history/redirect-meta-refresh-2-seconds.html:
        * http/tests/history/resources/redirect-target.html:

git-svn-id: https://svn.webkit.org/repository/webkit/trunk@40424 268f45cc-cd09-0410-ab3c-d52691b4dbfc

63 files changed:
LayoutTests/ChangeLog
LayoutTests/http/tests/history/redirect-200-refresh-0-seconds-expected.txt
LayoutTests/http/tests/history/redirect-200-refresh-0-seconds.pl
LayoutTests/http/tests/history/redirect-200-refresh-2-seconds-expected.txt
LayoutTests/http/tests/history/redirect-200-refresh-2-seconds.pl
LayoutTests/http/tests/history/redirect-301-expected.txt
LayoutTests/http/tests/history/redirect-301.pl
LayoutTests/http/tests/history/redirect-302-expected.txt
LayoutTests/http/tests/history/redirect-302.pl
LayoutTests/http/tests/history/redirect-303-expected.txt
LayoutTests/http/tests/history/redirect-303.pl
LayoutTests/http/tests/history/redirect-307-expected.txt
LayoutTests/http/tests/history/redirect-307.pl
LayoutTests/http/tests/history/redirect-js-document-location-0-seconds-expected.txt
LayoutTests/http/tests/history/redirect-js-document-location-0-seconds.html
LayoutTests/http/tests/history/redirect-js-document-location-2-seconds-expected.txt
LayoutTests/http/tests/history/redirect-js-document-location-2-seconds.html
LayoutTests/http/tests/history/redirect-js-document-location-before-load-expected.txt
LayoutTests/http/tests/history/redirect-js-document-location-before-load.html
LayoutTests/http/tests/history/redirect-js-form-submit-0-seconds-expected.txt [new file with mode: 0644]
LayoutTests/http/tests/history/redirect-js-form-submit-0-seconds.html [new file with mode: 0644]
LayoutTests/http/tests/history/redirect-js-form-submit-2-seconds-expected.txt [new file with mode: 0644]
LayoutTests/http/tests/history/redirect-js-form-submit-2-seconds.html [new file with mode: 0644]
LayoutTests/http/tests/history/redirect-js-form-submit-before-load-expected.txt [new file with mode: 0644]
LayoutTests/http/tests/history/redirect-js-form-submit-before-load.html [new file with mode: 0644]
LayoutTests/http/tests/history/redirect-js-location-0-seconds-expected.txt
LayoutTests/http/tests/history/redirect-js-location-0-seconds.html
LayoutTests/http/tests/history/redirect-js-location-2-seconds-expected.txt
LayoutTests/http/tests/history/redirect-js-location-2-seconds.html
LayoutTests/http/tests/history/redirect-js-location-assign-0-seconds-expected.txt
LayoutTests/http/tests/history/redirect-js-location-assign-0-seconds.html
LayoutTests/http/tests/history/redirect-js-location-assign-2-seconds-expected.txt
LayoutTests/http/tests/history/redirect-js-location-assign-2-seconds.html
LayoutTests/http/tests/history/redirect-js-location-assign-before-load-expected.txt
LayoutTests/http/tests/history/redirect-js-location-assign-before-load.html
LayoutTests/http/tests/history/redirect-js-location-before-load-expected.txt
LayoutTests/http/tests/history/redirect-js-location-before-load.html
LayoutTests/http/tests/history/redirect-js-location-href-0-seconds-expected.txt
LayoutTests/http/tests/history/redirect-js-location-href-0-seconds.html
LayoutTests/http/tests/history/redirect-js-location-href-2-seconds-expected.txt
LayoutTests/http/tests/history/redirect-js-location-href-2-seconds.html
LayoutTests/http/tests/history/redirect-js-location-href-before-load-expected.txt
LayoutTests/http/tests/history/redirect-js-location-href-before-load.html
LayoutTests/http/tests/history/redirect-js-location-replace-0-seconds-expected.txt
LayoutTests/http/tests/history/redirect-js-location-replace-0-seconds.html
LayoutTests/http/tests/history/redirect-js-location-replace-2-seconds-expected.txt
LayoutTests/http/tests/history/redirect-js-location-replace-2-seconds.html
LayoutTests/http/tests/history/redirect-js-location-replace-before-load-expected.txt
LayoutTests/http/tests/history/redirect-js-location-replace-before-load.html
LayoutTests/http/tests/history/redirect-meta-refresh-0-seconds-expected.txt
LayoutTests/http/tests/history/redirect-meta-refresh-0-seconds.html
LayoutTests/http/tests/history/redirect-meta-refresh-2-seconds-expected.txt
LayoutTests/http/tests/history/redirect-meta-refresh-2-seconds.html
LayoutTests/http/tests/history/resources/redirect-target.html
WebCore/ChangeLog
WebCore/bindings/js/JSHTMLFormElementCustom.cpp
WebCore/bindings/js/ScriptController.cpp
WebCore/bindings/js/ScriptController.h
WebCore/html/HTMLFormElement.cpp
WebCore/html/HTMLFormElement.h
WebCore/html/HTMLFormElement.idl
WebCore/loader/FrameLoader.cpp
WebCore/loader/FrameLoader.h

index ec8a60a..52fbab3 100644 (file)
@@ -1,3 +1,70 @@
+2009-01-30  Geoffrey Garen  <ggaren@apple.com>
+
+        Reviewed by Darin Adler.
+
+        More redirect layout test work.
+        
+        Added tests (expected to fail) for form submission via JavaScript:
+        
+        * http/tests/history/redirect-js-form-submit-0-seconds-expected.txt: Added.
+        * http/tests/history/redirect-js-form-submit-0-seconds.html: Added.
+        * http/tests/history/redirect-js-form-submit-2-seconds-expected.txt: Added.
+        * http/tests/history/redirect-js-form-submit-2-seconds.html: Added.
+        * http/tests/history/redirect-js-form-submit-before-load-expected.txt: Added.
+        * http/tests/history/redirect-js-form-submit-before-load.html: Added.
+        
+        Updated these tests to dump their back/forward lists, to check for
+        back/forward regressions, and to use # instead of ? to communicate between
+        URLs, since, to my surprise, form submissions can't use query strings.
+
+        * http/tests/history/redirect-200-refresh-0-seconds-expected.txt:
+        * http/tests/history/redirect-200-refresh-0-seconds.pl:
+        * http/tests/history/redirect-200-refresh-2-seconds-expected.txt:
+        * http/tests/history/redirect-200-refresh-2-seconds.pl:
+        * http/tests/history/redirect-301-expected.txt:
+        * http/tests/history/redirect-301.pl:
+        * http/tests/history/redirect-302-expected.txt:
+        * http/tests/history/redirect-302.pl:
+        * http/tests/history/redirect-303-expected.txt:
+        * http/tests/history/redirect-303.pl:
+        * http/tests/history/redirect-307-expected.txt:
+        * http/tests/history/redirect-307.pl:
+        * http/tests/history/redirect-js-document-location-0-seconds-expected.txt:
+        * http/tests/history/redirect-js-document-location-0-seconds.html:
+        * http/tests/history/redirect-js-document-location-2-seconds-expected.txt:
+        * http/tests/history/redirect-js-document-location-2-seconds.html:
+        * http/tests/history/redirect-js-document-location-before-load-expected.txt:
+        * http/tests/history/redirect-js-document-location-before-load.html:
+        * http/tests/history/redirect-js-location-0-seconds-expected.txt:
+        * http/tests/history/redirect-js-location-0-seconds.html:
+        * http/tests/history/redirect-js-location-2-seconds-expected.txt:
+        * http/tests/history/redirect-js-location-2-seconds.html:
+        * http/tests/history/redirect-js-location-assign-0-seconds-expected.txt:
+        * http/tests/history/redirect-js-location-assign-0-seconds.html:
+        * http/tests/history/redirect-js-location-assign-2-seconds-expected.txt:
+        * http/tests/history/redirect-js-location-assign-2-seconds.html:
+        * http/tests/history/redirect-js-location-assign-before-load-expected.txt:
+        * http/tests/history/redirect-js-location-assign-before-load.html:
+        * http/tests/history/redirect-js-location-before-load-expected.txt:
+        * http/tests/history/redirect-js-location-before-load.html:
+        * http/tests/history/redirect-js-location-href-0-seconds-expected.txt:
+        * http/tests/history/redirect-js-location-href-0-seconds.html:
+        * http/tests/history/redirect-js-location-href-2-seconds-expected.txt:
+        * http/tests/history/redirect-js-location-href-2-seconds.html:
+        * http/tests/history/redirect-js-location-href-before-load-expected.txt:
+        * http/tests/history/redirect-js-location-href-before-load.html:
+        * http/tests/history/redirect-js-location-replace-0-seconds-expected.txt:
+        * http/tests/history/redirect-js-location-replace-0-seconds.html:
+        * http/tests/history/redirect-js-location-replace-2-seconds-expected.txt:
+        * http/tests/history/redirect-js-location-replace-2-seconds.html:
+        * http/tests/history/redirect-js-location-replace-before-load-expected.txt:
+        * http/tests/history/redirect-js-location-replace-before-load.html:
+        * http/tests/history/redirect-meta-refresh-0-seconds-expected.txt:
+        * http/tests/history/redirect-meta-refresh-0-seconds.html:
+        * http/tests/history/redirect-meta-refresh-2-seconds-expected.txt:
+        * http/tests/history/redirect-meta-refresh-2-seconds.html:
+        * http/tests/history/resources/redirect-target.html:
+
 2009-01-30  Pierre-Olivier Latour  <pol@apple.com>
 
         Updated the references images for the media layout tests on Tiger since they now differ from Leopard after installing QuickTime 7.6.
index ae83a8d..062b69b 100644 (file)
@@ -2,3 +2,7 @@ This page is the target of a redirect.
 
 PASS: History item count should be 1 and is.
 
+
+============== Back Forward List ==============
+curr->  http://127.0.0.1:8000/history/resources/redirect-target.html#1  **nav target**
+===============================================
index 5d4fedc..db2340e 100755 (executable)
@@ -2,7 +2,7 @@
 # Script to generate a Refresh header HTTP redirect
 
 print "Status: 200 ok\r\n";
-print "Refresh: 0; url=resources/redirect-target.html?1\r\n";
+print "Refresh: 0; url=resources/redirect-target.html#1\r\n";
 print "Content-type: text/html\r\n";
 print "\r\n";
 
index a4d02fb..a2faff2 100644 (file)
@@ -2,3 +2,8 @@ This page is the target of a redirect.
 
 FAIL: History item count should be 1 but instead is 2.
 
+
+============== Back Forward List ==============
+        http://127.0.0.1:8000/history/redirect-200-refresh-2-seconds.pl  **nav target**
+curr->  http://127.0.0.1:8000/history/resources/redirect-target.html#1  **nav target**
+===============================================
index da5c831..734443a 100755 (executable)
@@ -2,7 +2,7 @@
 # Script to generate a Refresh header HTTP redirect
 
 print "Status: 200 ok\r\n";
-print "Refresh: 2; url=resources/redirect-target.html?1\r\n";
+print "Refresh: 2; url=resources/redirect-target.html#1\r\n";
 print "Content-type: text/html\r\n";
 print "\r\n";
 
index ae83a8d..062b69b 100644 (file)
@@ -2,3 +2,7 @@ This page is the target of a redirect.
 
 PASS: History item count should be 1 and is.
 
+
+============== Back Forward List ==============
+curr->  http://127.0.0.1:8000/history/resources/redirect-target.html#1  **nav target**
+===============================================
index 6aaa601..f0f15ec 100755 (executable)
@@ -2,7 +2,7 @@
 # Script to generate a 301 HTTP redirect
 
 print "Status: 301 Moved Permanently\r\n";
-print "Location: resources/redirect-target.html?1\r\n";
+print "Location: resources/redirect-target.html#1\r\n";
 print "Content-type: text/html\r\n";
 print "\r\n";
 
index ae83a8d..062b69b 100644 (file)
@@ -2,3 +2,7 @@ This page is the target of a redirect.
 
 PASS: History item count should be 1 and is.
 
+
+============== Back Forward List ==============
+curr->  http://127.0.0.1:8000/history/resources/redirect-target.html#1  **nav target**
+===============================================
index b4e5497..e06310f 100755 (executable)
@@ -2,7 +2,7 @@
 # Script to generate a 302 HTTP redirect
 
 print "Status: 302 Moved Temporarily\r\n";
-print "Location: resources/redirect-target.html?1\r\n";
+print "Location: resources/redirect-target.html#1\r\n";
 print "Content-type: text/html\r\n";
 print "\r\n";
 
index ae83a8d..062b69b 100644 (file)
@@ -2,3 +2,7 @@ This page is the target of a redirect.
 
 PASS: History item count should be 1 and is.
 
+
+============== Back Forward List ==============
+curr->  http://127.0.0.1:8000/history/resources/redirect-target.html#1  **nav target**
+===============================================
index c6c7a26..c7891bf 100755 (executable)
@@ -2,7 +2,7 @@
 # Script to generate a 303 HTTP redirect
 
 print "Status: 303 See Other\r\n";
-print "Location: resources/redirect-target.html?1\r\n";
+print "Location: resources/redirect-target.html#1\r\n";
 print "Content-type: text/html\r\n";
 print "\r\n";
 
index ae83a8d..062b69b 100644 (file)
@@ -2,3 +2,7 @@ This page is the target of a redirect.
 
 PASS: History item count should be 1 and is.
 
+
+============== Back Forward List ==============
+curr->  http://127.0.0.1:8000/history/resources/redirect-target.html#1  **nav target**
+===============================================
index e60dab9..c44db9e 100755 (executable)
@@ -2,7 +2,7 @@
 # Script to generate a 307 HTTP redirect
 
 print "Status: 307 Moved Temporarily\r\n";
-print "Location: resources/redirect-target.html?1\r\n";
+print "Location: resources/redirect-target.html#1\r\n";
 print "Content-type: text/html\r\n";
 print "\r\n";
 
index a4d02fb..7619344 100644 (file)
@@ -2,3 +2,8 @@ This page is the target of a redirect.
 
 FAIL: History item count should be 1 but instead is 2.
 
+
+============== Back Forward List ==============
+        http://127.0.0.1:8000/history/redirect-js-document-location-0-seconds.html  **nav target**
+curr->  http://127.0.0.1:8000/history/resources/redirect-target.html#1  **nav target**
+===============================================
index dc585c0..513305b 100644 (file)
@@ -7,7 +7,7 @@ if (window.layoutTestController) {
     layoutTestController.keepWebHistory();
     layoutTestController.waitUntilDone();
 }
-setTimeout(function () { document.location = "resources/redirect-target.html?1"; }, 0);
+setTimeout(function () { document.location = "resources/redirect-target.html#1"; }, 0);
 </script>
 </head>
 
index a4d02fb..0e92c8b 100644 (file)
@@ -2,3 +2,8 @@ This page is the target of a redirect.
 
 FAIL: History item count should be 1 but instead is 2.
 
+
+============== Back Forward List ==============
+        http://127.0.0.1:8000/history/redirect-js-document-location-2-seconds.html  **nav target**
+curr->  http://127.0.0.1:8000/history/resources/redirect-target.html#1  **nav target**
+===============================================
index 7eb60a7..f175e51 100644 (file)
@@ -7,7 +7,7 @@ if (window.layoutTestController) {
     layoutTestController.keepWebHistory();
     layoutTestController.waitUntilDone();
 }
-setTimeout(function () { document.location = "resources/redirect-target.html?1"; }, 2000);
+setTimeout(function () { document.location = "resources/redirect-target.html#1"; }, 2000);
 </script>
 </head>
 
index a4d02fb..efbe835 100644 (file)
@@ -2,3 +2,8 @@ This page is the target of a redirect.
 
 FAIL: History item count should be 1 but instead is 2.
 
+
+============== Back Forward List ==============
+        http://127.0.0.1:8000/history/redirect-js-document-location-before-load.html  **nav target**
+curr->  http://127.0.0.1:8000/history/resources/redirect-target.html#1  **nav target**
+===============================================
index 8b69a69..f6240eb 100644 (file)
@@ -7,7 +7,7 @@ if (window.layoutTestController) {
     layoutTestController.keepWebHistory();
     layoutTestController.waitUntilDone();
 }
-document.location = "resources/redirect-target.html?1";
+document.location = "resources/redirect-target.html#1";
 </script>
 </head>
 
diff --git a/LayoutTests/http/tests/history/redirect-js-form-submit-0-seconds-expected.txt b/LayoutTests/http/tests/history/redirect-js-form-submit-0-seconds-expected.txt
new file mode 100644 (file)
index 0000000..77ecf29
--- /dev/null
@@ -0,0 +1,9 @@
+This page is the target of a redirect.
+
+FAIL: History item count should be 1 but instead is 2.
+
+
+============== Back Forward List ==============
+        http://127.0.0.1:8000/history/redirect-js-form-submit-0-seconds.html  **nav target**
+curr->  http://127.0.0.1:8000/history/resources/redirect-target.html?#1  **nav target**
+===============================================
diff --git a/LayoutTests/http/tests/history/redirect-js-form-submit-0-seconds.html b/LayoutTests/http/tests/history/redirect-js-form-submit-0-seconds.html
new file mode 100644 (file)
index 0000000..074e8d8
--- /dev/null
@@ -0,0 +1,18 @@
+<html>
+<head>
+<title>JavaScript Redirect</title>
+
+<script>
+if (window.layoutTestController) {
+    layoutTestController.keepWebHistory();
+    layoutTestController.waitUntilDone();
+}
+setTimeout(function () { document.getElementById("form").submit(); }, 0);
+</script>
+</head>
+
+<body>
+<p>This page is a JavaScript redirect on a 0 second delay.</p>
+<form id="form" action="resources/redirect-target.html#1"></form>
+</body>
+</html>
diff --git a/LayoutTests/http/tests/history/redirect-js-form-submit-2-seconds-expected.txt b/LayoutTests/http/tests/history/redirect-js-form-submit-2-seconds-expected.txt
new file mode 100644 (file)
index 0000000..809ab18
--- /dev/null
@@ -0,0 +1,9 @@
+This page is the target of a redirect.
+
+FAIL: History item count should be 1 but instead is 2.
+
+
+============== Back Forward List ==============
+        http://127.0.0.1:8000/history/redirect-js-form-submit-2-seconds.html  **nav target**
+curr->  http://127.0.0.1:8000/history/resources/redirect-target.html?#1  **nav target**
+===============================================
diff --git a/LayoutTests/http/tests/history/redirect-js-form-submit-2-seconds.html b/LayoutTests/http/tests/history/redirect-js-form-submit-2-seconds.html
new file mode 100644 (file)
index 0000000..c0fc5c6
--- /dev/null
@@ -0,0 +1,18 @@
+<html>
+<head>
+<title>JavaScript Redirect</title>
+
+<script>
+if (window.layoutTestController) {
+    layoutTestController.keepWebHistory();
+    layoutTestController.waitUntilDone();
+}
+setTimeout(function () { document.getElementById("form").submit(); }, 2000);
+</script>
+</head>
+
+<body>
+<p>This page is a JavaScript redirect on a 2 second delay.</p>
+<form id="form" action="resources/redirect-target.html#1"></form>
+</body>
+</html>
diff --git a/LayoutTests/http/tests/history/redirect-js-form-submit-before-load-expected.txt b/LayoutTests/http/tests/history/redirect-js-form-submit-before-load-expected.txt
new file mode 100644 (file)
index 0000000..759b4c8
--- /dev/null
@@ -0,0 +1,9 @@
+This page is the target of a redirect.
+
+FAIL: History item count should be 1 but instead is 2.
+
+
+============== Back Forward List ==============
+        http://127.0.0.1:8000/history/redirect-js-form-submit-before-load.html  **nav target**
+curr->  http://127.0.0.1:8000/history/resources/redirect-target.html?#1  **nav target**
+===============================================
diff --git a/LayoutTests/http/tests/history/redirect-js-form-submit-before-load.html b/LayoutTests/http/tests/history/redirect-js-form-submit-before-load.html
new file mode 100644 (file)
index 0000000..c336b7a
--- /dev/null
@@ -0,0 +1,20 @@
+<html>
+<head>
+<title>JavaScript Redirect</title>
+
+<script>
+if (window.layoutTestController) {
+    layoutTestController.keepWebHistory();
+    layoutTestController.waitUntilDone();
+}
+</script>
+</head>
+
+<body>
+<p>This page is a JavaScript redirect.</p>
+<form id="form" action="resources/redirect-target.html#1"></form>
+<script>
+document.getElementById("form").submit();
+</script>
+</body>
+</html>
index a4d02fb..c9278ae 100644 (file)
@@ -2,3 +2,8 @@ This page is the target of a redirect.
 
 FAIL: History item count should be 1 but instead is 2.
 
+
+============== Back Forward List ==============
+        http://127.0.0.1:8000/history/redirect-js-location-0-seconds.html  **nav target**
+curr->  http://127.0.0.1:8000/history/resources/redirect-target.html#1  **nav target**
+===============================================
index f7ab092..3259d64 100644 (file)
@@ -7,7 +7,7 @@ if (window.layoutTestController) {
     layoutTestController.keepWebHistory();
     layoutTestController.waitUntilDone();
 }
-setTimeout(function () { location = "resources/redirect-target.html?1"; }, 0);
+setTimeout(function () { location = "resources/redirect-target.html#1"; }, 0);
 </script>
 </head>
 
index a4d02fb..9c257a7 100644 (file)
@@ -2,3 +2,8 @@ This page is the target of a redirect.
 
 FAIL: History item count should be 1 but instead is 2.
 
+
+============== Back Forward List ==============
+        http://127.0.0.1:8000/history/redirect-js-location-2-seconds.html  **nav target**
+curr->  http://127.0.0.1:8000/history/resources/redirect-target.html#1  **nav target**
+===============================================
index d708731..4b1e76c 100644 (file)
@@ -7,7 +7,7 @@ if (window.layoutTestController) {
     layoutTestController.keepWebHistory();
     layoutTestController.waitUntilDone();
 }
-setTimeout(function () { location = "resources/redirect-target.html?1"; }, 2000);
+setTimeout(function () { location = "resources/redirect-target.html#1"; }, 2000);
 </script>
 </head>
 
index a4d02fb..46e198c 100644 (file)
@@ -2,3 +2,8 @@ This page is the target of a redirect.
 
 FAIL: History item count should be 1 but instead is 2.
 
+
+============== Back Forward List ==============
+        http://127.0.0.1:8000/history/redirect-js-location-assign-0-seconds.html  **nav target**
+curr->  http://127.0.0.1:8000/history/resources/redirect-target.html#1  **nav target**
+===============================================
index c2a2a36..5c0bd67 100644 (file)
@@ -7,7 +7,7 @@ if (window.layoutTestController) {
     layoutTestController.keepWebHistory();
     layoutTestController.waitUntilDone();
 }
-setTimeout(function () { location.assign("resources/redirect-target.html?1"); }, 0);
+setTimeout(function () { location.assign("resources/redirect-target.html#1"); }, 0);
 </script>
 </head>
 
index a4d02fb..15c5d47 100644 (file)
@@ -2,3 +2,8 @@ This page is the target of a redirect.
 
 FAIL: History item count should be 1 but instead is 2.
 
+
+============== Back Forward List ==============
+        http://127.0.0.1:8000/history/redirect-js-location-assign-2-seconds.html  **nav target**
+curr->  http://127.0.0.1:8000/history/resources/redirect-target.html#1  **nav target**
+===============================================
index bb4dd53..c8b2e28 100644 (file)
@@ -7,7 +7,7 @@ if (window.layoutTestController) {
     layoutTestController.keepWebHistory();
     layoutTestController.waitUntilDone();
 }
-setTimeout(function () { location.assign("resources/redirect-target.html?1"); }, 2000);
+setTimeout(function () { location.assign("resources/redirect-target.html#1"); }, 2000);
 </script>
 </head>
 
index a4d02fb..42a1259 100644 (file)
@@ -2,3 +2,8 @@ This page is the target of a redirect.
 
 FAIL: History item count should be 1 but instead is 2.
 
+
+============== Back Forward List ==============
+        http://127.0.0.1:8000/history/redirect-js-location-assign-before-load.html  **nav target**
+curr->  http://127.0.0.1:8000/history/resources/redirect-target.html#1  **nav target**
+===============================================
index 76a5906..7717b04 100644 (file)
@@ -7,7 +7,7 @@ if (window.layoutTestController) {
     layoutTestController.keepWebHistory();
     layoutTestController.waitUntilDone();
 }
-location.assign("resources/redirect-target.html?1");
+location.assign("resources/redirect-target.html#1");
 </script>
 </head>
 
index a4d02fb..b6daf9e 100644 (file)
@@ -2,3 +2,8 @@ This page is the target of a redirect.
 
 FAIL: History item count should be 1 but instead is 2.
 
+
+============== Back Forward List ==============
+        http://127.0.0.1:8000/history/redirect-js-location-before-load.html  **nav target**
+curr->  http://127.0.0.1:8000/history/resources/redirect-target.html#1  **nav target**
+===============================================
index d8b0b59..722c75b 100644 (file)
@@ -7,7 +7,7 @@ if (window.layoutTestController) {
     layoutTestController.keepWebHistory();
     layoutTestController.waitUntilDone();
 }
-location = "resources/redirect-target.html?1";
+location = "resources/redirect-target.html#1";
 </script>
 </head>
 
index a4d02fb..9c3fdd9 100644 (file)
@@ -2,3 +2,8 @@ This page is the target of a redirect.
 
 FAIL: History item count should be 1 but instead is 2.
 
+
+============== Back Forward List ==============
+        http://127.0.0.1:8000/history/redirect-js-location-href-0-seconds.html  **nav target**
+curr->  http://127.0.0.1:8000/history/resources/redirect-target.html#1  **nav target**
+===============================================
index c97fd9a..3e84d1e 100644 (file)
@@ -7,7 +7,7 @@ if (window.layoutTestController) {
     layoutTestController.keepWebHistory();
     layoutTestController.waitUntilDone();
 }
-setTimeout(function () { location.href = "resources/redirect-target.html?1"; }, 0);
+setTimeout(function () { location.href = "resources/redirect-target.html#1"; }, 0);
 </script>
 </head>
 
index a4d02fb..7db9b7e 100644 (file)
@@ -2,3 +2,8 @@ This page is the target of a redirect.
 
 FAIL: History item count should be 1 but instead is 2.
 
+
+============== Back Forward List ==============
+        http://127.0.0.1:8000/history/redirect-js-location-href-2-seconds.html  **nav target**
+curr->  http://127.0.0.1:8000/history/resources/redirect-target.html#1  **nav target**
+===============================================
index 15e8c6d..8083185 100644 (file)
@@ -7,7 +7,7 @@ if (window.layoutTestController) {
     layoutTestController.keepWebHistory();
     layoutTestController.waitUntilDone();
 }
-setTimeout(function () { location.href = "resources/redirect-target.html?1"; }, 2000);
+setTimeout(function () { location.href = "resources/redirect-target.html#1"; }, 2000);
 </script>
 </head>
 
index a4d02fb..3cc9c6b 100644 (file)
@@ -2,3 +2,8 @@ This page is the target of a redirect.
 
 FAIL: History item count should be 1 but instead is 2.
 
+
+============== Back Forward List ==============
+        http://127.0.0.1:8000/history/redirect-js-location-href-before-load.html  **nav target**
+curr->  http://127.0.0.1:8000/history/resources/redirect-target.html#1  **nav target**
+===============================================
index 516da4e..b963ccd 100644 (file)
@@ -7,7 +7,7 @@ if (window.layoutTestController) {
     layoutTestController.keepWebHistory();
     layoutTestController.waitUntilDone();
 }
-location.href = "resources/redirect-target.html?1";
+location.href = "resources/redirect-target.html#1";
 </script>
 </head>
 
index ae83a8d..062b69b 100644 (file)
@@ -2,3 +2,7 @@ This page is the target of a redirect.
 
 PASS: History item count should be 1 and is.
 
+
+============== Back Forward List ==============
+curr->  http://127.0.0.1:8000/history/resources/redirect-target.html#1  **nav target**
+===============================================
index 01c26cf..05c0ca4 100644 (file)
@@ -7,7 +7,7 @@ if (window.layoutTestController) {
     layoutTestController.keepWebHistory();
     layoutTestController.waitUntilDone();
 }
-setTimeout(function () { location.replace("resources/redirect-target.html?1"); }, 0);
+setTimeout(function () { location.replace("resources/redirect-target.html#1"); }, 0);
 </script>
 </head>
 
index ae83a8d..062b69b 100644 (file)
@@ -2,3 +2,7 @@ This page is the target of a redirect.
 
 PASS: History item count should be 1 and is.
 
+
+============== Back Forward List ==============
+curr->  http://127.0.0.1:8000/history/resources/redirect-target.html#1  **nav target**
+===============================================
index 381ce22..2c31588 100644 (file)
@@ -7,7 +7,7 @@ if (window.layoutTestController) {
     layoutTestController.keepWebHistory();
     layoutTestController.waitUntilDone();
 }
-setTimeout(function () { location.replace("resources/redirect-target.html?1"); }, 2000);
+setTimeout(function () { location.replace("resources/redirect-target.html#1"); }, 2000);
 </script>
 </head>
 
index ae83a8d..062b69b 100644 (file)
@@ -2,3 +2,7 @@ This page is the target of a redirect.
 
 PASS: History item count should be 1 and is.
 
+
+============== Back Forward List ==============
+curr->  http://127.0.0.1:8000/history/resources/redirect-target.html#1  **nav target**
+===============================================
index 11a4dcf..32266a6 100644 (file)
@@ -7,7 +7,7 @@ if (window.layoutTestController) {
     layoutTestController.keepWebHistory();
     layoutTestController.waitUntilDone();
 }
-location.replace("resources/redirect-target.html?1");
+location.replace("resources/redirect-target.html#1");
 </script>
 </head>
 
index ae83a8d..062b69b 100644 (file)
@@ -2,3 +2,7 @@ This page is the target of a redirect.
 
 PASS: History item count should be 1 and is.
 
+
+============== Back Forward List ==============
+curr->  http://127.0.0.1:8000/history/resources/redirect-target.html#1  **nav target**
+===============================================
index b2b0ee2..6e78ec5 100644 (file)
@@ -1,6 +1,6 @@
 <html>
 <head>
-<meta http-equiv="Refresh" content="0; url=resources/redirect-target.html?1">
+<meta http-equiv="Refresh" content="0; url=resources/redirect-target.html#1">
 <title>Meta Refresh Redirect</title>
 <script>
 if (window.layoutTestController) {
index a4d02fb..226d943 100644 (file)
@@ -2,3 +2,8 @@ This page is the target of a redirect.
 
 FAIL: History item count should be 1 but instead is 2.
 
+
+============== Back Forward List ==============
+        http://127.0.0.1:8000/history/redirect-meta-refresh-2-seconds.html  **nav target**
+curr->  http://127.0.0.1:8000/history/resources/redirect-target.html#1  **nav target**
+===============================================
index 1b7abbf..b9f6549 100644 (file)
@@ -1,6 +1,6 @@
 <html>
 <head>
-<meta http-equiv="Refresh" content="2; url=resources/redirect-target.html?1">
+<meta http-equiv="Refresh" content="2; url=resources/redirect-target.html#1">
 <title>Meta Refresh Redirect</title>
 <script>
 if (window.layoutTestController) {
index addfac0..b3ea4ee 100644 (file)
@@ -13,7 +13,7 @@ function log(s)
 
 function testHistoryItemCount()
 {
-    var expected = parseInt(location.search.slice(1));
+    var expected = parseInt(location.hash.slice(1));
     var actual = layoutTestController.webHistoryItemCount + 1; // Add one to include the referring page, which loaded before we started recording history.
     if (actual === expected)
         log("PASS: History item count should be " + expected + " and is.");
@@ -25,6 +25,7 @@ window.addEventListener("load", function () {
     if (window.layoutTestController) {
         layoutTestController.dumpAsText();
         testHistoryItemCount();
+        layoutTestController.dumpBackForwardList();
         layoutTestController.notifyDone();
     }
 }, false);
index 042ae5c..5764d01 100644 (file)
@@ -1,3 +1,56 @@
+2009-01-30  Geoffrey Garen  <ggaren@apple.com>
+
+        Reviewed by Darin Adler.
+        
+        More scaffolding for redirect tracking. No behavior change yet.
+
+        * bindings/js/JSHTMLFormElementCustom.cpp:
+        (WebCore::JSHTMLFormElement::submit): Added scaffolding necessary for
+        redirect checking in a form submission through JS. (Currently, we
+        just specify "no redirect.")
+
+        * bindings/js/ScriptController.h:
+        * bindings/js/ScriptController.cpp:
+        (WebCore::ScriptController::processingUserGesture):
+        (WebCore::ScriptController::processingUserGestureEvent):
+        (WebCore::ScriptController::isJavaScriptAnchorNavigation): Refactored
+        user gesture check to make it more clear.
+
+        (WebCore::ScriptController::pageIsProcessingUserGesture): Added a helper
+        for checking if there's a user gesture in any frame on the page (a more
+        relaxed rule than our popup blocking rule, which requires the user
+        gesture to occur in the frame that's executing JavaScript.)
+
+        * html/HTMLFormElement.h:
+        * html/HTMLFormElement.cpp:
+        (WebCore::HTMLFormElement::submit): Added scaffolding necessary for
+        redirect checking in a form submission through the DOM. (Currently, we
+        just specify "no redirect.")
+
+        * html/HTMLFormElement.idl: Made submit custom so it can participate
+        in redirect checking.
+
+        * loader/FrameLoader.h:
+        * loader/FrameLoader.cpp:
+        (WebCore::FormSubmission::FormSubmission): Clarified some names, and
+        added a "lockHistory" parameter to form submissions, to match other
+        navigations.
+
+        (WebCore::FrameLoader::submitFormAgain):
+        (WebCore::FrameLoader::submitForm): Use the lockHistory parameter.
+
+        (WebCore::FrameLoader::userGestureHint): Refactored this function for
+        clarity, and added a FIXME for a change I was too scared to make myself.
+        (Really, we should just get rid of this function.)
+
+        (WebCore::FrameLoader::loadFrameRequestWithFormAndValues): Refactored
+        to pass a FrameLoadType to form posts, too, so they can participate in
+        redirect tracking.
+
+        (WebCore::FrameLoader::loadPostRequest):
+        (WebCore::FrameLoader::continueFragmentScrollAfterNavigationPolicy):
+        (WebCore::FrameLoader::loadItem): Use the lockHistory parameter.
+
 2009-01-30  Holger Hans Peter Freyther  <zecke@selfish.org>
 
         Unreviewed build fix.
index 4e16cc5..750a2db 100644 (file)
 #include "config.h"
 #include "JSHTMLFormElement.h"
 
+#include "Frame.h"
 #include "HTMLCollection.h"
 #include "HTMLFormElement.h"
+#include "JSDOMWindowCustom.h"
 #include "JSNamedNodesCollection.h"
 
 using namespace JSC;
@@ -55,4 +57,13 @@ JSValuePtr JSHTMLFormElement::nameGetter(ExecState* exec, const Identifier& prop
     return jsUndefined();
 }
 
+JSValuePtr JSHTMLFormElement::submit(ExecState* exec, const ArgList&)
+{
+    Frame* activeFrame = asJSDOMWindow(exec->dynamicGlobalObject())->impl()->frame();
+    if (!activeFrame)
+        return jsUndefined();
+    static_cast<HTMLFormElement*>(impl())->submit(0, false, false);
+    return jsUndefined();
+}
+
 }
index 3715c41..24ac166 100644 (file)
@@ -180,6 +180,11 @@ void ScriptController::initScript()
 
 bool ScriptController::processingUserGesture() const
 {
+    return processingUserGestureEvent() || isJavaScriptAnchorNavigation();
+}
+
+bool ScriptController::processingUserGestureEvent() const
+{
     if (!m_windowShell)
         return false;
 
@@ -196,13 +201,37 @@ bool ScriptController::processingUserGesture() const
             type == eventNames().focusEvent || type == eventNames().blurEvent ||
             type == eventNames().submitEvent)
             return true;
-    } else { // no event
-        if (m_sourceURL && m_sourceURL->isNull() && !m_processingTimerCallback) {
-            // This is the <a href="javascript:window.open('...')> case -> we let it through
-            return true;
+    }
+    
+    return false;
+}
+
+// FIXME: This seems like an insufficient check to verify a click on a javascript: anchor.
+bool ScriptController::isJavaScriptAnchorNavigation() const
+{
+    // This is the <a href="javascript:window.open('...')> case -> we let it through
+    if (m_sourceURL && m_sourceURL->isNull() && !m_processingTimerCallback)
+        return true;
+
+    // This is the <script>window.open(...)</script> case or a timer callback -> block it
+    return false;
+}
+
+bool ScriptController::anyPageIsProcessingUserGesture() const
+{
+    Page* page = m_frame->page();
+    if (!page)
+        return false;
+
+    const HashSet<Page*>& pages = page->group().pages();
+    HashSet<Page*>::const_iterator end = pages.end();
+    for (HashSet<Page*>::const_iterator it = pages.begin(); it != end; ++it) {
+        for (Frame* frame = page->mainFrame(); frame; frame = frame->tree()->traverseNext()) {
+            if (frame->script()->processingUserGesture())
+                return true;
         }
-        // This is the <script>window.open(...)</script> case or a timer callback -> block it
     }
+
     return false;
 }
 
index c952cc2..28fd7e9 100644 (file)
@@ -89,6 +89,7 @@ public:
 
     void setProcessingTimerCallback(bool b) { m_processingTimerCallback = b; }
     bool processingUserGesture() const;
+    bool anyPageIsProcessingUserGesture() const;
 
     bool isEnabled();
 
@@ -141,6 +142,9 @@ private:
 
     void disconnectPlatformScriptObjects();
 
+    bool processingUserGestureEvent() const;
+    bool isJavaScriptAnchorNavigation() const;
+
     JSC::ProtectedPtr<JSDOMWindowShell> m_windowShell;
     HashSet<JSDOMWindow*> m_liveFormerWindows;
     Frame* m_frame;
index 4a0a3c6..e917cec 100644 (file)
@@ -268,12 +268,7 @@ bool HTMLFormElement::prepareSubmit(Event* event)
     return m_doingsubmit;
 }
 
-void HTMLFormElement::submit()
-{
-    submit(0, false);
-}
-
-void HTMLFormElement::submit(Event* event, bool activateSubmitButton)
+void HTMLFormElement::submit(Event* event, bool activateSubmitButton, bool lockHistory)
 {
     FrameView* view = document()->view();
     Frame* frame = document()->frame();
@@ -335,14 +330,14 @@ void HTMLFormElement::submit(Event* event, bool activateSubmitButton)
                 FormDataBuilder::encodeStringAsFormData(bodyData, body.utf8());
                 data = FormData::create(String(bodyData.data(), bodyData.size()).replace('+', "%20").latin1());
             }
-            frame->loader()->submitForm("POST", m_url, data, m_target, m_formDataBuilder.encodingType(), String(), event);
+            frame->loader()->submitForm("POST", m_url, data, m_target, m_formDataBuilder.encodingType(), String(), event, lockHistory);
         } else {
             Vector<char> boundary = m_formDataBuilder.generateUniqueBoundaryString();
-            frame->loader()->submitForm("POST", m_url, createFormData(boundary.data()), m_target, m_formDataBuilder.encodingType(), boundary.data(), event);
+            frame->loader()->submitForm("POST", m_url, createFormData(boundary.data()), m_target, m_formDataBuilder.encodingType(), boundary.data(), event, lockHistory);
         }
     } else {
         m_formDataBuilder.setIsMultiPartForm(false);
-        frame->loader()->submitForm("GET", m_url, createFormData(CString()), m_target, String(), String(), event);
+        frame->loader()->submitForm("GET", m_url, createFormData(CString()), m_target, String(), String(), event, lockHistory);
     }
 
     if (needButtonActivation && firstSuccessfulSubmitButton)
index ef22043..13ba0d1 100644 (file)
@@ -76,8 +76,7 @@ public:
     void removeImgElement(HTMLImageElement*);
 
     bool prepareSubmit(Event*);
-    void submit();
-    void submit(Event*, bool activateSubmitButton = false);
+    void submit(Event* = 0, bool activateSubmitButton = false, bool lockHistory = false);
     void reset();
 
     // Used to indicate a malformed state to keep from applying the bottom margin of the form.
index 39db70c..f3aca87 100644 (file)
@@ -37,7 +37,7 @@ module html {
                  attribute [ConvertNullToNullString] DOMString       method;
                  attribute [ConvertNullToNullString] DOMString       target;
         
-        void               submit();
-        void               reset();
+        [Custom] void submit();
+        void reset();
     };
 }
index ec18769..ca3fd4d 100644 (file)
@@ -120,25 +120,28 @@ const unsigned int cMaxPendingSourceLengthInLowBandwidthDisplay = 128 * 1024;
 typedef HashSet<String, CaseFoldingHash> LocalSchemesMap;
 
 struct FormSubmission {
+    FormSubmission(const char* action, const String& url, PassRefPtr<FormData> formData,
+                   const String& target, const String& contentType, const String& boundary,
+                   PassRefPtr<Event> event, bool lockHistory)
+        : action(action)
+        , url(url)
+        , formData(formData)
+        , target(target)
+        , contentType(contentType)
+        , boundary(boundary)
+        , event(event)
+        , lockHistory(lockHistory)
+    {
+    }
+
     const char* action;
     String url;
-    RefPtr<FormData> data;
+    RefPtr<FormData> formData;
     String target;
     String contentType;
     String boundary;
     RefPtr<Event> event;
-
-    FormSubmission(const char* a, const String& u, PassRefPtr<FormData> d, const String& t,
-            const String& ct, const String& b, PassRefPtr<Event> e)
-        : action(a)
-        , url(u)
-        , data(d)
-        , target(t)
-        , contentType(ct)
-        , boundary(b)
-        , event(e)
-    {
-    }
+    bool lockHistory;
 };
 
 struct ScheduledRedirection {
@@ -498,13 +501,13 @@ void FrameLoader::submitFormAgain()
     if (m_isRunningScript)
         return;
     OwnPtr<FormSubmission> form(m_deferredFormSubmission.release());
-    if (form)
-        submitForm(form->action, form->url, form->data, form->target,
-            form->contentType, form->boundary, form->event.get());
+    if (!form)
+        return;
+    submitForm(form->action, form->url, form->formData, form->target, form->contentType, form->boundary, form->event.get(), form->lockHistory);
 }
 
 void FrameLoader::submitForm(const char* action, const String& url, PassRefPtr<FormData> formData,
-    const String& target, const String& contentType, const String& boundary, Event* event)
+    const String& target, const String& contentType, const String& boundary, Event* event, bool lockHistory)
 {
     ASSERT(formData);
     
@@ -527,8 +530,7 @@ void FrameLoader::submitForm(const char* action, const String& url, PassRefPtr<F
     if (m_isRunningScript) {
         if (m_deferredFormSubmission)
             return;
-        m_deferredFormSubmission.set(new FormSubmission(action, url, formData, target,
-            contentType, boundary, event));
+        m_deferredFormSubmission.set(new FormSubmission(action, url, formData, target, contentType, boundary, event, lockHistory));
         return;
     }
 
@@ -569,7 +571,7 @@ void FrameLoader::submitForm(const char* action, const String& url, PassRefPtr<F
     frameRequest.resourceRequest().setURL(u);
     addHTTPOriginIfNeeded(frameRequest.resourceRequest(), outgoingOrigin());
 
-    submitForm(frameRequest, event);
+    submitForm(frameRequest, event, lockHistory);
 }
 
 void FrameLoader::stopLoading(bool sendUnload)
@@ -1834,14 +1836,10 @@ void FrameLoader::provisionalLoadStarted()
 
 bool FrameLoader::userGestureHint()
 {
-    Frame* rootFrame = m_frame;
-    while (rootFrame->tree()->parent())
-        rootFrame = rootFrame->tree()->parent();
-
-    if (rootFrame->script()->isEnabled())
-        return rootFrame->script()->processingUserGesture();
-
-    return true; // If JavaScript is disabled, a user gesture must have initiated the navigation
+    Frame* frame = m_frame->tree()->top();
+    if (!frame->script()->isEnabled())
+        return true; // If JavaScript is disabled, a user gesture must have initiated the navigation.
+    return frame->script()->processingUserGesture(); // FIXME: Use pageIsProcessingUserGesture.
 }
 
 void FrameLoader::didNotOpenURL(const KURL& url)
@@ -2236,22 +2234,20 @@ void FrameLoader::loadFrameRequestWithFormAndValues(const FrameLoadRequest& requ
     if (shouldHideReferrer(url, referrer))
         referrer = String();
     
-    Frame* targetFrame = findFrameForNavigation(request.frameName());
+    FrameLoadType loadType;
+    if (request.resourceRequest().cachePolicy() == ReloadIgnoringCacheData)
+        loadType = FrameLoadTypeReload;
+    else if (lockHistory)
+        loadType = FrameLoadTypeRedirectWithLockedHistory;
+    else
+        loadType = FrameLoadTypeStandard;    
 
-    if (request.resourceRequest().httpMethod() != "POST") {
-        FrameLoadType loadType;
-        if (request.resourceRequest().cachePolicy() == ReloadIgnoringCacheData)
-            loadType = FrameLoadTypeReload;
-        else if (lockHistory)
-            loadType = FrameLoadTypeRedirectWithLockedHistory;
-        else
-            loadType = FrameLoadTypeStandard;    
-    
-        loadURL(request.resourceRequest().url(), referrer, request.frameName(), loadType, 
-                event, formState.release());
-    } else
-        loadPostRequest(request.resourceRequest(), referrer, request.frameName(), event, formState.release());
+    if (request.resourceRequest().httpMethod() == "POST")
+        loadPostRequest(request.resourceRequest(), referrer, request.frameName(), loadType, event, formState.release());
+    else
+        loadURL(request.resourceRequest().url(), referrer, request.frameName(), loadType, event, formState.release());
 
+    Frame* targetFrame = findFrameForNavigation(request.frameName());
     if (targetFrame && targetFrame != m_frame)
         if (Page* page = targetFrame->page())
             page->chrome()->focus();
@@ -3483,7 +3479,7 @@ int FrameLoader::numPendingOrLoadingRequests(bool recurse) const
     return count;
 }
 
-void FrameLoader::submitForm(const FrameLoadRequest& request, Event* event)
+void FrameLoader::submitForm(const FrameLoadRequest& request, Event* event, bool lockHistory)
 {
     // FIXME: We'd like to remove this altogether and fix the multiple form submission issue another way.
     // We do not want to submit more than one form from the same page,
@@ -3502,8 +3498,7 @@ void FrameLoader::submitForm(const FrameLoadRequest& request, Event* event)
         m_submittedFormURL = request.resourceRequest().url();
     }
 
-    // FIXME: We should probably call userGestureHint() to tell whether this form submission was the result of a user gesture.
-    loadFrameRequestWithFormAndValues(request, false, event, m_formAboutToBeSubmitted.get(), m_formValuesAboutToBeSubmitted);
+    loadFrameRequestWithFormAndValues(request, lockHistory, event, m_formAboutToBeSubmitted.get(), m_formValuesAboutToBeSubmitted);
 
     clearRecordedFormValues();
 }
@@ -3634,8 +3629,7 @@ void FrameLoader::committedLoad(DocumentLoader* loader, const char* data, int le
     m_client->committedLoad(loader, data, length);
 }
 
-void FrameLoader::loadPostRequest(const ResourceRequest& inRequest, const String& referrer, const String& frameName,
-    Event* event, PassRefPtr<FormState> prpFormState)
+void FrameLoader::loadPostRequest(const ResourceRequest& inRequest, const String& referrer, const String& frameName, FrameLoadType loadType, Event* event, PassRefPtr<FormState> prpFormState)
 {
     RefPtr<FormState> formState = prpFormState;
 
@@ -3662,17 +3656,17 @@ void FrameLoader::loadPostRequest(const ResourceRequest& inRequest, const String
     workingResourceRequest.setHTTPMethod("POST");
     workingResourceRequest.setHTTPBody(formData);
     workingResourceRequest.setHTTPContentType(contentType);
-    addExtraFieldsToRequest(workingResourceRequest, FrameLoadTypeStandard, true, true);
+    addExtraFieldsToRequest(workingResourceRequest, loadType, true, true);
 
-    NavigationAction action(url, FrameLoadTypeStandard, true, event);
+    NavigationAction action(url, loadType, true, event);
 
     if (!frameName.isEmpty()) {
         if (Frame* targetFrame = findFrameForNavigation(frameName))
-            targetFrame->loader()->loadWithNavigationAction(workingResourceRequest, action, FrameLoadTypeStandard, formState.release());
+            targetFrame->loader()->loadWithNavigationAction(workingResourceRequest, action, loadType, formState.release());
         else
             checkNewWindowPolicy(action, workingResourceRequest, formState.release(), frameName);
     } else
-        loadWithNavigationAction(workingResourceRequest, action, FrameLoadTypeStandard, formState.release());    
+        loadWithNavigationAction(workingResourceRequest, action, loadType, formState.release());    
 }
 
 void FrameLoader::loadEmptyDocumentSynchronously()
@@ -3831,9 +3825,6 @@ void FrameLoader::callContinueFragmentScrollAfterNavigationPolicy(void* argument
 
 void FrameLoader::continueFragmentScrollAfterNavigationPolicy(const ResourceRequest& request, bool shouldContinue)
 {
-    // FIXME:
-    // some functions check m_quickRedirectComing, and others check for
-    // FrameLoadTypeRedirectWithLockedHistory.  
     bool isRedirect = m_quickRedirectComing || m_policyLoadType == FrameLoadTypeRedirectWithLockedHistory;
     m_quickRedirectComing = false;
 
@@ -4590,8 +4581,6 @@ void FrameLoader::loadItem(HistoryItem* item, FrameLoadType loadType)
                         break;
                     case FrameLoadTypeStandard:
                     case FrameLoadTypeRedirectWithLockedHistory:
-                        // no-op: leave as protocol default
-                        // FIXME:  I wonder if we ever hit this case
                         break;
                     case FrameLoadTypeSame:
                     default:
index 44b7745..0a3f9ee 100644 (file)
@@ -138,11 +138,11 @@ namespace WebCore {
         void loadWithNavigationAction(const ResourceRequest&, const NavigationAction&,              // Calls loadWithDocumentLoader()
             FrameLoadType, PassRefPtr<FormState>);
 
-        void loadPostRequest(const ResourceRequest& inRequest, const String& referrer,              // Called by loadFrameRequestWithFormAndValues(), calls loadWithNavigationAction
-            const String& frameName, Event* event, PassRefPtr<FormState> prpFormState);
+        void loadPostRequest(const ResourceRequest&, const String& referrer,                        // Called by loadFrameRequestWithFormAndValues(), calls loadWithNavigationAction
+            const String& frameName, FrameLoadType, Event*, PassRefPtr<FormState>);
 
         void loadURL(const KURL& newURL, const String& referrer, const String& frameName,           // Called by loadFrameRequestWithFormAndValues(), calls loadWithNavigationAction or else dispatches to navigation policy delegate    
-            FrameLoadType, Event* event, PassRefPtr<FormState> prpFormState);                                                         
+            FrameLoadType, Event*, PassRefPtr<FormState>);                                                         
         void loadURLIntoChildFrame(const KURL&, const String& referer, Frame*);
 
         void loadFrameRequestWithFormAndValues(const FrameLoadRequest&, bool lockHistory,           // Called by submitForm, calls loadPostRequest()
@@ -288,9 +288,9 @@ namespace WebCore {
         bool requestFrame(HTMLFrameOwnerElement*, const String& url, const AtomicString& frameName);
         Frame* loadSubframe(HTMLFrameOwnerElement*, const KURL&, const String& name, const String& referrer);
 
-        void submitForm(const char* action, const String& url, PassRefPtr<FormData>, const String& target, const String& contentType, const String& boundary, Event*);
+        void submitForm(const char* action, const String& url, PassRefPtr<FormData>, const String& target, const String& contentType, const String& boundary, Event*, bool lockHistory);
         void submitFormAgain();
-        void submitForm(const FrameLoadRequest&, Event*);
+        void submitForm(const FrameLoadRequest&, Event*, bool lockHistory);
 
         void stop();
         void stopLoading(bool sendUnload);