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

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

Issue 2640823004: Allow origin trials to be enabled by script (Closed)
Patch Set: Address latest comment Created 3 years, 11 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
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..538a9ee7edc2da13220329bbcf1fdf4b13d95cc4 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,7 +78,7 @@ void injectInternalsObject(v8::Local<v8::Context> context) {
.ToChecked();
}
-void installConditionalFeaturesForTests(
+void installConditionalFeaturesForTesting(
const WrapperTypeInfo* type,
const blink::ScriptState* scriptState,
v8::Local<v8::Object> prototypeObject,
@@ -123,4 +119,36 @@ void resetInternalsObject(v8::Local<v8::Context> context) {
InternalSettings::from(*page)->resetToConsistentState();
}
+void installPendingConditionalFeatureForTesting(
+ const String& feature,
+ const ScriptState* scriptState) {
+ (*s_originalInstallPendingConditionalFeatureFunction)(feature, scriptState);
+ v8::Local<v8::Object> prototypeObject;
+ v8::Local<v8::Function> interfaceObject;
+ if (feature == "Frobulate") {
+ if (scriptState->perContextData()
+ ->getExistingConstructorAndPrototypeForType(
+ &V8OriginTrialsTest::wrapperTypeInfo, &prototypeObject,
+ &interfaceObject)) {
+ 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

Powered by Google App Engine
This is Rietveld 408576698