New issue
Advanced search Search tips
Note: Color blocks (like or ) mean that a user may not be available. Tooltip shows the reason.

Issue 593241 link

Starred by 3 users

Issue metadata

Status: Fixed
Owner:
Closed: Mar 2016
Cc:
Components:
EstimatedDays: ----
NextAction: ----
OS: ----
Pri: 3
Type: Feature
Team-Security-UX



Sign in to add a comment

Count a DevTools evaluation as a user gesture

Project Member Reported by lgar...@chromium.org, Mar 9 2016

Issue description

<b>Version: <Kenneth, what is the frequency?></b>
<b>OS: <please tell me it's not XP></b>

What steps will reproduce the problem?
(1) Open DevTools and input some Javascript that requires a user gesture, e.g. one of the following lines:

    document.execCommand("copy");
    document.body.requestFullScreen();
    document.body.requestPointerLock();

What is the expected output? What do you see instead?
The command fails. In fact, each of the commands above fails in a different way.

    document.execCommand("copy"); // returns false
    document.body.requestFullScreen(); // shows warning in the console: "Failed to execute 'requestFullScreen' on 'Element': API can only be initiated by a user gesture."
    document.body.requestPointerLock(); // Fails, but no warning.

Just as an example, here's a hacky way to get around this:
  document.body.onclick = document.body.requestPointerLock;


I propose that any code that Javascript executed via DevTools should
- be considered to be triggered by a user gesture, and
- print a warning that states "X usually requires a user gesture".

I can imagine that this causes confusion in more scenarios, but it's much more convenient if you are testing or getting used to these APIs.

felt@, do you know who would decide whether this is okay to implement?
 

Comment 1 by caseq@chromium.org, Mar 14 2016

Cc: dgozman@chromium.org
Components: -Platform>DevTools>UX
Labels: -Pri-2 Pri-3
Owner: lushnikov@chromium.org
Status: Assigned (was: Untriaged)
Not sure we should do this by default, since scenarios of console usage may vary and people may actually expect console evaluation to behave the way it would should the code be invoked any other way, but having an option for treating console evals as user gesture might be convenient.

Comment 2 by f...@chromium.org, Mar 14 2016

Cc: dominickn@chromium.org
+dom, who's been thinking about what should count as a user gesture IIRC.

Re #1: I have the same concern that people who are testing using the console will expect it to work the same way as if it were executed from inside the scope of the page.
I agree that Javascript in the console shouldn't be considered as triggered by a user gesture (though perhaps a more consistent failure indication is warranted). Gesture gating is already a noisy heuristic, so I'm wary of even adding an option in devtools to trigger it.
Owner: pfeldman@chromium.org
I'm with lgarron@ on that one, lets enforce UserGestureIndicator with DefinitelyProcessingNewUserGesture for console evaluation. I don't think warning message is necessary - it'll fail in the page with the proper error message. I'll do that.
Project Member

Comment 5 by bugdroid1@chromium.org, Mar 16 2016

The following revision refers to this bug:
  https://chromium.googlesource.com/chromium/src.git/+/5db661ff8e8dcd081145ea28b183b48b20a087c1

commit 5db661ff8e8dcd081145ea28b183b48b20a087c1
Author: pfeldman <pfeldman@chromium.org>
Date: Wed Mar 16 19:33:15 2016

DevTools: wrap console evaluation with user gesture indicator for convenience.

BUG= 593241 

Review URL: https://codereview.chromium.org/1808533002

Cr-Commit-Position: refs/heads/master@{#381511}

[modify] https://crrev.com/5db661ff8e8dcd081145ea28b183b48b20a087c1/third_party/WebKit/LayoutTests/http/tests/inspector/inspector-test.js
[modify] https://crrev.com/5db661ff8e8dcd081145ea28b183b48b20a087c1/third_party/WebKit/LayoutTests/http/tests/inspector/network/network-initiator-from-console.html
[modify] https://crrev.com/5db661ff8e8dcd081145ea28b183b48b20a087c1/third_party/WebKit/LayoutTests/inspector/console/console-save-to-temp-var.html
[modify] https://crrev.com/5db661ff8e8dcd081145ea28b183b48b20a087c1/third_party/WebKit/LayoutTests/inspector/sources/debugger-ui/debugger-save-to-temp-var.html
[modify] https://crrev.com/5db661ff8e8dcd081145ea28b183b48b20a087c1/third_party/WebKit/LayoutTests/inspector/sources/debugger-ui/show-function-definition.html
[modify] https://crrev.com/5db661ff8e8dcd081145ea28b183b48b20a087c1/third_party/WebKit/Source/core/inspector/InspectorRuntimeAgent.cpp
[modify] https://crrev.com/5db661ff8e8dcd081145ea28b183b48b20a087c1/third_party/WebKit/Source/core/inspector/InspectorRuntimeAgent.h
[modify] https://crrev.com/5db661ff8e8dcd081145ea28b183b48b20a087c1/third_party/WebKit/Source/devtools/front_end/elements/EventListenersWidget.js
[modify] https://crrev.com/5db661ff8e8dcd081145ea28b183b48b20a087c1/third_party/WebKit/Source/devtools/front_end/extensions/ExtensionServer.js
[modify] https://crrev.com/5db661ff8e8dcd081145ea28b183b48b20a087c1/third_party/WebKit/Source/devtools/front_end/sdk/ConsoleModel.js
[modify] https://crrev.com/5db661ff8e8dcd081145ea28b183b48b20a087c1/third_party/WebKit/Source/devtools/front_end/sdk/RemoteObject.js
[modify] https://crrev.com/5db661ff8e8dcd081145ea28b183b48b20a087c1/third_party/WebKit/Source/devtools/front_end/sdk/RuntimeModel.js
[modify] https://crrev.com/5db661ff8e8dcd081145ea28b183b48b20a087c1/third_party/WebKit/Source/devtools/front_end/sources/ObjectEventListenersSidebarPane.js
[modify] https://crrev.com/5db661ff8e8dcd081145ea28b183b48b20a087c1/third_party/WebKit/Source/devtools/front_end/sources/WatchExpressionsSidebarPane.js
[modify] https://crrev.com/5db661ff8e8dcd081145ea28b183b48b20a087c1/third_party/WebKit/Source/devtools/protocol.json
[modify] https://crrev.com/5db661ff8e8dcd081145ea28b183b48b20a087c1/third_party/WebKit/Source/platform/v8_inspector/V8RuntimeAgentImpl.cpp
[modify] https://crrev.com/5db661ff8e8dcd081145ea28b183b48b20a087c1/third_party/WebKit/Source/platform/v8_inspector/V8RuntimeAgentImpl.h

Status: Fixed (was: Assigned)

Comment 7 by phistuck@gmail.com, Mar 17 2016

I think this is a bad idea. This hurts real world hacking. The false illusion of such code working within the console is harmful.
I agree with phistuck that the false illusion of such code working will hurt.
As suggested first, we should add a warning message to let developers know that this work only because they're in Dev Tools. It will raise awareness as they will explore further.

TL;DR; Please print a warning message that states "X usually requires a user gesture".

Components: -Security>UX Platform>DevTools>Security

Sign in to add a comment