summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--content/shell/shell_browser_main.cc16
-rw-r--r--content/shell/webkit_test_runner_host.cc6
-rw-r--r--content/shell/webkit_test_runner_host.h4
-rw-r--r--content/test/layout_browsertest.cc3
4 files changed, 20 insertions, 9 deletions
diff --git a/content/shell/shell_browser_main.cc b/content/shell/shell_browser_main.cc
index d8fabe9..8447c9c 100644
--- a/content/shell/shell_browser_main.cc
+++ b/content/shell/shell_browser_main.cc
@@ -23,6 +23,7 @@
namespace {
GURL GetURLForLayoutTest(const std::string& test_name,
+ FilePath* current_working_directory,
bool* enable_pixel_dumping,
std::string* expected_pixel_hash) {
// A test name is formated like file:///path/to/test'--pixel-test'pixelhash
@@ -56,10 +57,14 @@ GURL GetURLForLayoutTest(const std::string& test_name,
#endif
}
FilePath local_path;
- if (net::FileURLToFilePath(test_url, &local_path)) {
- // We're outside of the message loop here, and this is a test.
+ {
base::ThreadRestrictions::ScopedAllowIO allow_io;
- file_util::SetCurrentDirectory(local_path.DirName());
+ if (net::FileURLToFilePath(test_url, &local_path)) {
+ // We're outside of the message loop here, and this is a test.
+ file_util::SetCurrentDirectory(local_path.DirName());
+ }
+ if (current_working_directory)
+ file_util::GetCurrentDirectory(current_working_directory);
}
return test_url;
}
@@ -119,10 +124,11 @@ int ShellBrowserMain(const content::MainFunctionParams& parameters) {
bool enable_pixel_dumps;
std::string pixel_hash;
+ FilePath cwd;
GURL test_url = GetURLForLayoutTest(
- test_string, &enable_pixel_dumps, &pixel_hash);
+ test_string, &cwd, &enable_pixel_dumps, &pixel_hash);
if (!content::WebKitTestController::Get()->PrepareForLayoutTest(
- test_url, enable_pixel_dumps, pixel_hash)) {
+ test_url, cwd, enable_pixel_dumps, pixel_hash)) {
break;
}
diff --git a/content/shell/webkit_test_runner_host.cc b/content/shell/webkit_test_runner_host.cc
index 977014b..2120613 100644
--- a/content/shell/webkit_test_runner_host.cc
+++ b/content/shell/webkit_test_runner_host.cc
@@ -141,9 +141,11 @@ WebKitTestController::~WebKitTestController() {
bool WebKitTestController::PrepareForLayoutTest(
const GURL& test_url,
+ const FilePath& current_working_directory,
bool enable_pixel_dumping,
const std::string& expected_pixel_hash) {
DCHECK(CalledOnValidThread());
+ current_working_directory_ = current_working_directory;
enable_pixel_dumping_ = enable_pixel_dumping;
expected_pixel_hash_ = expected_pixel_hash;
if (test_url.spec().find("/dumpAsText/") != std::string::npos ||
@@ -241,12 +243,10 @@ void WebKitTestController::PluginCrashed(const FilePath& plugin_path) {
}
void WebKitTestController::RenderViewReady() {
- FilePath cwd;
- file_util::GetCurrentDirectory(&cwd);
RenderViewHost* render_view_host =
main_window_->web_contents()->GetRenderViewHost();
render_view_host->Send(new ShellViewMsg_SetCurrentWorkingDirectory(
- render_view_host->GetRoutingID(), cwd));
+ render_view_host->GetRoutingID(), current_working_directory_));
if (did_set_as_main_window_)
return;
render_view_host->Send(new ShellViewMsg_SetIsMainWindow(
diff --git a/content/shell/webkit_test_runner_host.h b/content/shell/webkit_test_runner_host.h
index 8616be6..53573bf 100644
--- a/content/shell/webkit_test_runner_host.h
+++ b/content/shell/webkit_test_runner_host.h
@@ -9,6 +9,7 @@
#include <string>
#include "base/cancelable_callback.h"
+#include "base/file_path.h"
#include "base/threading/non_thread_safe.h"
#include "content/public/browser/render_view_host_observer.h"
#include "content/public/browser/web_contents_observer.h"
@@ -71,6 +72,7 @@ class WebKitTestController : public base::NonThreadSafe,
// True if the controller is ready for testing.
bool PrepareForLayoutTest(const GURL& test_url,
+ const FilePath& current_working_directory,
bool enable_pixel_dumping,
const std::string& expected_pixel_hash);
// True if the controller was reset successfully.
@@ -127,6 +129,8 @@ class WebKitTestController : public base::NonThreadSafe,
scoped_ptr<WebKitTestResultPrinter> printer_;
+ FilePath current_working_directory_;
+
Shell* main_window_;
bool enable_pixel_dumping_;
diff --git a/content/test/layout_browsertest.cc b/content/test/layout_browsertest.cc
index 9d4e628..c3bf9ab 100644
--- a/content/test/layout_browsertest.cc
+++ b/content/test/layout_browsertest.cc
@@ -153,7 +153,8 @@ void InProcessBrowserLayoutTest::RunLayoutTestInternal(
test_controller_->set_printer(printer.release());
LOG(INFO) << "Navigating to URL " << url << " and blocking.";
- ASSERT_TRUE(test_controller_->PrepareForLayoutTest(url, false, ""));
+ ASSERT_TRUE(
+ test_controller_->PrepareForLayoutTest(url, FilePath(), false, ""));
base::RunLoop run_loop;
run_loop.Run();
LOG(INFO) << "Navigation completed.";