summaryrefslogtreecommitdiffstats
path: root/content/shell
diff options
context:
space:
mode:
authorjochen@chromium.org <jochen@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2012-12-21 00:09:51 +0000
committerjochen@chromium.org <jochen@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2012-12-21 00:09:51 +0000
commit86b36e67600b2bde0487725a1eb9b7934a0053ee (patch)
tree9b7e618633b75bfaa4a946ccb4b6bdced415aa4a /content/shell
parent3b1c0c7f6ef246aa42f71ea96c27b22bb54542cd (diff)
downloadchromium_src-86b36e67600b2bde0487725a1eb9b7934a0053ee.zip
chromium_src-86b36e67600b2bde0487725a1eb9b7934a0053ee.tar.gz
chromium_src-86b36e67600b2bde0487725a1eb9b7934a0053ee.tar.bz2
[content shell] run in headless mode (gtk only)
Don't show a window, instead make the renderer believe that the window is active and has focus. This also adds the command line option --show-content-shell to run layout tests using a visible window for debugging. BUG=111316 TEST=http/tests/appcache tests don't crash the content_shell, editing/inserting tests don't fail R=jam@chromium.org Review URL: https://chromiumcodereview.appspot.com/11640055 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@174284 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'content/shell')
-rw-r--r--content/shell/shell.cc11
-rw-r--r--content/shell/shell.h2
-rw-r--r--content/shell/shell_gtk.cc26
-rw-r--r--content/shell/shell_switches.cc4
-rw-r--r--content/shell/shell_switches.h1
-rw-r--r--content/shell/webkit_test_controller.cc2
6 files changed, 41 insertions, 5 deletions
diff --git a/content/shell/shell.cc b/content/shell/shell.cc
index f21b6f9..4816a35 100644
--- a/content/shell/shell.cc
+++ b/content/shell/shell.cc
@@ -45,11 +45,16 @@ Shell::Shell(WebContents* web_contents)
: dev_tools_(NULL),
is_fullscreen_(false),
window_(NULL),
- url_edit_view_(NULL)
+ url_edit_view_(NULL),
#if defined(OS_WIN) && !defined(USE_AURA)
- , default_edit_wnd_proc_(0)
+ default_edit_wnd_proc_(0),
#endif
- {
+ headless_(false) {
+ const CommandLine& command_line = *CommandLine::ForCurrentProcess();
+ if (command_line.HasSwitch(switches::kDumpRenderTree) &&
+ !command_line.HasSwitch(switches::kDisableHeadlessForLayoutTests)) {
+ headless_ = true;
+ }
registrar_.Add(this, NOTIFICATION_WEB_CONTENTS_TITLE_UPDATED,
Source<WebContents>(web_contents));
windows_.push_back(this);
diff --git a/content/shell/shell.h b/content/shell/shell.h
index 24173b9..748f9e6 100644
--- a/content/shell/shell.h
+++ b/content/shell/shell.h
@@ -242,6 +242,8 @@ class Shell : public WebContentsDelegate,
views::Widget* window_widget_;
#endif
+ bool headless_;
+
// A container of all the open windows. We use a vector so we can keep track
// of ordering.
static std::vector<Shell*> windows_;
diff --git a/content/shell/shell_gtk.cc b/content/shell/shell_gtk.cc
index 2cfbc47..25e6dd7 100644
--- a/content/shell/shell_gtk.cc
+++ b/content/shell/shell_gtk.cc
@@ -62,6 +62,9 @@ void Shell::PlatformCleanUp() {
}
void Shell::PlatformEnableUIControl(UIControl control, bool is_enabled) {
+ if (headless_)
+ return;
+
GtkToolItem* item = NULL;
switch (control) {
case BACK_BUTTON:
@@ -81,10 +84,16 @@ void Shell::PlatformEnableUIControl(UIControl control, bool is_enabled) {
}
void Shell::PlatformSetAddressBarURL(const GURL& url) {
+ if (headless_)
+ return;
+
gtk_entry_set_text(GTK_ENTRY(url_edit_view_), url.spec().c_str());
}
void Shell::PlatformSetIsLoading(bool loading) {
+ if (headless_)
+ return;
+
if (loading)
gtk_spinner_start(GTK_SPINNER(spinner_));
else
@@ -92,6 +101,9 @@ void Shell::PlatformSetIsLoading(bool loading) {
}
void Shell::PlatformCreateWindow(int width, int height) {
+ if (headless_)
+ return;
+
window_ = GTK_WINDOW(gtk_window_new(GTK_WINDOW_TOPLEVEL));
gtk_window_set_title(window_, "Content Shell");
g_signal_connect(G_OBJECT(window_), "destroy",
@@ -187,6 +199,9 @@ void Shell::PlatformCreateWindow(int width, int height) {
}
void Shell::PlatformSetContents() {
+ if (headless_)
+ return;
+
WebContentsView* content_view = web_contents_->GetView();
gtk_container_add(GTK_CONTAINER(vbox_), content_view->GetNativeView());
}
@@ -194,9 +209,8 @@ void Shell::PlatformSetContents() {
void Shell::SizeTo(int width, int height) {
content_width_ = width;
content_height_ = height;
- if (web_contents_.get()) {
+ if (web_contents_.get())
gtk_widget_set_size_request(web_contents_->GetNativeView(), width, height);
- }
}
void Shell::PlatformResizeSubViews() {
@@ -204,6 +218,11 @@ void Shell::PlatformResizeSubViews() {
}
void Shell::Close() {
+ if (headless_) {
+ delete this;
+ return;
+ }
+
gtk_widget_destroy(GTK_WIDGET(window_));
}
@@ -269,6 +288,9 @@ gboolean Shell::OnHighlightURLView(GtkAccelGroup* accel_group,
}
void Shell::PlatformSetTitle(const string16& title) {
+ if (headless_)
+ return;
+
std::string title_utf8 = UTF16ToUTF8(title);
gtk_window_set_title(GTK_WINDOW(window_), title_utf8.c_str());
}
diff --git a/content/shell/shell_switches.cc b/content/shell/shell_switches.cc
index 1328bb6..476f6d2 100644
--- a/content/shell/shell_switches.cc
+++ b/content/shell/shell_switches.cc
@@ -18,6 +18,10 @@ const char kContentBrowserTest[] = "browser-test";
// Makes Content Shell use the given path for its data directory.
const char kContentShellDataPath[] = "data-path";
+// Show the content_shell window, even when running in layout test mode.
+const char kDisableHeadlessForLayoutTests[] =
+ "disable-headless-for-layout-tests";
+
// Request pages to be dumped as text once they finished loading.
const char kDumpRenderTree[] = "dump-render-tree";
diff --git a/content/shell/shell_switches.h b/content/shell/shell_switches.h
index 3347037..482d3cc 100644
--- a/content/shell/shell_switches.h
+++ b/content/shell/shell_switches.h
@@ -13,6 +13,7 @@ extern const char kAllowExternalPages[];
extern const char kCheckLayoutTestSysDeps[];
extern const char kContentBrowserTest[];
extern const char kContentShellDataPath[];
+extern const char kDisableHeadlessForLayoutTests[];
extern const char kDumpRenderTree[];
extern const char kEnableSoftwareCompositing[];
extern const char kNoTimeout[];
diff --git a/content/shell/webkit_test_controller.cc b/content/shell/webkit_test_controller.cc
index e6e699f..25557ee 100644
--- a/content/shell/webkit_test_controller.cc
+++ b/content/shell/webkit_test_controller.cc
@@ -175,6 +175,8 @@ bool WebKitTestController::PrepareForLayoutTest(
test_url.spec().find("\\inspector\\") != std::string::npos) {
main_window_->ShowDevTools();
}
+ main_window_->web_contents()->GetRenderViewHost()->Focus();
+ main_window_->web_contents()->GetRenderViewHost()->SetActive(true);
return true;
}