Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(778)

Unified Diff: third_party/WebKit/Source/core/testing/v8/WebCoreTestSupport.cpp

Issue 2673953003: Allow origin trials to be enabled by script (Closed)
Patch Set: Created 3 years, 10 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « third_party/WebKit/Source/core/testing/v8/WebCoreTestSupport.h ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: third_party/WebKit/Source/core/testing/v8/WebCoreTestSupport.cpp
diff --git a/third_party/WebKit/Source/core/testing/v8/WebCoreTestSupport.cpp b/third_party/WebKit/Source/core/testing/v8/WebCoreTestSupport.cpp
index 21b58cfbd8d30466cb51a28c9159402012daf3a8..0af370d63e8156724dec74f9398ff13a95ed3ebe 100644
--- a/third_party/WebKit/Source/core/testing/v8/WebCoreTestSupport.cpp
+++ b/third_party/WebKit/Source/core/testing/v8/WebCoreTestSupport.cpp
@@ -45,6 +45,8 @@ namespace {
blink::InstallConditionalFeaturesFunction
s_originalInstallConditionalFeaturesFunction = nullptr;
+blink::InstallPendingConditionalFeatureFunction
+ s_originalInstallPendingConditionalFeatureFunction = nullptr;
v8::Local<v8::Value> createInternalsObject(v8::Local<v8::Context> context) {
ScriptState* scriptState = ScriptState::from(context);
@@ -61,13 +63,7 @@ v8::Local<v8::Value> createInternalsObject(v8::Local<v8::Context> context) {
}
void injectInternalsObject(v8::Local<v8::Context> context) {
- // Set conditional features installation function to
- // |installConditionalFeaturesForTests|
- if (!s_originalInstallConditionalFeaturesFunction) {
- s_originalInstallConditionalFeaturesFunction =
- setInstallConditionalFeaturesFunction(
- installConditionalFeaturesForTests);
- }
+ registerInstallConditionalFeaturesForTesting();
ScriptState* scriptState = ScriptState::from(context);
ScriptState::Scope scope(scriptState);
@@ -82,8 +78,8 @@ void injectInternalsObject(v8::Local<v8::Context> context) {
.ToChecked();
}
-void installConditionalFeaturesForTests(
- const WrapperTypeInfo* type,
+void installConditionalFeaturesForTesting(
+ const blink::WrapperTypeInfo* type,
const blink::ScriptState* scriptState,
v8::Local<v8::Object> prototypeObject,
v8::Local<v8::Function> interfaceObject) {
@@ -123,4 +119,36 @@ void resetInternalsObject(v8::Local<v8::Context> context) {
InternalSettings::from(*page)->resetToConsistentState();
}
+void installPendingConditionalFeatureForTesting(
+ const String& feature,
+ const blink::ScriptState* scriptState) {
+ (*s_originalInstallPendingConditionalFeatureFunction)(feature, scriptState);
+ v8::Local<v8::Object> prototypeObject;
+ v8::Local<v8::Function> interfaceObject;
+ if (feature == "Frobulate") {
+ if (scriptState->perContextData()
+ ->getExistingConstructorAndPrototypeForType(
+ &blink::V8OriginTrialsTest::wrapperTypeInfo, &prototypeObject,
+ &interfaceObject)) {
+ blink::V8OriginTrialsTest::installOriginTrialsSampleAPI(
+ scriptState->isolate(), scriptState->world(), v8::Local<v8::Object>(),
+ prototypeObject, interfaceObject);
+ }
+ return;
+ }
+}
+
+void registerInstallConditionalFeaturesForTesting() {
+ if (!s_originalInstallConditionalFeaturesFunction) {
+ s_originalInstallConditionalFeaturesFunction =
+ setInstallConditionalFeaturesFunction(
+ installConditionalFeaturesForTesting);
+ }
+ if (!s_originalInstallPendingConditionalFeatureFunction) {
+ s_originalInstallPendingConditionalFeatureFunction =
+ setInstallPendingConditionalFeatureFunction(
+ &installPendingConditionalFeatureForTesting);
+ }
+}
+
} // namespace WebCoreTestSupport
« no previous file with comments | « third_party/WebKit/Source/core/testing/v8/WebCoreTestSupport.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698