Commit b522cfef authored by Pavel Feldman's avatar Pavel Feldman Committed by Commit Bot

DevTools: do not reset device emulation upon second client attaching.

Change-Id: Ie90437511d2eda4a5477abde80c083eeb6448db8
Reviewed-on: https://chromium-review.googlesource.com/1239248Reviewed-by: default avatarDmitry Gozman <dgozman@chromium.org>
Commit-Queue: Pavel Feldman <pfeldman@chromium.org>
Cr-Commit-Position: refs/heads/master@{#593399}
parent f8fb81b9
...@@ -58,7 +58,7 @@ void DevToolsSession::Dispose() { ...@@ -58,7 +58,7 @@ void DevToolsSession::Dispose() {
void DevToolsSession::AddHandler( void DevToolsSession::AddHandler(
std::unique_ptr<protocol::DevToolsDomainHandler> handler) { std::unique_ptr<protocol::DevToolsDomainHandler> handler) {
handler->Wire(dispatcher_.get()); handler->Wire(dispatcher_.get());
handler->SetRenderer(process_host_id_, host_); handler->InitRenderer(process_host_id_, host_);
handlers_[handler->name()] = std::move(handler); handlers_[handler->name()] = std::move(handler);
} }
...@@ -67,7 +67,7 @@ void DevToolsSession::SetRenderer(int process_host_id, ...@@ -67,7 +67,7 @@ void DevToolsSession::SetRenderer(int process_host_id,
process_host_id_ = process_host_id; process_host_id_ = process_host_id;
host_ = frame_host; host_ = frame_host;
for (auto& pair : handlers_) for (auto& pair : handlers_)
pair.second->SetRenderer(process_host_id_, host_); pair.second->UpdateRenderer(process_host_id_, host_);
} }
void DevToolsSession::SetBrowserOnly(bool browser_only) { void DevToolsSession::SetBrowserOnly(bool browser_only) {
......
...@@ -17,6 +17,16 @@ DevToolsDomainHandler::DevToolsDomainHandler(const std::string& name) ...@@ -17,6 +17,16 @@ DevToolsDomainHandler::DevToolsDomainHandler(const std::string& name)
DevToolsDomainHandler::~DevToolsDomainHandler() { DevToolsDomainHandler::~DevToolsDomainHandler() {
} }
void DevToolsDomainHandler::InitRenderer(int process_host_id,
RenderFrameHostImpl* frame_host) {
SetRenderer(process_host_id, frame_host);
}
void DevToolsDomainHandler::UpdateRenderer(int process_host_id,
RenderFrameHostImpl* frame_host) {
SetRenderer(process_host_id, frame_host);
}
void DevToolsDomainHandler::SetRenderer(int process_host_id, void DevToolsDomainHandler::SetRenderer(int process_host_id,
RenderFrameHostImpl* frame_host) {} RenderFrameHostImpl* frame_host) {}
......
...@@ -18,13 +18,19 @@ class DevToolsDomainHandler { ...@@ -18,13 +18,19 @@ class DevToolsDomainHandler {
explicit DevToolsDomainHandler(const std::string& name); explicit DevToolsDomainHandler(const std::string& name);
virtual ~DevToolsDomainHandler(); virtual ~DevToolsDomainHandler();
virtual void SetRenderer(int process_host_id, virtual void InitRenderer(int process_host_id,
RenderFrameHostImpl* frame_host); RenderFrameHostImpl* frame_host);
virtual void UpdateRenderer(int process_host_id,
RenderFrameHostImpl* frame_host);
virtual void Wire(UberDispatcher* dispatcher); virtual void Wire(UberDispatcher* dispatcher);
virtual Response Disable(); virtual Response Disable();
const std::string& name() const { return name_; } const std::string& name() const { return name_; }
protected:
virtual void SetRenderer(int process_host_id,
RenderFrameHostImpl* frame_host);
private: private:
std::string name_; std::string name_;
......
...@@ -73,14 +73,18 @@ std::vector<EmulationHandler*> EmulationHandler::ForAgentHost( ...@@ -73,14 +73,18 @@ std::vector<EmulationHandler*> EmulationHandler::ForAgentHost(
host, Emulation::Metainfo::domainName); host, Emulation::Metainfo::domainName);
} }
void EmulationHandler::SetRenderer(int process_host_id, void EmulationHandler::InitRenderer(int process_host_id,
RenderFrameHostImpl* frame_host) { RenderFrameHostImpl* frame_host) {
if (host_ == frame_host)
return;
host_ = frame_host; host_ = frame_host;
if (touch_emulation_enabled_) if (touch_emulation_enabled_)
UpdateTouchEventEmulationState(); UpdateTouchEventEmulationState();
}
void EmulationHandler::UpdateRenderer(int process_host_id,
RenderFrameHostImpl* frame_host) {
if (host_ == frame_host)
return;
InitRenderer(process_host_id, frame_host);
UpdateDeviceEmulationState(); UpdateDeviceEmulationState();
} }
......
...@@ -32,8 +32,10 @@ class EmulationHandler : public DevToolsDomainHandler, ...@@ -32,8 +32,10 @@ class EmulationHandler : public DevToolsDomainHandler,
DevToolsAgentHostImpl* host); DevToolsAgentHostImpl* host);
void Wire(UberDispatcher* dispatcher) override; void Wire(UberDispatcher* dispatcher) override;
void SetRenderer(int process_host_id, void InitRenderer(int process_host_id,
RenderFrameHostImpl* frame_host) override; RenderFrameHostImpl* frame_host) override;
void UpdateRenderer(int process_host_id,
RenderFrameHostImpl* frame_host) override;
Response Disable() override; Response Disable() override;
......
Tests that device emulation is not reset upon second client attach.
Emulating device: 1200x1000x1
1200 x 1000
Creating a new session
1200 x 1000
(async function(testRunner) {
var {page, session, dp} = await testRunner.startBlank('Tests that device emulation is not reset upon second client attach.');
var DeviceEmulator = await testRunner.loadScript('../resources/device-emulator.js');
var deviceEmulator = new DeviceEmulator(testRunner, session);
await deviceEmulator.emulate(1200, 1000, 1);
testRunner.log(await session.evaluate(`document.body.clientWidth + ' x ' + document.body.clientHeight`));
testRunner.log('Creating a new session');
await page.createSession();
testRunner.log(await session.evaluate(`document.body.clientWidth + ' x ' + document.body.clientHeight`));
testRunner.completeTest();
})
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment