Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(2576)

Unified Diff: content/shell/browser/layout_test/blink_test_controller.cc

Issue 2837083003: DevTools: create test infrastructure so devtools drives the test (Closed)
Patch Set: rebaseline Created 3 years, 6 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
Index: content/shell/browser/layout_test/blink_test_controller.cc
diff --git a/content/shell/browser/layout_test/blink_test_controller.cc b/content/shell/browser/layout_test/blink_test_controller.cc
index 0c6a517df493ba25ad4bf2b0030d77be5585d4ee..c2b441256a5d64d39da5391321a578275dc55a68 100644
--- a/content/shell/browser/layout_test/blink_test_controller.cc
+++ b/content/shell/browser/layout_test/blink_test_controller.cc
@@ -249,6 +249,7 @@ BlinkTestController* BlinkTestController::Get() {
BlinkTestController::BlinkTestController()
: main_window_(NULL),
+ secondary_window_(nullptr),
devtools_window_(nullptr),
test_phase_(BETWEEN_TESTS),
is_leak_detection_enabled_(
@@ -296,10 +297,9 @@ bool BlinkTestController::PrepareForLayoutTest(
current_working_directory_ = current_working_directory;
enable_pixel_dumping_ = enable_pixel_dumping;
expected_pixel_hash_ = expected_pixel_hash;
- if (test_url.spec().find("/inspector-unit/") == std::string::npos)
- test_url_ = test_url;
- else
- test_url_ = LayoutTestDevToolsBindings::MapJSTestURL(test_url);
+ bool is_devtools_js_test = false;
+ test_url_ = LayoutTestDevToolsBindings::MapTestURLIfNeeded(
+ test_url, &is_devtools_js_test);
did_send_initial_test_configuration_ = false;
printer_->reset();
frame_to_layout_dump_map_.clear();
@@ -326,7 +326,10 @@ bool BlinkTestController::PrepareForLayoutTest(
current_pid_ = base::kNullProcessId;
default_prefs_ =
main_window_->web_contents()->GetRenderViewHost()->GetWebkitPreferences();
- main_window_->LoadURL(test_url_);
+ if (is_devtools_js_test)
+ LoadDevToolsJSTest();
+ else
+ main_window_->LoadURL(test_url_);
} else {
#if defined(OS_MACOSX)
// Shell::SizeTo is not implemented on all platforms.
@@ -352,12 +355,16 @@ bool BlinkTestController::PrepareForLayoutTest(
render_view_host->UpdateWebkitPreferences(default_prefs_);
HandleNewRenderFrameHost(render_view_host->GetMainFrame());
- NavigationController::LoadURLParams params(test_url_);
- params.transition_type = ui::PageTransitionFromInt(
- ui::PAGE_TRANSITION_TYPED | ui::PAGE_TRANSITION_FROM_ADDRESS_BAR);
- params.should_clear_history_list = true;
- main_window_->web_contents()->GetController().LoadURLWithParams(params);
- main_window_->web_contents()->Focus();
+ if (is_devtools_js_test) {
+ LoadDevToolsJSTest();
+ } else {
+ NavigationController::LoadURLParams params(test_url_);
+ params.transition_type = ui::PageTransitionFromInt(
+ ui::PAGE_TRANSITION_TYPED | ui::PAGE_TRANSITION_FROM_ADDRESS_BAR);
+ params.should_clear_history_list = true;
+ main_window_->web_contents()->GetController().LoadURLWithParams(params);
+ main_window_->web_contents()->Focus();
+ }
}
main_window_->web_contents()->GetRenderViewHost()->GetWidget()->SetActive(
true);
@@ -365,6 +372,25 @@ bool BlinkTestController::PrepareForLayoutTest(
return true;
}
+Shell* BlinkTestController::SecondaryWindow() {
+ if (!secondary_window_) {
+ ShellBrowserContext* browser_context =
+ ShellContentBrowserClient::Get()->browser_context();
+ secondary_window_ = content::Shell::CreateNewWindow(browser_context, GURL(),
+ nullptr, initial_size_);
+ }
+ return secondary_window_;
+}
+
+void BlinkTestController::LoadDevToolsJSTest() {
+ devtools_window_ = main_window_;
+ Shell* secondary = SecondaryWindow();
+ devtools_bindings_.reset(LayoutTestDevToolsBindings::LoadDevTools(
+ devtools_window_->web_contents(), secondary->web_contents(), "",
+ test_url_.spec()));
+ secondary->LoadURL(GURL(url::kAboutBlankURL));
+}
+
bool BlinkTestController::ResetAfterLayoutTest() {
DCHECK_CALLED_ON_VALID_SEQUENCE(sequence_checker_);
printer_->PrintTextFooter();
@@ -379,6 +405,7 @@ bool BlinkTestController::ResetAfterLayoutTest() {
prefs_ = WebPreferences();
should_override_prefs_ = false;
LayoutTestContentBrowserClient::Get()->SetPopupBlockingEnabled(false);
+ devtools_bindings_.reset();
#if defined(OS_ANDROID)
// Re-using the shell's main window on Android causes issues with networking
@@ -843,13 +870,7 @@ void BlinkTestController::OnClearDevToolsLocalStorage() {
void BlinkTestController::OnShowDevTools(const std::string& settings,
const std::string& frontend_url) {
- if (!devtools_window_) {
- ShellBrowserContext* browser_context =
- ShellContentBrowserClient::Get()->browser_context();
- devtools_window_ = content::Shell::CreateNewWindow(browser_context, GURL(),
- nullptr, initial_size_);
- }
-
+ devtools_window_ = SecondaryWindow();
devtools_bindings_.reset(LayoutTestDevToolsBindings::LoadDevTools(
devtools_window_->web_contents(), main_window_->web_contents(), settings,
frontend_url));
@@ -926,7 +947,7 @@ void BlinkTestController::OnCloseRemainingWindows() {
DevToolsAgentHost::DetachAllClients();
std::vector<Shell*> open_windows(Shell::windows());
for (size_t i = 0; i < open_windows.size(); ++i) {
- if (open_windows[i] != main_window_ && open_windows[i] != devtools_window_)
+ if (open_windows[i] != main_window_ && open_windows[i] != secondary_window_)
open_windows[i]->Close();
}
base::RunLoop().RunUntilIdle();

Powered by Google App Engine
This is Rietveld 408576698