2011-05-07  Joe Mason  <jmason@rim.com>

        Reviewed by Daniel Bates.

        FrameLoader::isProcessingUserGesture is wrong in dispatchWillPerformClientRedirect
        https://bugs.webkit.org/show_bug.cgi?id=52211

        Add willPerformClientRedirect to the user-gesture tests.

        * fast/frames/location-redirect-user-gesture-expected.txt:
        * fast/frames/meta-refresh-user-gesture-expected.txt:
2011-05-07  Joe Mason  <jmason@rim.com>

        Reviewed by Daniel Bates.

        FrameLoader::isProcessingUserGesture is wrong in dispatchWillPerformClientRedirect
        https://bugs.webkit.org/show_bug.cgi?id=52211

        Create a UserGestureIndicator when calling the clientRedirected callback.

        * loader/NavigationScheduler.cpp:
        (WebCore::ScheduledURLNavigation::didStartTimer):
        (WebCore::ScheduledURLNavigation::didStopTimer):
        (WebCore::ScheduledFormSubmission::didStartTimer):
        (WebCore::ScheduledFormSubmission::didStopTimer):
2011-05-07  Joe Mason  <jmason@rim.com>

        Reviewed by Daniel Bates.

        FrameLoader::isProcessingUserGesture is wrong in dispatchWillPerformClientRedirect
        https://bugs.webkit.org/show_bug.cgi?id=52211

        Dump isUserProcessingGesture in willPerformClientRedirect so that the layout tests can be extended.

        * WebCoreSupport/FrameLoaderClientQt.cpp:
        (WebCore::FrameLoaderClientQt::dispatchWillPerformClientRedirect):
2011-05-07  Joe Mason  <jmason@rim.com>

        Reviewed by Daniel Bates.

        FrameLoader::isProcessingUserGesture is wrong in dispatchWillPerformClientRedirect
        https://bugs.webkit.org/show_bug.cgi?id=52211

        Dump isUserProcessingGesture in willPerformClientRedirect so that the layout tests can be extended.
        (For the Mac and Chromium ports - other ports don't support dumping user gestures in DRT.)

        * DumpRenderTree/chromium/WebViewHost.cpp:
        (WebViewHost::willPerformClientRedirect):
        (WebViewHost::didStartProvisionalLoad):
        * DumpRenderTree/mac/FrameLoadDelegate.mm:
        (-[FrameLoadDelegate webView:willPerformClientRedirectToURL:delay:fireDate:forFrame:]):

git-svn-id: http://svn.webkit.org/repository/webkit/trunk@86013 268f45cc-cd09-0410-ab3c-d52691b4dbfc
diff --git a/LayoutTests/ChangeLog b/LayoutTests/ChangeLog
index 6c5da84..f18e06f 100644
--- a/LayoutTests/ChangeLog
+++ b/LayoutTests/ChangeLog
@@ -1,3 +1,15 @@
+2011-05-07  Joe Mason  <jmason@rim.com>
+
+        Reviewed by Daniel Bates.
+
+        FrameLoader::isProcessingUserGesture is wrong in dispatchWillPerformClientRedirect
+        https://bugs.webkit.org/show_bug.cgi?id=52211
+
+        Add willPerformClientRedirect to the user-gesture tests.
+
+        * fast/frames/location-redirect-user-gesture-expected.txt:
+        * fast/frames/meta-refresh-user-gesture-expected.txt:
+
 2011-05-07  Jessie Berlin  <jberlin@apple.com>
 
         [WebKit2] editing/selection/select-across-readonly-input-{1-5}.html failing since
diff --git a/LayoutTests/fast/frames/location-redirect-user-gesture-expected.txt b/LayoutTests/fast/frames/location-redirect-user-gesture-expected.txt
index 142a05f..bb40443 100644
--- a/LayoutTests/fast/frames/location-redirect-user-gesture-expected.txt
+++ b/LayoutTests/fast/frames/location-redirect-user-gesture-expected.txt
@@ -1,2 +1,3 @@
+Frame with user gesture "false" - in willPerformClientRedirect
 Frame with user gesture "false" - in didStartProvisionalLoadForFrame
 
diff --git a/LayoutTests/fast/frames/meta-refresh-user-gesture-expected.txt b/LayoutTests/fast/frames/meta-refresh-user-gesture-expected.txt
index 142a05f..bb40443 100644
--- a/LayoutTests/fast/frames/meta-refresh-user-gesture-expected.txt
+++ b/LayoutTests/fast/frames/meta-refresh-user-gesture-expected.txt
@@ -1,2 +1,3 @@
+Frame with user gesture "false" - in willPerformClientRedirect
 Frame with user gesture "false" - in didStartProvisionalLoadForFrame
 
diff --git a/Source/WebCore/ChangeLog b/Source/WebCore/ChangeLog
index 4a0898b..28cf974 100644
--- a/Source/WebCore/ChangeLog
+++ b/Source/WebCore/ChangeLog
@@ -1,3 +1,18 @@
+2011-05-07  Joe Mason  <jmason@rim.com>
+
+        Reviewed by Daniel Bates.
+
+        FrameLoader::isProcessingUserGesture is wrong in dispatchWillPerformClientRedirect
+        https://bugs.webkit.org/show_bug.cgi?id=52211
+
+        Create a UserGestureIndicator when calling the clientRedirected callback.
+
+        * loader/NavigationScheduler.cpp:
+        (WebCore::ScheduledURLNavigation::didStartTimer):
+        (WebCore::ScheduledURLNavigation::didStopTimer):
+        (WebCore::ScheduledFormSubmission::didStartTimer):
+        (WebCore::ScheduledFormSubmission::didStopTimer):
+
 2011-05-06  Jon Lee  <jonlee@apple.com>
 
         Reviewed by Alice Liu.
diff --git a/Source/WebCore/loader/NavigationScheduler.cpp b/Source/WebCore/loader/NavigationScheduler.cpp
index 65a4551..713a2c8 100644
--- a/Source/WebCore/loader/NavigationScheduler.cpp
+++ b/Source/WebCore/loader/NavigationScheduler.cpp
@@ -114,6 +114,8 @@
         if (m_haveToldClient)
             return;
         m_haveToldClient = true;
+
+        UserGestureIndicator gestureIndicator(wasUserGesture() ? DefinitelyProcessingUserGesture : DefinitelyNotProcessingUserGesture);
         frame->loader()->clientRedirected(KURL(ParsedURLString, m_url), delay(), currentTime() + timer->nextFireInterval(), lockBackForwardList());
     }
 
@@ -121,6 +123,13 @@
     {
         if (!m_haveToldClient)
             return;
+
+        // Do not set a UserGestureIndicator because
+        // clientRedirectCancelledOrFinished() is also called from many places
+        // inside FrameLoader, where the gesture state is not set and is in
+        // fact unavailable. We need to be consistent with them, otherwise the
+        // gesture state will sometimes be set and sometimes not within
+        // dispatchDidCancelClientRedirect().
         frame->loader()->clientRedirectCancelledOrFinished(newLoadInProgress);
     }
 
@@ -224,6 +233,8 @@
         if (m_haveToldClient)
             return;
         m_haveToldClient = true;
+
+        UserGestureIndicator gestureIndicator(wasUserGesture() ? DefinitelyProcessingUserGesture : DefinitelyNotProcessingUserGesture);
         frame->loader()->clientRedirected(m_submission->requestURL(), delay(), currentTime() + timer->nextFireInterval(), lockBackForwardList());
     }
 
@@ -231,6 +242,13 @@
     {
         if (!m_haveToldClient)
             return;
+
+        // Do not set a UserGestureIndicator because
+        // clientRedirectCancelledOrFinished() is also called from many places
+        // inside FrameLoader, where the gesture state is not set and is in
+        // fact unavailable. We need to be consistent with them, otherwise the
+        // gesture state will sometimes be set and sometimes not within
+        // dispatchDidCancelClientRedirect().
         frame->loader()->clientRedirectCancelledOrFinished(newLoadInProgress);
     }
 
diff --git a/Source/WebKit/qt/ChangeLog b/Source/WebKit/qt/ChangeLog
index 024ac23..915f2f7 100644
--- a/Source/WebKit/qt/ChangeLog
+++ b/Source/WebKit/qt/ChangeLog
@@ -1,3 +1,15 @@
+2011-05-07  Joe Mason  <jmason@rim.com>
+
+        Reviewed by Daniel Bates.
+
+        FrameLoader::isProcessingUserGesture is wrong in dispatchWillPerformClientRedirect
+        https://bugs.webkit.org/show_bug.cgi?id=52211
+
+        Dump isUserProcessingGesture in willPerformClientRedirect so that the layout tests can be extended.
+
+        * WebCoreSupport/FrameLoaderClientQt.cpp:
+        (WebCore::FrameLoaderClientQt::dispatchWillPerformClientRedirect):
+
 2011-05-06  Kent Tamura  <tkent@chromium.org>
 
         Reviewed by Ryosuke Niwa.
diff --git a/Source/WebKit/qt/WebCoreSupport/FrameLoaderClientQt.cpp b/Source/WebKit/qt/WebCoreSupport/FrameLoaderClientQt.cpp
index 62a3322..a0d214e 100644
--- a/Source/WebKit/qt/WebCoreSupport/FrameLoaderClientQt.cpp
+++ b/Source/WebKit/qt/WebCoreSupport/FrameLoaderClientQt.cpp
@@ -375,6 +375,9 @@
     if (dumpFrameLoaderCallbacks)
         printf("%s - willPerformClientRedirectToURL: %s \n", qPrintable(drtDescriptionSuitableForTestResult(m_frame)), qPrintable(drtDescriptionSuitableForTestResult(url)));
 
+    if (dumpUserGestureInFrameLoaderCallbacks)
+        printf("%s - in willPerformClientRedirect\n", qPrintable(drtPrintFrameUserGestureStatus(m_frame)));
+
     notImplemented();
 }
 
diff --git a/Tools/ChangeLog b/Tools/ChangeLog
index 115f18d..5c11657 100644
--- a/Tools/ChangeLog
+++ b/Tools/ChangeLog
@@ -1,3 +1,19 @@
+2011-05-07  Joe Mason  <jmason@rim.com>
+
+        Reviewed by Daniel Bates.
+
+        FrameLoader::isProcessingUserGesture is wrong in dispatchWillPerformClientRedirect
+        https://bugs.webkit.org/show_bug.cgi?id=52211
+
+        Dump isUserProcessingGesture in willPerformClientRedirect so that the layout tests can be extended.
+        (For the Mac and Chromium ports - other ports don't support dumping user gestures in DRT.)
+
+        * DumpRenderTree/chromium/WebViewHost.cpp:
+        (WebViewHost::willPerformClientRedirect):
+        (WebViewHost::didStartProvisionalLoad):
+        * DumpRenderTree/mac/FrameLoadDelegate.mm:
+        (-[FrameLoadDelegate webView:willPerformClientRedirectToURL:delay:fireDate:forFrame:]):
+
 2011-05-07  Daniel Bates  <dbates@webkit.org>
 
         Attempt to fix the build; remove some more references to isTiger(), which was removed in changeset 86007
diff --git a/Tools/DumpRenderTree/chromium/WebViewHost.cpp b/Tools/DumpRenderTree/chromium/WebViewHost.cpp
index 366c72c..c01cdd6 100644
--- a/Tools/DumpRenderTree/chromium/WebViewHost.cpp
+++ b/Tools/DumpRenderTree/chromium/WebViewHost.cpp
@@ -855,10 +855,13 @@
 void WebViewHost::willPerformClientRedirect(WebFrame* frame, const WebURL& from, const WebURL& to,
                                             double interval, double fire_time)
 {
-    if (!m_shell->shouldDumpFrameLoadCallbacks())
-        return;
-    printFrameDescription(frame);
-    printf(" - willPerformClientRedirectToURL: %s \n", to.spec().data());
+    if (m_shell->shouldDumpFrameLoadCallbacks()) {
+        printFrameDescription(frame);
+        printf(" - willPerformClientRedirectToURL: %s \n", to.spec().data());
+    }
+
+    if (m_shell->shouldDumpUserGestureInFrameLoadCallbacks())
+        printFrameUserGestureStatus(frame, " - in willPerformClientRedirect\n");
 }
 
 void WebViewHost::didCancelClientRedirect(WebFrame* frame)
@@ -878,13 +881,14 @@
 
 void WebViewHost::didStartProvisionalLoad(WebFrame* frame)
 {
-    if (m_shell->shouldDumpUserGestureInFrameLoadCallbacks())
-        printFrameUserGestureStatus(frame, " - in didStartProvisionalLoadForFrame\n");
     if (m_shell->shouldDumpFrameLoadCallbacks()) {
         printFrameDescription(frame);
         fputs(" - didStartProvisionalLoadForFrame\n", stdout);
     }
 
+    if (m_shell->shouldDumpUserGestureInFrameLoadCallbacks())
+        printFrameUserGestureStatus(frame, " - in didStartProvisionalLoadForFrame\n");
+
     if (!m_topLoadingFrame)
         m_topLoadingFrame = frame;
 
diff --git a/Tools/DumpRenderTree/mac/FrameLoadDelegate.mm b/Tools/DumpRenderTree/mac/FrameLoadDelegate.mm
index a36982c..27939df 100644
--- a/Tools/DumpRenderTree/mac/FrameLoadDelegate.mm
+++ b/Tools/DumpRenderTree/mac/FrameLoadDelegate.mm
@@ -353,6 +353,11 @@
         NSString *string = [NSString stringWithFormat:@"%@ - willPerformClientRedirectToURL: %@ ", [frame _drt_descriptionSuitableForTestResult], [URL _drt_descriptionSuitableForTestResult]];
         printf ("%s\n", [string UTF8String]);
     }
+
+    if (!done && gLayoutTestController->dumpUserGestureInFrameLoadCallbacks()) {
+        NSString *string = [NSString stringWithFormat:@"%@ - in willPerformClientRedirect", [frame _drt_printFrameUserGestureStatus]];
+        printf ("%s\n", [string UTF8String]);
+    }
 }
 
 - (void)webView:(WebView *)sender didCancelClientRedirectForFrame:(WebFrame *)frame