diff options
author | jochen@chromium.org <jochen@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2013-03-18 15:30:32 +0000 |
---|---|---|
committer | jochen@chromium.org <jochen@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2013-03-18 15:30:32 +0000 |
commit | 1afb9af0b6a4471088825e168dbf8ad2a5aa7c08 (patch) | |
tree | b1a1e44cbb8d66490270b82c9443460eda6118fe | |
parent | 7598787c6c5141d8babfa7023605738e4628b5bd (diff) | |
download | chromium_src-1afb9af0b6a4471088825e168dbf8ad2a5aa7c08.zip chromium_src-1afb9af0b6a4471088825e168dbf8ad2a5aa7c08.tar.gz chromium_src-1afb9af0b6a4471088825e168dbf8ad2a5aa7c08.tar.bz2 |
[content shell] prune the history as soon as a pending navigation entry for the next layout test exists
Since we prune the history asynchronously from the browser, we need to prune it
before the renderer had a chance to access it for the next test.
BUG=171128
TEST=history tests don't report a too long session history
Review URL: https://codereview.chromium.org/12483009
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@188744 0039d316-1c4b-4281-b951-d872f2087c98
-rw-r--r-- | content/shell/shell_messages.h | 4 | ||||
-rw-r--r-- | content/shell/shell_render_process_observer.cc | 7 | ||||
-rw-r--r-- | content/shell/webkit_test_controller.cc | 30 | ||||
-rw-r--r-- | content/shell/webkit_test_controller.h | 8 | ||||
-rw-r--r-- | content/shell/webkit_test_runner.cc | 11 | ||||
-rw-r--r-- | content/shell/webkit_test_runner.h | 1 |
6 files changed, 33 insertions, 28 deletions
diff --git a/content/shell/shell_messages.h b/content/shell/shell_messages.h index ebd99e4..5389d96 100644 --- a/content/shell/shell_messages.h +++ b/content/shell/shell_messages.h @@ -25,7 +25,7 @@ IPC_STRUCT_TRAITS_MEMBER(expected_pixel_hash) IPC_STRUCT_TRAITS_END() // Tells the renderer to reset all test runners. -IPC_MESSAGE_CONTROL0(ShellViewMsg_ResetAll) +IPC_MESSAGE_ROUTED0(ShellViewMsg_Reset) // Sets the path to the WebKit checkout. IPC_MESSAGE_CONTROL1(ShellViewMsg_SetWebKitSourceDir, @@ -65,6 +65,8 @@ IPC_MESSAGE_ROUTED1(ShellViewHostMsg_AudioDump, IPC_MESSAGE_ROUTED1(ShellViewHostMsg_TestFinished, bool /* did_timeout */) +IPC_MESSAGE_ROUTED0(ShellViewHostMsg_ResetDone) + // WebTestDelegate related. IPC_MESSAGE_ROUTED1(ShellViewHostMsg_OverridePreferences, webkit_glue::WebPreferences /* preferences */) diff --git a/content/shell/shell_render_process_observer.cc b/content/shell/shell_render_process_observer.cc index c18264e..da8a5d0 100644 --- a/content/shell/shell_render_process_observer.cc +++ b/content/shell/shell_render_process_observer.cc @@ -80,7 +80,6 @@ bool ShellRenderProcessObserver::OnControlMessageReceived( const IPC::Message& message) { bool handled = true; IPC_BEGIN_MESSAGE_MAP(ShellRenderProcessObserver, message) - IPC_MESSAGE_HANDLER(ShellViewMsg_ResetAll, OnResetAll) IPC_MESSAGE_HANDLER(ShellViewMsg_SetWebKitSourceDir, OnSetWebKitSourceDir) IPC_MESSAGE_HANDLER(ShellViewMsg_LoadHyphenDictionary, OnLoadHyphenDictionary) @@ -90,12 +89,6 @@ bool ShellRenderProcessObserver::OnControlMessageReceived( return handled; } -void ShellRenderProcessObserver::OnResetAll() { - test_interfaces_->resetAll(); - if (main_test_runner_) - main_test_runner_->Reset(); -} - void ShellRenderProcessObserver::OnSetWebKitSourceDir( const base::FilePath& webkit_source_dir) { webkit_source_dir_ = webkit_source_dir; diff --git a/content/shell/webkit_test_controller.cc b/content/shell/webkit_test_controller.cc index 99f0a80..983bab7 100644 --- a/content/shell/webkit_test_controller.cc +++ b/content/shell/webkit_test_controller.cc @@ -220,7 +220,6 @@ bool WebKitTestController::PrepareForLayoutTest( MSG_ROUTING_NONE, initial_size); WebContentsObserver::Observe(main_window_->web_contents()); - prune_history_ = false; send_configuration_to_next_host_ = true; current_pid_ = base::kNullProcessId; } else { @@ -238,7 +237,10 @@ bool WebKitTestController::PrepareForLayoutTest( OverrideWebkitPrefs(&prefs); render_view_host->UpdateWebkitPreferences(prefs); SendTestConfiguration(); - prune_history_ = true; + registrar_.Add(this, + NOTIFICATION_NAV_ENTRY_PENDING, + Source<NavigationController>( + &main_window_->web_contents()->GetController())); } main_window_->LoadURL(test_url); main_window_->web_contents()->GetRenderViewHost()->SetActive(true); @@ -267,7 +269,6 @@ bool WebKitTestController::ResetAfterLayoutTest() { prefs_ = webkit_glue::WebPreferences(); should_override_prefs_ = false; watchdog_.Cancel(); - Send(new ShellViewMsg_ResetAll); return true; } @@ -320,6 +321,7 @@ bool WebKitTestController::OnMessageReceived(const IPC::Message& message) { OnCaptureSessionHistory) IPC_MESSAGE_HANDLER(ShellViewHostMsg_CloseRemainingWindows, OnCloseRemainingWindows) + IPC_MESSAGE_HANDLER(ShellViewHostMsg_ResetDone, OnResetDone) IPC_MESSAGE_UNHANDLED(handled = false) IPC_END_MESSAGE_MAP() @@ -357,15 +359,6 @@ void WebKitTestController::RenderViewGone(base::TerminationStatus status) { DiscardMainWindow(); } -void WebKitTestController::DidNavigateMainFrame( - const LoadCommittedDetails& details, - const FrameNavigateParams& params) { - if (!prune_history_) - return; - prune_history_ = false; - main_window_->web_contents()->GetController().PruneAllButActive(); -} - void WebKitTestController::WebContentsDestroyed(WebContents* web_contents) { DCHECK(CalledOnValidThread()); printer_->AddErrorMessage("FAIL: main window was destroyed"); @@ -391,6 +384,11 @@ void WebKitTestController::Observe(int type, current_pid_ = base::GetProcId(render_process_host->GetHandle()); break; } + case NOTIFICATION_NAV_ENTRY_PENDING: { + registrar_.Remove(this, NOTIFICATION_NAV_ENTRY_PENDING, source); + main_window_->web_contents()->GetController().PruneAllButActive(); + break; + } default: NOTREACHED(); } @@ -449,7 +447,9 @@ void WebKitTestController::OnTestFinished(bool did_timeout) { } if (!printer_->output_finished()) printer_->PrintImageFooter(); - MessageLoop::current()->PostTask(FROM_HERE, MessageLoop::QuitClosure()); + RenderViewHost* render_view_host = + main_window_->web_contents()->GetRenderViewHost(); + Send(new ShellViewMsg_Reset(render_view_host->GetRoutingID())); } void WebKitTestController::OnImageDump( @@ -594,4 +594,8 @@ void WebKitTestController::OnCloseRemainingWindows() { MessageLoop::current()->RunUntilIdle(); } +void WebKitTestController::OnResetDone() { + MessageLoop::current()->PostTask(FROM_HERE, MessageLoop::QuitClosure()); +} + } // namespace content diff --git a/content/shell/webkit_test_controller.h b/content/shell/webkit_test_controller.h index bf18e3b..7474e45 100644 --- a/content/shell/webkit_test_controller.h +++ b/content/shell/webkit_test_controller.h @@ -106,9 +106,6 @@ class WebKitTestController : public base::NonThreadSafe, base::ProcessId plugin_pid) OVERRIDE; virtual void RenderViewCreated(RenderViewHost* render_view_host) OVERRIDE; virtual void RenderViewGone(base::TerminationStatus status) OVERRIDE; - virtual void DidNavigateMainFrame( - const LoadCommittedDetails& details, - const FrameNavigateParams& params) OVERRIDE; virtual void WebContentsDestroyed(WebContents* web_contents) OVERRIDE; // NotificationObserver implementation. @@ -140,6 +137,7 @@ class WebKitTestController : public base::NonThreadSafe, void OnLoadURLForFrame(const GURL& url, const std::string& frame_name); void OnCaptureSessionHistory(); void OnCloseRemainingWindows(); + void OnResetDone(); scoped_ptr<WebKitTestResultPrinter> printer_; @@ -151,10 +149,6 @@ class WebKitTestController : public base::NonThreadSafe, // The PID of the render process of the render view host of main_window_. int current_pid_; - // True if we should prune all but the active navigation entry of main_window_ - // on the next commit of a main frame navigation. - bool prune_history_; - // True if we should set the test configuration to the next RenderViewHost // created. bool send_configuration_to_next_host_; diff --git a/content/shell/webkit_test_runner.cc b/content/shell/webkit_test_runner.cc index b263ce8..4a1eadc 100644 --- a/content/shell/webkit_test_runner.cc +++ b/content/shell/webkit_test_runner.cc @@ -35,6 +35,7 @@ #include "third_party/WebKit/Source/Platform/chromium/public/WebString.h" #include "third_party/WebKit/Source/Platform/chromium/public/WebURL.h" #include "third_party/WebKit/Source/Platform/chromium/public/WebURLError.h" +#include "third_party/WebKit/Source/Platform/chromium/public/WebURLRequest.h" #include "third_party/WebKit/Source/Platform/chromium/public/WebURLResponse.h" #include "third_party/WebKit/Source/WebKit/chromium/public/WebArrayBufferView.h" #include "third_party/WebKit/Source/WebKit/chromium/public/WebContextMenuData.h" @@ -73,6 +74,7 @@ using WebKit::WebSize; using WebKit::WebString; using WebKit::WebURL; using WebKit::WebURLError; +using WebKit::WebURLRequest; using WebKit::WebTestingSupport; using WebKit::WebVector; using WebKit::WebView; @@ -499,6 +501,7 @@ bool WebKitTestRunner::OnMessageReceived(const IPC::Message& message) { IPC_MESSAGE_HANDLER(ShellViewMsg_SetTestConfiguration, OnSetTestConfiguration) IPC_MESSAGE_HANDLER(ShellViewMsg_SessionHistory, OnSessionHistory) + IPC_MESSAGE_HANDLER(ShellViewMsg_Reset, OnReset) IPC_MESSAGE_UNHANDLED(handled = false) IPC_END_MESSAGE_MAP() @@ -587,6 +590,8 @@ void WebKitTestRunner::CaptureDump() { } } + render_view()->GetWebView()->mainFrame() + ->loadRequest(WebURLRequest(GURL("about:blank"))); Send(new ShellViewHostMsg_TestFinished(routing_id(), false)); } @@ -614,4 +619,10 @@ void WebKitTestRunner::OnSessionHistory( CaptureDump(); } +void WebKitTestRunner::OnReset() { + ShellRenderProcessObserver::GetInstance()->test_interfaces()->resetAll(); + Reset(); + Send(new ShellViewHostMsg_ResetDone(routing_id())); +} + } // namespace content diff --git a/content/shell/webkit_test_runner.h b/content/shell/webkit_test_runner.h index fd8805b..a66445a 100644 --- a/content/shell/webkit_test_runner.h +++ b/content/shell/webkit_test_runner.h @@ -98,6 +98,7 @@ class WebKitTestRunner : public RenderViewObserver, const std::vector<int>& routing_ids, const std::vector<std::vector<std::string> >& session_histories, const std::vector<unsigned>& current_entry_indexes); + void OnReset(); // After finishing the test, retrieves the audio, text, and pixel dumps from // the TestRunner library and sends them to the browser process. |