summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorjochen@chromium.org <jochen@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2013-03-01 07:54:02 +0000
committerjochen@chromium.org <jochen@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2013-03-01 07:54:02 +0000
commitf322356c10256b6ddcf527ddede1ef62494e54ca (patch)
tree8305a3d55f67a9f415dd041473d39870c6fd1e35
parent416c3772371948669b86687d23096fbaac6945e7 (diff)
downloadchromium_src-f322356c10256b6ddcf527ddede1ef62494e54ca.zip
chromium_src-f322356c10256b6ddcf527ddede1ef62494e54ca.tar.gz
chromium_src-f322356c10256b6ddcf527ddede1ef62494e54ca.tar.bz2
[content shell] sync the navigation state to the browser before recording the navigation history
In layout tests that dump the back/forward history, the state of the latest navigation entry (which is kept in the browser browser) does not reliably reflect the current state. This is because updates to the state are only send when a new navigation starts or else at regular intervals. Therefore, we force a sync of the session history state when running layout tests that dump the back/forward history. BUG=111316 R=brettw@chromium.org TEST=remaining http/tests/navigation tests pass Review URL: https://codereview.chromium.org/12330099 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@185490 0039d316-1c4b-4281-b951-d872f2087c98
-rw-r--r--content/public/test/layouttest_support.h3
-rw-r--r--content/renderer/render_view_impl.h8
-rw-r--r--content/shell/webkit_test_runner.cc16
-rw-r--r--content/test/layouttest_support.cc4
4 files changed, 27 insertions, 4 deletions
diff --git a/content/public/test/layouttest_support.h b/content/public/test/layouttest_support.h
index 97d61ff..85a1eab 100644
--- a/content/public/test/layouttest_support.h
+++ b/content/public/test/layouttest_support.h
@@ -43,6 +43,9 @@ void SetAllowOSMesaImageTransportForTesting();
// Do not require a user gesture for focus change events.
void DoNotRequireUserGestureForFocusChanges();
+// Sync the current session history to the browser process.
+void SyncNavigationState(RenderView* render_view);
+
} // namespace content
#endif // CONTENT_PUBLIC_TEST_LAYOUTTEST_SUPPORT_H_
diff --git a/content/renderer/render_view_impl.h b/content/renderer/render_view_impl.h
index 63ebb7e..a8c049e 100644
--- a/content/renderer/render_view_impl.h
+++ b/content/renderer/render_view_impl.h
@@ -394,6 +394,10 @@ class CONTENT_EXPORT RenderViewImpl
void GetWindowSnapshot(const WindowSnapshotCallback& callback);
+ // Dispatches the current navigation state to the browser. Called on a
+ // periodic timer so we don't send too many messages.
+ void SyncNavigationState();
+
// Returns the length of the session history of this RenderView. Note that
// this only coincides with the actual length of the session history if this
// RenderView is the currently active RenderView of a WebContents.
@@ -1202,10 +1206,6 @@ class CONTENT_EXPORT RenderViewImpl
// Stops the current find-in-page search.
void StopFinding(StopFindAction action);
- // Dispatches the current navigation state to the browser. Called on a
- // periodic timer so we don't send too many messages.
- void SyncNavigationState();
-
// Dispatches the current state of selection on the webpage to the browser if
// it has changed.
// TODO(varunjain): delete this method once we figure out how to keep
diff --git a/content/shell/webkit_test_runner.cc b/content/shell/webkit_test_runner.cc
index a63e0cd..b484d03 100644
--- a/content/shell/webkit_test_runner.cc
+++ b/content/shell/webkit_test_runner.cc
@@ -19,6 +19,7 @@
#include "base/time.h"
#include "base/utf_string_conversions.h"
#include "content/public/renderer/render_view.h"
+#include "content/public/renderer/render_view_visitor.h"
#include "content/public/test/layouttest_support.h"
#include "content/shell/shell_messages.h"
#include "content/shell/shell_render_process_observer.h"
@@ -110,6 +111,19 @@ void CopyCanvasToBitmap(SkCanvas* canvas, SkBitmap* snapshot) {
}
+class SyncNavigationStateVisitor : public RenderViewVisitor {
+ public:
+ SyncNavigationStateVisitor() {}
+ virtual ~SyncNavigationStateVisitor() {}
+
+ virtual bool Visit(RenderView* render_view) OVERRIDE {
+ SyncNavigationState(render_view);
+ return true;
+ }
+ private:
+ DISALLOW_COPY_AND_ASSIGN(SyncNavigationStateVisitor);
+};
+
} // namespace
WebKitTestRunner::WebKitTestRunner(RenderView* render_view)
@@ -333,6 +347,8 @@ void WebKitTestRunner::testFinished() {
ShellRenderProcessObserver::GetInstance()->test_interfaces();
interfaces->setTestIsRunning(false);
if (interfaces->testRunner()->shouldDumpBackForwardList()) {
+ SyncNavigationStateVisitor visitor;
+ RenderView::ForEach(&visitor);
Send(new ShellViewHostMsg_CaptureSessionHistory(routing_id()));
} else {
CaptureDump();
diff --git a/content/test/layouttest_support.cc b/content/test/layouttest_support.cc
index 28f34a9..3a7b852 100644
--- a/content/test/layouttest_support.cc
+++ b/content/test/layouttest_support.cc
@@ -73,4 +73,8 @@ void DoNotRequireUserGestureForFocusChanges() {
RenderThreadImpl::current()->set_require_user_gesture_for_focus(false);
}
+void SyncNavigationState(RenderView* render_view) {
+ static_cast<RenderViewImpl*>(render_view)->SyncNavigationState();
+}
+
} // namespace content