summaryrefslogtreecommitdiffstats
path: root/webkit
diff options
context:
space:
mode:
authordpranke@chromium.org <dpranke@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2010-04-23 01:47:16 +0000
committerdpranke@chromium.org <dpranke@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2010-04-23 01:47:16 +0000
commit45fbad0fdf0c83236a997e043805cfade80fc5d8 (patch)
tree1b6010795fefb1664a3e25d705381c5c2dff2a99 /webkit
parent8dc1411ff5c8dc7e3a1cc2724c77f7ce0193c4ba (diff)
downloadchromium_src-45fbad0fdf0c83236a997e043805cfade80fc5d8.zip
chromium_src-45fbad0fdf0c83236a997e043805cfade80fc5d8.tar.gz
chromium_src-45fbad0fdf0c83236a997e043805cfade80fc5d8.tar.bz2
Add an --allow-external-pages switch to test_shell.
Normally test_shell will not let you load an external URL (like "www.google.com") when running in --layout-tests mode. This is a good thing because it keeps us from writing tests that might have unpredictable results if the external URL changes. However, it would be cool to be able to use the --layout-test infrastructure to capture the rendered/painted page (outside of the actual layout tests run) for QA purposes. This change adds an --allow-external-pages switch to override the check described above. This is kind of a short-term fix. A better fix would be to add a "--headless" flag that loaded and rendered the page and dumped the whole thing, entirely separate from --layout-test mode. I will add that soon. BUG=none TEST=none R=dglazkov Review URL: http://codereview.chromium.org/1748005 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@45403 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'webkit')
-rw-r--r--webkit/tools/test_shell/run_all_tests.cc2
-rw-r--r--webkit/tools/test_shell/test_shell.cc1
-rw-r--r--webkit/tools/test_shell/test_shell.h9
-rw-r--r--webkit/tools/test_shell/test_shell_gtk.cc4
-rw-r--r--webkit/tools/test_shell/test_shell_mac.mm6
-rw-r--r--webkit/tools/test_shell/test_shell_main.cc6
-rw-r--r--webkit/tools/test_shell/test_shell_switches.cc2
-rw-r--r--webkit/tools/test_shell/test_shell_switches.h1
-rw-r--r--webkit/tools/test_shell/test_shell_webkit_init.h2
-rw-r--r--webkit/tools/test_shell/test_shell_win.cc4
-rw-r--r--webkit/tools/test_shell/test_webview_delegate.cc3
11 files changed, 31 insertions, 9 deletions
diff --git a/webkit/tools/test_shell/run_all_tests.cc b/webkit/tools/test_shell/run_all_tests.cc
index 560604b..8680af8 100644
--- a/webkit/tools/test_shell/run_all_tests.cc
+++ b/webkit/tools/test_shell/run_all_tests.cc
@@ -78,7 +78,7 @@ int main(int argc, char* argv[]) {
// Initialize test shell in layout test mode, which will let us load one
// request than automatically quit.
- TestShell::InitializeTestShell(true);
+ TestShell::InitializeTestShell(true, false);
// Allocate a message loop for this thread. Although it is not used
// directly, its constructor sets up some necessary state.
diff --git a/webkit/tools/test_shell/test_shell.cc b/webkit/tools/test_shell/test_shell.cc
index 577fd1d..b67f5b5 100644
--- a/webkit/tools/test_shell/test_shell.cc
+++ b/webkit/tools/test_shell/test_shell.cc
@@ -107,6 +107,7 @@ WebPreferences* TestShell::web_prefs_ = NULL;
bool TestShell::developer_extras_enabled_ = false;
bool TestShell::inspector_test_mode_ = false;
bool TestShell::layout_test_mode_ = false;
+bool TestShell::allow_external_pages_ = false;
int TestShell::file_test_timeout_ms_ = kDefaultFileTestTimeoutMillisecs;
bool TestShell::test_is_preparing_ = false;
bool TestShell::test_is_pending_ = false;
diff --git a/webkit/tools/test_shell/test_shell.h b/webkit/tools/test_shell/test_shell.h
index f07b5a1..38b1715 100644
--- a/webkit/tools/test_shell/test_shell.h
+++ b/webkit/tools/test_shell/test_shell.h
@@ -92,10 +92,12 @@ public:
static void CleanupLogging();
// Initialization and clean up of a static member variable.
- static void InitializeTestShell(bool layout_test_mode);
+ static void InitializeTestShell(bool layout_test_mode,
+ bool allow_external_pages);
static void ShutdownTestShell();
static bool layout_test_mode() { return layout_test_mode_; }
+ static bool allow_external_pages() { return allow_external_pages_; }
// Called from the destructor to let each platform do any necessary
// cleanup.
@@ -382,6 +384,11 @@ private:
// True when the app is being run using the --layout-tests switch.
static bool layout_test_mode_;
+
+ // True when we wish to allow test shell to load external pages like
+ // www.google.com even when in --layout-test mode (used for QA to
+ // produce images of the rendered page)
+ static bool allow_external_pages_;
// Default timeout in ms for file page loads when in layout test mode.
static int file_test_timeout_ms_;
diff --git a/webkit/tools/test_shell/test_shell_gtk.cc b/webkit/tools/test_shell/test_shell_gtk.cc
index 4729f73..d6c85e0 100644
--- a/webkit/tools/test_shell/test_shell_gtk.cc
+++ b/webkit/tools/test_shell/test_shell_gtk.cc
@@ -154,9 +154,11 @@ GtkWidget* CreateMenuBar(TestShell* shell) {
} // namespace
// static
-void TestShell::InitializeTestShell(bool layout_test_mode) {
+void TestShell::InitializeTestShell(bool layout_test_mode,
+ bool allow_external_pages) {
window_list_ = new WindowList;
layout_test_mode_ = layout_test_mode;
+ allow_external_pages_ = allow_external_pages;
web_prefs_ = new WebPreferences;
diff --git a/webkit/tools/test_shell/test_shell_mac.mm b/webkit/tools/test_shell/test_shell_mac.mm
index 923b5b0..618f91d 100644
--- a/webkit/tools/test_shell/test_shell_mac.mm
+++ b/webkit/tools/test_shell/test_shell_mac.mm
@@ -195,13 +195,15 @@ void TestShell::PlatformShutdown() {
}
// static
-void TestShell::InitializeTestShell(bool layout_test_mode) {
+void TestShell::InitializeTestShell(bool layout_test_mode,
+ bool allow_external_pages) {
// This should move to a per-process platform-specific initialization function
// when one exists.
window_list_ = new WindowList;
layout_test_mode_ = layout_test_mode;
-
+ allow_external_pages_ = allow_external_pages;
+
web_prefs_ = new WebPreferences;
// mmap the data pack which holds strings used by WebCore. This is only
diff --git a/webkit/tools/test_shell/test_shell_main.cc b/webkit/tools/test_shell/test_shell_main.cc
index 9dc8108..37c26bc 100644
--- a/webkit/tools/test_shell/test_shell_main.cc
+++ b/webkit/tools/test_shell/test_shell_main.cc
@@ -110,6 +110,10 @@ int main(int argc, char* argv[]) {
bool enable_gp_fault_error_box = false;
enable_gp_fault_error_box =
parsed_command_line.HasSwitch(test_shell::kGPFaultErrorBox);
+
+ bool allow_external_pages =
+ parsed_command_line.HasSwitch(test_shell::kAllowExternalPages);
+
TestShell::InitLogging(suppress_error_dialogs,
layout_test_mode,
enable_gp_fault_error_box);
@@ -175,7 +179,7 @@ int main(int argc, char* argv[]) {
platform.InitializeGUI();
- TestShell::InitializeTestShell(layout_test_mode);
+ TestShell::InitializeTestShell(layout_test_mode, allow_external_pages);
if (parsed_command_line.HasSwitch(test_shell::kAllowScriptsToCloseWindows))
TestShell::SetAllowScriptsToCloseWindows();
diff --git a/webkit/tools/test_shell/test_shell_switches.cc b/webkit/tools/test_shell/test_shell_switches.cc
index 0769525..2f9c707 100644
--- a/webkit/tools/test_shell/test_shell_switches.cc
+++ b/webkit/tools/test_shell/test_shell_switches.cc
@@ -84,4 +84,6 @@ const char kProfiler[] = "profiler";
// Make functions of the HeapProfiler class available in javascript
const char kHeapProfiler[] = "heap-profiler";
+const char kAllowExternalPages[] = "allow-external-pages";
+
} // namespace test_shell
diff --git a/webkit/tools/test_shell/test_shell_switches.h b/webkit/tools/test_shell/test_shell_switches.h
index 0330e0a..46ec7b2 100644
--- a/webkit/tools/test_shell/test_shell_switches.h
+++ b/webkit/tools/test_shell/test_shell_switches.h
@@ -34,6 +34,7 @@ extern const char kCheckLayoutTestSystemDeps[];
extern const char kGDB[];
extern const char kProfiler[];
extern const char kHeapProfiler[];
+extern const char kAllowExternalPages[];
} // namespace test_shell
diff --git a/webkit/tools/test_shell/test_shell_webkit_init.h b/webkit/tools/test_shell/test_shell_webkit_init.h
index a1073ad..bdeaad5 100644
--- a/webkit/tools/test_shell/test_shell_webkit_init.h
+++ b/webkit/tools/test_shell/test_shell_webkit_init.h
@@ -241,7 +241,7 @@ class TestShellWebKitInit : public webkit_glue::WebKitClientImpl {
SimpleAppCacheSystem appcache_system_;
SimpleDatabaseSystem database_system_;
SimpleWebCookieJarImpl cookie_jar_;
-
+
#if defined(OS_WIN)
WebKit::WebThemeEngine* active_theme_engine_;
#endif
diff --git a/webkit/tools/test_shell/test_shell_win.cc b/webkit/tools/test_shell/test_shell_win.cc
index 934eef4..5653d6e 100644
--- a/webkit/tools/test_shell/test_shell_win.cc
+++ b/webkit/tools/test_shell/test_shell_win.cc
@@ -150,7 +150,8 @@ HINSTANCE TestShell::instance_handle_;
/////////////////////////////////////////////////////////////////////////////
// static methods on TestShell
-void TestShell::InitializeTestShell(bool layout_test_mode) {
+void TestShell::InitializeTestShell(bool layout_test_mode,
+ bool allow_external_pages) {
// Start COM stuff.
HRESULT res = OleInitialize(NULL);
DCHECK(SUCCEEDED(res));
@@ -158,6 +159,7 @@ void TestShell::InitializeTestShell(bool layout_test_mode) {
window_list_ = new WindowList;
instance_handle_ = ::GetModuleHandle(NULL);
layout_test_mode_ = layout_test_mode;
+ allow_external_pages_ = allow_external_pages;
web_prefs_ = new WebPreferences;
diff --git a/webkit/tools/test_shell/test_webview_delegate.cc b/webkit/tools/test_shell/test_webview_delegate.cc
index 3b52c75..408c0b0 100644
--- a/webkit/tools/test_shell/test_webview_delegate.cc
+++ b/webkit/tools/test_shell/test_webview_delegate.cc
@@ -962,7 +962,8 @@ void TestWebViewDelegate::willSendRequest(
host != "127.0.0.1" &&
host != "255.255.255.255" && // Used in some tests that expect to get
// back an error.
- host != "localhost") {
+ host != "localhost" &&
+ !TestShell::allow_external_pages()) {
printf("Blocked access to external URL %s\n", request_url.c_str());
// To block the request, we set its URL to an empty one.