Reviewers: kinuko, bajones, bokan
CL:
https://codereview.chromium.org/2543723002/Message:
bajones@ for third_party/WebKit/Source/Modules/vr/ OWNER
bokan@ for third_party/WebKit/Source/web/WebRuntimeFeatures.cpp OWNER
kin...@chromium.org: for everything else
Description:
Add feature to disable WebVR gesture requirement
Adds a way to disable WebVR requiring a user gesture to present to allow
automated tests to present.
Feature can only be enabled via a the command line flag
"--disable-webvr-gestures-for-tests"
BUG=667520
Affected files (+22, -2 lines):
M content/browser/renderer_host/render_process_host_impl.cc
M content/child/runtime_features.cc
M content/public/common/content_switches.h
M content/public/common/content_switches.cc
M third_party/WebKit/Source/modules/vr/VRDisplay.cpp
M third_party/WebKit/Source/platform/RuntimeEnabledFeatures.in
M third_party/WebKit/Source/web/WebRuntimeFeatures.cpp
M third_party/WebKit/public/web/WebRuntimeFeatures.h
Index: content/browser/renderer_host/render_process_host_impl.cc
diff --git a/content/browser/renderer_host/render_process_host_impl.cc b/content/browser/renderer_host/render_process_host_impl.cc
index 597e977a184e46bb5ce9597fa8a5e3160a2c6c61..cd510759b35a8c814b01a21a873294f0c784fa5e 100644
--- a/content/browser/renderer_host/render_process_host_impl.cc
+++ b/content/browser/renderer_host/render_process_host_impl.cc
@@ -1670,6 +1670,7 @@ void RenderProcessHostImpl::PropagateBrowserCommandLineToRenderer(
switches::kDisableTouchDragDrop,
switches::kDisableV8IdleTasks,
switches::kDisableWebGLImageChromium,
+ switches::kDisableWebVrGesturesForTests,
switches::kDomAutomationController,
switches::kEnableBlinkFeatures,
switches::kEnableBrowserSideNavigation,
Index: content/child/runtime_features.cc
diff --git a/content/child/runtime_features.cc b/content/child/runtime_features.cc
index 956aacac7360a5bba9e66cbfd9d9707ef99aeb74..2c0e22fb0f3a42e1c18cf7bcdbfe0433285c9ca9 100644
--- a/content/child/runtime_features.cc
+++ b/content/child/runtime_features.cc
@@ -199,6 +199,9 @@ void SetRuntimeFeaturesDefaultsAndUpdateFromArgs(
if (command_line.HasSwitch(switches::kEnableWebVR))
WebRuntimeFeatures::enableWebVR(true);
+ if (command_line.HasSwitch(switches::kDisableWebVrGesturesForTests))
+ WebRuntimeFeatures::disableWebVrGestures(true);
+
if (command_line.HasSwitch(switches::kDisablePresentationAPI))
WebRuntimeFeatures::enablePresentationAPI(false);
Index: content/public/common/content_switches.cc
diff --git a/content/public/common/content_switches.cc b/content/public/common/content_switches.cc
index 1668c5a7816c9fd57bad58df9277e38d3a04fefc..ce33bef418b4b443795496a03a8a1055611c799b 100644
--- a/content/public/common/content_switches.cc
+++ b/content/public/common/content_switches.cc
@@ -304,6 +304,11 @@ const char kDisableWebGLImageChromium[] = "disable-webgl-image-chromium";
// Don't enforce the same-origin policy. (Used by people testing their sites.)
const char kDisableWebSecurity[] = "disable-web-security";
+// Disables WebVR's user gesture requirement in order to present so that
+// automated tests can be run in cases where we cannot mint gesture tokens
+const char kDisableWebVrGesturesForTests[] =
+ "disable-webvr-gestures-for-tests";
+
// Disables Blink's XSSAuditor. The XSSAuditor mitigates reflective XSS.
const char kDisableXSSAuditor[] = "disable-xss-auditor";
Index: content/public/common/content_switches.h
diff --git a/content/public/common/content_switches.h b/content/public/common/content_switches.h
index e721b9abdd9c058fbdb1fc5e9ed3812765316ff7..c5c937acc2872f4116dfc71844b88423e6385f07 100644
--- a/content/public/common/content_switches.h
+++ b/content/public/common/content_switches.h
@@ -101,6 +101,7 @@ CONTENT_EXPORT extern const char kDisableThreadedScrolling[];
extern const char kDisableV8IdleTasks[];
CONTENT_EXPORT extern const char kDisableWebGLImageChromium[];
CONTENT_EXPORT extern const char kDisableWebSecurity[];
+extern const char kDisableWebVrGesturesForTests[];
extern const char kDisableXSSAuditor[];
CONTENT_EXPORT extern const char kDisableZeroCopy[];
CONTENT_EXPORT extern const char kDisableZeroCopyDxgiVideo[];
Index: third_party/WebKit/Source/modules/vr/VRDisplay.cpp
diff --git a/third_party/WebKit/Source/modules/vr/VRDisplay.cpp b/third_party/WebKit/Source/modules/vr/VRDisplay.cpp
index a266f43d9b194bc884955d27c1c2187d10041e79..fdab47832ff4e63080185115ad6ffd7259786861 100644
--- a/third_party/WebKit/Source/modules/vr/VRDisplay.cpp
+++ b/third_party/WebKit/Source/modules/vr/VRDisplay.cpp
@@ -23,6 +23,7 @@
#include "modules/vr/VRStageParameters.h"
#include "modules/webgl/WebGLRenderingContextBase.h"
#include "platform/Histogram.h"
+#include "platform/RuntimeEnabledFeatures.h"
#include "platform/UserGestureIndicator.h"
#include "public/platform/Platform.h"
#include "wtf/AutoReset.h"
@@ -274,12 +275,15 @@ ScriptPromise VRDisplay::requestPresent(ScriptState* scriptState,
}
bool firstPresent = !m_isPresenting;
+ bool gesturesDisabled =
+ RuntimeEnabledFeatures::webVrGesturesDisabledEnabled();
// Initiating VR presentation is only allowed in response to a user gesture.
// If the VRDisplay is already presenting, however, repeated calls are
// allowed outside a user gesture so that the presented content may be
// updated.
- if (firstPresent && !UserGestureIndicator::utilizeUserGesture()) {
+ if (firstPresent && !UserGestureIndicator::utilizeUserGesture() &&
+ !gesturesDisabled) {
DOMException* exception = DOMException::create(
InvalidStateError, "API can only be initiated by a user gesture.");
resolver->reject(exception);
Index: third_party/WebKit/Source/platform/RuntimeEnabledFeatures.in
diff --git a/third_party/WebKit/Source/platform/RuntimeEnabledFeatures.in b/third_party/WebKit/Source/platform/RuntimeEnabledFeatures.in
index a1a27b1ca3a268e5cd8b0c9b2d53072913fbbc50..762dfd4a7af74f820dd60a9131eb6bf05ae19c07 100644
--- a/third_party/WebKit/Source/platform/RuntimeEnabledFeatures.in
+++ b/third_party/WebKit/Source/platform/RuntimeEnabledFeatures.in
@@ -250,6 +250,7 @@ WebGLDraftExtensions status=experimental
WebGLImageChromium
WebUSB status=experimental, origin_trial_feature_name=WebUSB
WebVR origin_trial_feature_name=WebVR
+WebVrGesturesDisabled
WebVTTRegions status=experimental
V8BasedStructuredClone status=stable
V8IdleTasks
@@ -270,4 +271,4 @@ LazyParseCSS status=experimental
ParseHTMLOnMainThread status=test
SendBeaconThrowForBlobWithNonSimpleType status=experimental
PerformanceNavigationTiming2 status=test
-BackgroundVideoTrackOptimization status=stable
\ No newline at end of file
+BackgroundVideoTrackOptimization status=stable
Index: third_party/WebKit/Source/web/WebRuntimeFeatures.cpp
diff --git a/third_party/WebKit/Source/web/WebRuntimeFeatures.cpp b/third_party/WebKit/Source/web/WebRuntimeFeatures.cpp
index 97ecac1a41e3f562b5086696267049b4124e991f..dda594340560966b431b236f5a013a12ca5a7f94 100644
--- a/third_party/WebKit/Source/web/WebRuntimeFeatures.cpp
+++ b/third_party/WebKit/Source/web/WebRuntimeFeatures.cpp
@@ -296,6 +296,10 @@ void WebRuntimeFeatures::enableWebVR(bool enable) {
RuntimeEnabledFeatures::setWebVREnabled(enable);
}
+void WebRuntimeFeatures::disableWebVrGestures(bool disable) {
+ RuntimeEnabledFeatures::setWebVrGesturesDisabledEnabled(disable);
+}
+
void WebRuntimeFeatures::enablePresentationAPI(bool enable) {
RuntimeEnabledFeatures::setPresentationEnabled(enable);
}
Index: third_party/WebKit/public/web/WebRuntimeFeatures.h
diff --git a/third_party/WebKit/public/web/WebRuntimeFeatures.h b/third_party/WebKit/public/web/WebRuntimeFeatures.h
index 0eb3e5b336086bc922016546608f62ecc2aa6743..6ef71a95d73fa95037c95f2cb476ca911814825b 100644
--- a/third_party/WebKit/public/web/WebRuntimeFeatures.h
+++ b/third_party/WebKit/public/web/WebRuntimeFeatures.h
@@ -128,6 +128,7 @@ class WebRuntimeFeatures {
BLINK_EXPORT static void enableWebGLImageChromium(bool);
BLINK_EXPORT static void enableWebUsb(bool);
BLINK_EXPORT static void enableWebVR(bool);
+ BLINK_EXPORT static void disableWebVrGestures(bool);
BLINK_EXPORT static void enableXSLT(bool);
BLINK_EXPORT static void forceOverlayFullscreenVideo(bool);
BLINK_EXPORT static void enableAutoplayMutedVideos(bool);