Skip to content

Commit

Permalink
[DevTools] Route input events to the correct RenderWidgetHost
Browse files Browse the repository at this point in the history
With OOPIFs, we route input events sent to main frame's target
to the correct RenderWidgetHost inside.

We might consider doing the same for non-main frames as well, or
instead prohibit input domain on them.

This does not touch gestures yet, those will follow in next patch.

Bug: 746266

[email protected]

(cherry picked from commit 901b630)

Change-Id: I7ba87c6d227ea24a559ebb7b5ca6a3cf9764d0f0
Reviewed-on: https://chromium-review.googlesource.com/939540
Commit-Queue: Dmitry Gozman <[email protected]>
Reviewed-by: Andrey Kosyakov <[email protected]>
Cr-Original-Commit-Position: refs/heads/master@{#540419}
Reviewed-on: https://chromium-review.googlesource.com/953163
Reviewed-by: Dmitry Gozman <[email protected]>
Cr-Commit-Position: refs/branch-heads/3359@{#66}
Cr-Branched-From: 66afc5e-refs/heads/master@{#540276}
  • Loading branch information
dgozman committed Mar 7, 2018
1 parent efc9001 commit 58b43c8
Show file tree
Hide file tree
Showing 8 changed files with 380 additions and 107 deletions.
13 changes: 13 additions & 0 deletions chrome/browser/devtools/devtools_sanity_browsertest.cc
Original file line number Diff line number Diff line change
Expand Up @@ -2165,3 +2165,16 @@ IN_PROC_BROWSER_TEST_F(SitePerProcessDevToolsSanityTest, InspectElement) {
DispatchOnTestSuite(window, "testInspectedElementIs", "INSPECTED-DIV");
DevToolsWindowTesting::CloseDevToolsWindowSync(window);
}

IN_PROC_BROWSER_TEST_F(SitePerProcessDevToolsSanityTest,
InputDispatchEventsToOOPIF) {
GURL url(
embedded_test_server()->GetURL("a.com", "/devtools/oopif-input.html"));
ui_test_utils::NavigateToURLBlockUntilNavigationsComplete(browser(), url, 2);
for (auto* frame : GetInspectedTab()->GetAllFrames())
content::WaitForChildFrameSurfaceReady(frame);
DevToolsWindow* window =
DevToolsWindowTesting::OpenDevToolsWindowSync(GetInspectedTab(), false);
RunTestFunction(window, "testInputDispatchEventsToOOPIF");
DevToolsWindowTesting::CloseDevToolsWindowSync(window);
}
4 changes: 4 additions & 0 deletions chrome/test/data/devtools/oopif-input-iframe.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
<body>
<script src='oopif-input.js'></script>
Hello World!
</body>
10 changes: 10 additions & 0 deletions chrome/test/data/devtools/oopif-input.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
<body>
<script src="oopif-input.js"></script>
<iframe style="width: 100px; height: 100px; position: absolute; top: 100px; left: 200px; border: 0;"></iframe>
<script>
var url = window.location.href;
url = url.replace(/a\.com/, "b.com");
url = url.replace(/oopif-input\.html/, "oopif-input-iframe.html");
document.querySelector('iframe').setAttribute('src', url);
</script>
</body>
47 changes: 47 additions & 0 deletions chrome/test/data/devtools/oopif-input.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
// Copyright 2018 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.

var logs = [];
function log(text) {
logs.push(text);
}

function logMouseEvent(event) {
log('Event');
log('type: ' + event.type);
log('button: ' + event.button);
if (event.shiftKey)
log('shiftKey');
log('x: ' + event.x);
log('y: ' + event.y);
if (event.type === 'mousewheel') {
log('deltaX: ' + event.deltaX);
log('deltaY: ' + event.deltaY);
}
event.preventDefault();
}

function logKeyEvent(event) {
log('Event');
log('type: ' + event.type);
event.preventDefault();
}

function logTouchEvent(event) {
log('Event');
log('type: ' + event.type);
for (var touch of event.touches) {
log('touch x: ' + touch.pageX);
log('touch y: ' + touch.pageY);
}
event.preventDefault();
}

window.addEventListener('mousedown', logMouseEvent);
window.addEventListener('mouseup', logMouseEvent);
window.addEventListener('contextmenu', logMouseEvent);
window.addEventListener('mousewheel', logMouseEvent);
window.addEventListener('keydown', logKeyEvent);
window.addEventListener('touchstart', logTouchEvent);
window.addEventListener('touchend', event => event.preventDefault());
Loading

0 comments on commit 58b43c8

Please sign in to comment.