summaryrefslogtreecommitdiffstats
path: root/content
diff options
context:
space:
mode:
Diffstat (limited to 'content')
-rw-r--r--content/shell/shell_browser_main.cc7
-rw-r--r--content/shell/shell_messages.h3
-rw-r--r--content/shell/webkit_test_controller.cc5
-rw-r--r--content/shell/webkit_test_controller.h3
-rw-r--r--content/shell/webkit_test_runner.cc22
-rw-r--r--content/shell/webkit_test_runner.h1
6 files changed, 38 insertions, 3 deletions
diff --git a/content/shell/shell_browser_main.cc b/content/shell/shell_browser_main.cc
index cffd464..182f7a2 100644
--- a/content/shell/shell_browser_main.cc
+++ b/content/shell/shell_browser_main.cc
@@ -123,6 +123,13 @@ int ShellBrowserMain(const content::MainFunctionParams& parameters) {
if (layout_test_mode) {
content::WebKitTestController test_controller;
+ {
+ // We're outside of the message loop here, and this is a test.
+ base::ThreadRestrictions::ScopedAllowIO allow_io;
+ base::FilePath temp_path;
+ file_util::GetTempDir(&temp_path);
+ test_controller.SetTempPath(temp_path);
+ }
std::string test_string;
CommandLine::StringVector args =
CommandLine::ForCurrentProcess()->GetArgs();
diff --git a/content/shell/shell_messages.h b/content/shell/shell_messages.h
index 5b0b083..7121704 100644
--- a/content/shell/shell_messages.h
+++ b/content/shell/shell_messages.h
@@ -16,6 +16,9 @@ IPC_STRUCT_BEGIN(ShellViewMsg_SetTestConfiguration_Params)
// The current working directory.
IPC_STRUCT_MEMBER(base::FilePath, current_working_directory)
+ // The temporary directory of the system.
+ IPC_STRUCT_MEMBER(base::FilePath, temp_path)
+
// The URL of the current layout test.
IPC_STRUCT_MEMBER(GURL, test_url)
diff --git a/content/shell/webkit_test_controller.cc b/content/shell/webkit_test_controller.cc
index e761b56..c2840a6 100644
--- a/content/shell/webkit_test_controller.cc
+++ b/content/shell/webkit_test_controller.cc
@@ -241,6 +241,10 @@ bool WebKitTestController::ResetAfterLayoutTest() {
return true;
}
+void WebKitTestController::SetTempPath(const base::FilePath& temp_path) {
+ temp_path_ = temp_path;
+}
+
void WebKitTestController::RendererUnresponsive() {
DCHECK(CalledOnValidThread());
if (!CommandLine::ForCurrentProcess()->HasSwitch(switches::kNoTimeout))
@@ -302,6 +306,7 @@ void WebKitTestController::RenderViewCreated(RenderViewHost* render_view_host) {
current_pid_ = base::GetProcId(render_view_host->GetProcess()->GetHandle());
ShellViewMsg_SetTestConfiguration_Params params;
params.current_working_directory = current_working_directory_;
+ params.temp_path = temp_path_;
params.test_url = test_url_;
params.enable_pixel_dumping = enable_pixel_dumping_;
params.layout_test_timeout = kTestTimeoutMilliseconds;
diff --git a/content/shell/webkit_test_controller.h b/content/shell/webkit_test_controller.h
index b544e7d..619c7da 100644
--- a/content/shell/webkit_test_controller.h
+++ b/content/shell/webkit_test_controller.h
@@ -88,6 +88,8 @@ class WebKitTestController : public base::NonThreadSafe,
// True if the controller was reset successfully.
bool ResetAfterLayoutTest();
+ void SetTempPath(const base::FilePath& temp_path);
+
void RendererUnresponsive();
void OverrideWebkitPrefs(webkit_glue::WebPreferences* prefs);
@@ -133,6 +135,7 @@ class WebKitTestController : public base::NonThreadSafe,
scoped_ptr<WebKitTestResultPrinter> printer_;
base::FilePath current_working_directory_;
+ base::FilePath temp_path_;
Shell* main_window_;
diff --git a/content/shell/webkit_test_runner.cc b/content/shell/webkit_test_runner.cc
index 54023ba..c3e4783 100644
--- a/content/shell/webkit_test_runner.cc
+++ b/content/shell/webkit_test_runner.cc
@@ -4,6 +4,7 @@
#include "content/shell/webkit_test_runner.h"
+#include <algorithm>
#include <clocale>
#include <cmath>
@@ -12,6 +13,7 @@
#include "base/md5.h"
#include "base/memory/scoped_ptr.h"
#include "base/message_loop.h"
+#include "base/string_util.h"
#include "base/stringprintf.h"
#include "base/sys_string_conversions.h"
#include "base/time.h"
@@ -304,9 +306,22 @@ void WebKitTestRunner::setAcceptAllCookies(bool accept) {
}
std::string WebKitTestRunner::pathToLocalResource(const std::string& resource) {
- Send(new ShellViewHostMsg_NotImplemented(
- routing_id(), "WebKitTestRunner", "pathToLocalResource"));
- return std::string();
+#if defined(OS_WIN)
+ if (resource.find("/tmp/") == 0) {
+ // We want a temp file.
+ GURL base_url = net::FilePathToFileURL(temp_path_);
+ return base_url.Resolve(resource.substr(strlen("/tmp/"))).spec();
+ }
+#endif
+
+ // Some layout tests use file://// which we resolve as a UNC path. Normalize
+ // them to just file:///.
+ std::string result = resource;
+ while (StringToLowerASCII(result).find("file:////") == 0) {
+ result = result.substr(0, strlen("file:///")) +
+ result.substr(strlen("file:////"));
+ }
+ return rewriteLayoutTestsURL(result).spec();
}
void WebKitTestRunner::setLocale(const std::string& locale) {
@@ -562,6 +577,7 @@ void WebKitTestRunner::CaptureDump() {
void WebKitTestRunner::OnSetTestConfiguration(
const ShellViewMsg_SetTestConfiguration_Params& params) {
current_working_directory_ = params.current_working_directory;
+ temp_path_ = params.temp_path;
enable_pixel_dumping_ = params.enable_pixel_dumping;
layout_test_timeout_ = params.layout_test_timeout;
allow_external_pages_ = params.allow_external_pages;
diff --git a/content/shell/webkit_test_runner.h b/content/shell/webkit_test_runner.h
index 4583ea02b..47611f2 100644
--- a/content/shell/webkit_test_runner.h
+++ b/content/shell/webkit_test_runner.h
@@ -122,6 +122,7 @@ class WebKitTestRunner : public RenderViewObserver,
static int window_count_;
base::FilePath current_working_directory_;
+ base::FilePath temp_path_;
::WebTestRunner::WebTestProxyBase* proxy_;