summaryrefslogtreecommitdiffstats
path: root/content/shell
diff options
context:
space:
mode:
authorjochen@chromium.org <jochen@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2013-04-08 14:15:11 +0000
committerjochen@chromium.org <jochen@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2013-04-08 14:15:11 +0000
commit1ca4fac072a12890b72b899b48da00617f8429ef (patch)
treeeefc5e7ed4732470224ac4160135255c5081c456 /content/shell
parent8b830e96fcb8abd0d59bd92e3199e6aae4fbec7c (diff)
downloadchromium_src-1ca4fac072a12890b72b899b48da00617f8429ef.zip
chromium_src-1ca4fac072a12890b72b899b48da00617f8429ef.tar.gz
chromium_src-1ca4fac072a12890b72b899b48da00617f8429ef.tar.bz2
[content shell] add support for invoking testRunner.notifyDone in a different process
Some layout tests, e.g. http/tests/navigation/no-referrer-target-blank.html create a new process, and notifyDone() will be invoked in that new process. Add support for forwarding that signal to the main test runner. BUG=111316 R=mkwst@chromium.org TEST=http/tests/navigation/no-referrer-target-blank.html does not time out Review URL: https://codereview.chromium.org/13795002 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@192819 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'content/shell')
-rw-r--r--content/shell/notify_done_forwarder.cc33
-rw-r--r--content/shell/notify_done_forwarder.h34
-rw-r--r--content/shell/shell.cc3
-rw-r--r--content/shell/shell_messages.h6
-rw-r--r--content/shell/webkit_test_controller.cc7
-rw-r--r--content/shell/webkit_test_controller.h1
-rw-r--r--content/shell/webkit_test_runner.cc19
-rw-r--r--content/shell/webkit_test_runner.h1
8 files changed, 103 insertions, 1 deletions
diff --git a/content/shell/notify_done_forwarder.cc b/content/shell/notify_done_forwarder.cc
new file mode 100644
index 0000000..7de67ed
--- /dev/null
+++ b/content/shell/notify_done_forwarder.cc
@@ -0,0 +1,33 @@
+// Copyright (c) 2013 The Chromium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+#include "content/shell/notify_done_forwarder.h"
+
+#include "content/shell/shell_messages.h"
+#include "content/shell/webkit_test_controller.h"
+
+namespace content {
+
+DEFINE_WEB_CONTENTS_USER_DATA_KEY(NotifyDoneForwarder);
+
+NotifyDoneForwarder::NotifyDoneForwarder(WebContents* web_contents)
+ : WebContentsObserver(web_contents) {}
+
+NotifyDoneForwarder::~NotifyDoneForwarder() {}
+
+bool NotifyDoneForwarder::OnMessageReceived(const IPC::Message& message) {
+ bool handled = true;
+ IPC_BEGIN_MESSAGE_MAP(NotifyDoneForwarder, message)
+ IPC_MESSAGE_HANDLER(ShellViewHostMsg_TestFinishedInSecondaryWindow,
+ OnTestFinishedInSecondaryWindow)
+ IPC_MESSAGE_UNHANDLED(handled = false)
+ IPC_END_MESSAGE_MAP()
+ return handled;
+}
+
+void NotifyDoneForwarder::OnTestFinishedInSecondaryWindow() {
+ WebKitTestController::Get()->TestFinishedInSecondaryWindow();
+}
+
+} // namespace content
diff --git a/content/shell/notify_done_forwarder.h b/content/shell/notify_done_forwarder.h
new file mode 100644
index 0000000..008371a
--- /dev/null
+++ b/content/shell/notify_done_forwarder.h
@@ -0,0 +1,34 @@
+// Copyright (c) 2013 The Chromium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+#ifndef CONTENT_SHELL_NOTIFY_DONE_FORWARDER_H_
+#define CONTENT_SHELL_NOTIFY_DONE_FORWARDER_H_
+
+#include "base/basictypes.h"
+#include "content/public/browser/web_contents_observer.h"
+#include "content/public/browser/web_contents_user_data.h"
+
+namespace content {
+
+class NotifyDoneForwarder : public WebContentsObserver,
+ public WebContentsUserData<NotifyDoneForwarder> {
+ public:
+ virtual ~NotifyDoneForwarder();
+
+ // WebContentsObserver implementation.
+ virtual bool OnMessageReceived(const IPC::Message& message) OVERRIDE;
+
+ private:
+ friend class WebContentsUserData<NotifyDoneForwarder>;
+
+ explicit NotifyDoneForwarder(WebContents* web_contents);
+
+ void OnTestFinishedInSecondaryWindow();
+
+ DISALLOW_COPY_AND_ASSIGN(NotifyDoneForwarder);
+};
+
+} // namespace content
+
+#endif // CONTENT_SHELL_NOTIFY_DONE_FORWARDER_H_
diff --git a/content/shell/shell.cc b/content/shell/shell.cc
index 0d32f0f..903d6e60 100644
--- a/content/shell/shell.cc
+++ b/content/shell/shell.cc
@@ -22,6 +22,7 @@
#include "content/public/browser/web_contents.h"
#include "content/public/browser/web_contents_view.h"
#include "content/public/common/renderer_preferences.h"
+#include "content/shell/notify_done_forwarder.h"
#include "content/shell/shell_browser_main_parts.h"
#include "content/shell/shell_content_browser_client.h"
#include "content/shell/shell_devtools_frontend.h"
@@ -263,6 +264,8 @@ void Shell::WebContentsCreated(WebContents* source_contents,
const GURL& target_url,
WebContents* new_contents) {
CreateShell(new_contents);
+ if (CommandLine::ForCurrentProcess()->HasSwitch(switches::kDumpRenderTree))
+ NotifyDoneForwarder::CreateForWebContents(new_contents);
}
void Shell::DidNavigateMainFramePostCommit(WebContents* web_contents) {
diff --git a/content/shell/shell_messages.h b/content/shell/shell_messages.h
index 5389d96..da5b96c 100644
--- a/content/shell/shell_messages.h
+++ b/content/shell/shell_messages.h
@@ -39,6 +39,10 @@ IPC_MESSAGE_CONTROL1(ShellViewMsg_LoadHyphenDictionary,
IPC_MESSAGE_ROUTED1(ShellViewMsg_SetTestConfiguration,
content::ShellTestConfiguration)
+// Tells the main window that a secondary window in a different process invoked
+// notifyDone().
+IPC_MESSAGE_ROUTED0(ShellViewMsg_NotifyDone)
+
// Pushes a snapshot of the current session history from the browser process.
// This includes only information about those RenderViews that are in the
// same process as the main window of the layout test and that are the current
@@ -67,6 +71,8 @@ IPC_MESSAGE_ROUTED1(ShellViewHostMsg_TestFinished,
IPC_MESSAGE_ROUTED0(ShellViewHostMsg_ResetDone)
+IPC_MESSAGE_ROUTED0(ShellViewHostMsg_TestFinishedInSecondaryWindow)
+
// WebTestDelegate related.
IPC_MESSAGE_ROUTED1(ShellViewHostMsg_OverridePreferences,
webkit_glue::WebPreferences /* preferences */)
diff --git a/content/shell/webkit_test_controller.cc b/content/shell/webkit_test_controller.cc
index 4f604c3..eaa7b12 100644
--- a/content/shell/webkit_test_controller.cc
+++ b/content/shell/webkit_test_controller.cc
@@ -309,6 +309,13 @@ void WebKitTestController::OpenURL(const GURL& url) {
gfx::Size());
}
+void WebKitTestController::TestFinishedInSecondaryWindow() {
+ RenderViewHost* render_view_host =
+ main_window_->web_contents()->GetRenderViewHost();
+ render_view_host->Send(
+ new ShellViewMsg_NotifyDone(render_view_host->GetRoutingID()));
+}
+
bool WebKitTestController::OnMessageReceived(const IPC::Message& message) {
DCHECK(CalledOnValidThread());
bool handled = true;
diff --git a/content/shell/webkit_test_controller.h b/content/shell/webkit_test_controller.h
index 8964f7f..7e1fee7 100644
--- a/content/shell/webkit_test_controller.h
+++ b/content/shell/webkit_test_controller.h
@@ -94,6 +94,7 @@ class WebKitTestController : public base::NonThreadSafe,
void RendererUnresponsive();
void OverrideWebkitPrefs(webkit_glue::WebPreferences* prefs);
void OpenURL(const GURL& url);
+ void TestFinishedInSecondaryWindow();
WebKitTestResultPrinter* printer() { return printer_.get(); }
void set_printer(WebKitTestResultPrinter* printer) {
diff --git a/content/shell/webkit_test_runner.cc b/content/shell/webkit_test_runner.cc
index ba6134c..967e7b0 100644
--- a/content/shell/webkit_test_runner.cc
+++ b/content/shell/webkit_test_runner.cc
@@ -47,6 +47,7 @@
#include "third_party/WebKit/Source/WebKit/chromium/public/WebFrame.h"
#include "third_party/WebKit/Source/WebKit/chromium/public/WebHistoryItem.h"
#include "third_party/WebKit/Source/WebKit/chromium/public/WebKit.h"
+#include "third_party/WebKit/Source/WebKit/chromium/public/WebScriptSource.h"
#include "third_party/WebKit/Source/WebKit/chromium/public/WebTestingSupport.h"
#include "third_party/WebKit/Source/WebKit/chromium/public/WebView.h"
#include "third_party/WebKit/Tools/DumpRenderTree/chromium/TestRunner/public/WebTask.h"
@@ -73,6 +74,7 @@ using WebKit::WebMediaPlayer;
using WebKit::WebMediaPlayerClient;
using WebKit::WebPoint;
using WebKit::WebRect;
+using WebKit::WebScriptSource;
using WebKit::WebSize;
using WebKit::WebString;
using WebKit::WebURL;
@@ -405,8 +407,10 @@ void WebKitTestRunner::setLocale(const std::string& locale) {
}
void WebKitTestRunner::testFinished() {
- if (!is_main_window_)
+ if (!is_main_window_) {
+ Send(new ShellViewHostMsg_TestFinishedInSecondaryWindow(routing_id()));
return;
+ }
WebTestInterfaces* interfaces =
ShellRenderProcessObserver::GetInstance()->test_interfaces();
interfaces->setTestIsRunning(false);
@@ -517,6 +521,7 @@ bool WebKitTestRunner::OnMessageReceived(const IPC::Message& message) {
OnSetTestConfiguration)
IPC_MESSAGE_HANDLER(ShellViewMsg_SessionHistory, OnSessionHistory)
IPC_MESSAGE_HANDLER(ShellViewMsg_Reset, OnReset)
+ IPC_MESSAGE_HANDLER(ShellViewMsg_NotifyDone, OnNotifyDone)
IPC_MESSAGE_UNHANDLED(handled = false)
IPC_END_MESSAGE_MAP()
@@ -525,6 +530,13 @@ bool WebKitTestRunner::OnMessageReceived(const IPC::Message& message) {
void WebKitTestRunner::Navigate(const GURL& url) {
focus_on_next_commit_ = true;
+ if (!is_main_window_ &&
+ ShellRenderProcessObserver::GetInstance()->main_test_runner() == this) {
+ WebTestInterfaces* interfaces =
+ ShellRenderProcessObserver::GetInstance()->test_interfaces();
+ interfaces->setTestIsRunning(true);
+ interfaces->configureForTestWithURL(GURL(), false);
+ }
}
void WebKitTestRunner::DidCommitProvisionalLoad(WebFrame* frame,
@@ -661,4 +673,9 @@ void WebKitTestRunner::OnReset() {
Send(new ShellViewHostMsg_ResetDone(routing_id()));
}
+void WebKitTestRunner::OnNotifyDone() {
+ render_view()->GetWebView()->mainFrame()->executeScript(
+ WebScriptSource(WebString::fromUTF8("testRunner.notifyDone();")));
+}
+
} // namespace content
diff --git a/content/shell/webkit_test_runner.h b/content/shell/webkit_test_runner.h
index aa2f5d1..0023ec4 100644
--- a/content/shell/webkit_test_runner.h
+++ b/content/shell/webkit_test_runner.h
@@ -114,6 +114,7 @@ class WebKitTestRunner : public RenderViewObserver,
const std::vector<std::vector<std::string> >& session_histories,
const std::vector<unsigned>& current_entry_indexes);
void OnReset();
+ void OnNotifyDone();
// After finishing the test, retrieves the audio, text, and pixel dumps from
// the TestRunner library and sends them to the browser process.