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

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

Issue 2756623002: DevTools: extract bindings from ShellDevToolsFrontend (Closed)
Patch Set: fixup Created 3 years, 9 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 26fa29fd0fc6fafe0159db72446658f10ae7171b..1495732c1565356ea73f8523aaa4fdf11e2a671f 100644
--- a/content/shell/browser/layout_test/blink_test_controller.cc
+++ b/content/shell/browser/layout_test/blink_test_controller.cc
@@ -43,7 +43,7 @@
#include "content/public/common/content_switches.h"
#include "content/public/common/url_constants.h"
#include "content/shell/browser/layout_test/layout_test_bluetooth_chooser_factory.h"
-#include "content/shell/browser/layout_test/layout_test_devtools_frontend.h"
+#include "content/shell/browser/layout_test/layout_test_devtools_bindings.h"
#include "content/shell/browser/layout_test/layout_test_first_device_bluetooth_chooser.h"
#include "content/shell/browser/shell.h"
#include "content/shell/browser/shell_browser_context.h"
@@ -227,12 +227,12 @@ BlinkTestController* BlinkTestController::Get() {
BlinkTestController::BlinkTestController()
: main_window_(NULL),
+ devtools_window_(nullptr),
test_phase_(BETWEEN_TESTS),
is_leak_detection_enabled_(
base::CommandLine::ForCurrentProcess()->HasSwitch(
switches::kEnableLeakDetection)),
crash_when_leak_found_(false),
- devtools_frontend_(NULL),
render_process_host_observer_(this) {
CHECK(!instance_);
instance_ = this;
@@ -277,7 +277,7 @@ bool BlinkTestController::PrepareForLayoutTest(
if (test_url.spec().find("/inspector-unit/") == std::string::npos)
test_url_ = test_url;
else
- test_url_ = LayoutTestDevToolsFrontend::MapJSTestURL(test_url);
+ test_url_ = LayoutTestDevToolsBindings::MapJSTestURL(test_url);
did_send_initial_test_configuration_ = false;
printer_->reset();
frame_to_layout_dump_map_.clear();
@@ -494,9 +494,13 @@ void BlinkTestController::RenderFrameCreated(
void BlinkTestController::DevToolsProcessCrashed() {
DCHECK(CalledOnValidThread());
printer_->AddErrorMessage("#CRASHED - devtools");
- if (devtools_frontend_)
- devtools_frontend_->Close();
- devtools_frontend_ = NULL;
+ if (devtools_window_)
+ devtools_window_->Close();
+ if (secondary_window_.get() == devtools_window_)
dgozman 2017/03/16 21:38:07 This is always true.
chenwilliam 2017/03/17 22:08:26 Removed (will do in f/u patch). I took out the dev
+ secondary_window_.reset();
+ else
+ main_window_ = nullptr;
+ devtools_window_ = nullptr;
}
void BlinkTestController::WebContentsDestroyed() {
@@ -805,31 +809,43 @@ void BlinkTestController::OnClearDevToolsLocalStorage() {
StoragePartition* storage_partition =
BrowserContext::GetStoragePartition(browser_context, NULL);
storage_partition->GetDOMStorageContext()->DeleteLocalStorage(
- content::LayoutTestDevToolsFrontend::GetDevToolsPathAsURL("")
+ content::LayoutTestDevToolsBindings::GetDevToolsPathAsURL("")
.GetOrigin());
}
void BlinkTestController::OnShowDevTools(const std::string& settings,
const std::string& frontend_url) {
- if (!devtools_frontend_) {
- devtools_frontend_ = LayoutTestDevToolsFrontend::Show(
- main_window_->web_contents(), settings, frontend_url);
+ if (!devtools_bindings_) {
+ if (!secondary_window_) {
+ ShellBrowserContext* browser_context =
+ ShellContentBrowserClient::Get()->browser_context();
+ secondary_window_.reset(content::Shell::CreateNewWindow(
+ browser_context, GURL(), NULL, initial_size_));
+ }
+ devtools_window_ = secondary_window_.get();
+ devtools_bindings_.reset(new LayoutTestDevToolsBindings(
+ devtools_window_->web_contents(), main_window_->web_contents()));
} else {
- devtools_frontend_->ReuseFrontend(settings, frontend_url);
+ devtools_bindings_->DisconnectFromTarget();
dgozman 2017/03/16 21:38:07 Can we instead destroy bindings when the test fini
chenwilliam 2017/03/17 22:08:26 Done.
+ devtools_bindings_->reset_ready_for_test();
+ devtools_bindings_->clear_pending_evaluations();
}
- devtools_frontend_->Activate();
- devtools_frontend_->Focus();
+ devtools_bindings_->SetPreferences(settings);
+ devtools_window_->LoadURL(
+ devtools_bindings_->GetDevToolsPathAsURL(frontend_url));
+ devtools_bindings_->Activate();
+ devtools_bindings_->Focus();
}
void BlinkTestController::OnEvaluateInDevTools(
int call_id, const std::string& script) {
- if (devtools_frontend_)
- devtools_frontend_->EvaluateInFrontend(call_id, script);
+ if (devtools_bindings_)
+ devtools_bindings_->EvaluateInFrontend(call_id, script);
}
void BlinkTestController::OnCloseDevTools() {
- if (devtools_frontend_)
- devtools_frontend_->DisconnectFromTarget();
+ if (devtools_bindings_)
+ devtools_bindings_->DisconnectFromTarget();
}
void BlinkTestController::OnGoToOffset(int offset) {
@@ -890,10 +906,9 @@ void BlinkTestController::OnCaptureSessionHistory() {
void BlinkTestController::OnCloseRemainingWindows() {
DevToolsAgentHost::DetachAllClients();
std::vector<Shell*> open_windows(Shell::windows());
- Shell* devtools_shell = devtools_frontend_ ?
- devtools_frontend_->frontend_shell() : NULL;
for (size_t i = 0; i < open_windows.size(); ++i) {
- if (open_windows[i] != main_window_ && open_windows[i] != devtools_shell)
+ if (open_windows[i] != main_window_ &&
+ open_windows[i] != secondary_window_.get())
open_windows[i]->Close();
}
base::RunLoop().RunUntilIdle();

Powered by Google App Engine
This is Rietveld 408576698