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

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 nit 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
« 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 600adbe23edf15a34139c2825f91f5a1dd8d8c76..0339a641ce4ec7b1e28038caac5e6b3271c979c3 100644
--- a/third_party/WebKit/Source/core/testing/v8/WebCoreTestSupport.cpp
+++ b/third_party/WebKit/Source/core/testing/v8/WebCoreTestSupport.cpp
@@ -43,6 +43,8 @@ namespace {
blink::InstallConditionalFeaturesFunction
s_originalInstallConditionalFeaturesFunction = nullptr;
+blink::InstallPendingConditionalFeatureFunction
+ s_originalInstallPendingConditionalFeatureFunction = nullptr;
v8::Local<v8::Value> createInternalsObject(v8::Local<v8::Context> context) {
blink::ScriptState* scriptState = blink::ScriptState::from(context);
@@ -62,13 +64,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();
blink::ScriptState* scriptState = blink::ScriptState::from(context);
blink::ScriptState::Scope scope(scriptState);
@@ -84,7 +80,7 @@ void injectInternalsObject(v8::Local<v8::Context> context) {
.ToChecked();
}
-void installConditionalFeaturesForTests(
+void installConditionalFeaturesForTesting(
const blink::WrapperTypeInfo* type,
const blink::ScriptState* scriptState,
v8::Local<v8::Object> prototypeObject,
@@ -127,4 +123,36 @@ void resetInternalsObject(v8::Local<v8::Context> context) {
blink::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