Issue metadata
Sign in to add a comment
|
Count a DevTools evaluation as a user gesture |
||||||||||||||||||||||||
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?
,
Mar 14 2016
+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.
,
Mar 15 2016
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.
,
Mar 15 2016
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.
,
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
,
Mar 17 2016
,
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.
,
Jun 22 2016
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".
,
Nov 24 2016
|
|||||||||||||||||||||||||
►
Sign in to add a comment |
|||||||||||||||||||||||||
Comment 1 by caseq@chromium.org
, Mar 14 2016Components: -Platform>DevTools>UX
Labels: -Pri-2 Pri-3
Owner: lushnikov@chromium.org
Status: Assigned (was: Untriaged)