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

Unified Diff: third_party/WebKit/Source/bindings/tests/results/core/V8TestObject.cpp

Issue 2005433002: [Origin Trials] Install origin trial bindings on V8 context conditionally (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@track-ef-install
Patch Set: Fix multiple definition of signature; addressing nits Created 4 years, 7 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/bindings/tests/results/core/V8TestObject.cpp
diff --git a/third_party/WebKit/Source/bindings/tests/results/core/V8TestObject.cpp b/third_party/WebKit/Source/bindings/tests/results/core/V8TestObject.cpp
index 722c8284e2b5a742b60990b9152e97693839e4b0..1fb59ef51a87ce8f5afa8961a45166d219d927d6 100644
--- a/third_party/WebKit/Source/bindings/tests/results/core/V8TestObject.cpp
+++ b/third_party/WebKit/Source/bindings/tests/results/core/V8TestObject.cpp
@@ -114,71 +114,26 @@ static void MEASURED_CONSTANTConstantGetterCallback(v8::Local<v8::Name>, const v
static void FEATURE1_ORIGIN_TRIAL_ENABLED_CONST1ConstantGetterCallback(v8::Local<v8::Name>, const v8::PropertyCallbackInfo<v8::Value>& info)
{
- ExecutionContext* executionContext = currentExecutionContext(info.GetIsolate());
- String errorMessage;
- if (!OriginTrials::featureName1Enabled(executionContext, errorMessage)) {
- v8SetReturnValue(info, v8::Undefined(info.GetIsolate()));
- if (!errorMessage.isEmpty()) {
- executionContext->addConsoleMessage(ConsoleMessage::create(JSMessageSource, ErrorMessageLevel, errorMessage));
- }
- return;
- }
v8SetReturnValueInt(info, 1);
}
static void FEATURE1_ORIGIN_TRIAL_ENABLED_CONST2ConstantGetterCallback(v8::Local<v8::Name>, const v8::PropertyCallbackInfo<v8::Value>& info)
{
- ExecutionContext* executionContext = currentExecutionContext(info.GetIsolate());
- String errorMessage;
- if (!OriginTrials::featureName1Enabled(executionContext, errorMessage)) {
- v8SetReturnValue(info, v8::Undefined(info.GetIsolate()));
- if (!errorMessage.isEmpty()) {
- executionContext->addConsoleMessage(ConsoleMessage::create(JSMessageSource, ErrorMessageLevel, errorMessage));
- }
- return;
- }
v8SetReturnValueInt(info, 2);
}
static void FEATURE2_ORIGIN_TRIAL_ENABLED_CONST1ConstantGetterCallback(v8::Local<v8::Name>, const v8::PropertyCallbackInfo<v8::Value>& info)
{
- ExecutionContext* executionContext = currentExecutionContext(info.GetIsolate());
- String errorMessage;
- if (!OriginTrials::featureName2Enabled(executionContext, errorMessage)) {
- v8SetReturnValue(info, v8::Undefined(info.GetIsolate()));
- if (!errorMessage.isEmpty()) {
- executionContext->addConsoleMessage(ConsoleMessage::create(JSMessageSource, ErrorMessageLevel, errorMessage));
- }
- return;
- }
v8SetReturnValueInt(info, 3);
}
static void FEATURE2_ORIGIN_TRIAL_ENABLED_CONST2ConstantGetterCallback(v8::Local<v8::Name>, const v8::PropertyCallbackInfo<v8::Value>& info)
{
- ExecutionContext* executionContext = currentExecutionContext(info.GetIsolate());
- String errorMessage;
- if (!OriginTrials::featureName2Enabled(executionContext, errorMessage)) {
- v8SetReturnValue(info, v8::Undefined(info.GetIsolate()));
- if (!errorMessage.isEmpty()) {
- executionContext->addConsoleMessage(ConsoleMessage::create(JSMessageSource, ErrorMessageLevel, errorMessage));
- }
- return;
- }
v8SetReturnValueInt(info, 4);
}
static void FEATURE3_ORIGIN_TRIAL_ENABLED_CONST1ConstantGetterCallback(v8::Local<v8::Name>, const v8::PropertyCallbackInfo<v8::Value>& info)
{
- ExecutionContext* executionContext = currentExecutionContext(info.GetIsolate());
- String errorMessage;
- if (!OriginTrials::featureName3Enabled(executionContext, errorMessage)) {
- v8SetReturnValue(info, v8::Undefined(info.GetIsolate()));
- if (!errorMessage.isEmpty()) {
- executionContext->addConsoleMessage(ConsoleMessage::create(JSMessageSource, ErrorMessageLevel, errorMessage));
- }
- return;
- }
v8SetReturnValueInt(info, 5);
}
@@ -2699,15 +2654,6 @@ static void notEnumerableLongAttributeAttributeSetterCallback(const v8::Function
static void originTrialEnabledLongAttributeAttributeGetter(const v8::FunctionCallbackInfo<v8::Value>& info)
{
- ExecutionContext* executionContext = currentExecutionContext(info.GetIsolate());
- String errorMessage;
- if (!OriginTrials::featureNameEnabled(executionContext, errorMessage)) {
- v8SetReturnValue(info, v8::Undefined(info.GetIsolate()));
- if (!errorMessage.isEmpty()) {
- executionContext->addConsoleMessage(ConsoleMessage::create(JSMessageSource, ErrorMessageLevel, errorMessage));
- }
- return;
- }
v8::Local<v8::Object> holder = info.Holder();
TestObject* impl = V8TestObject::toImpl(holder);
v8SetReturnValueInt(info, impl->originTrialEnabledLongAttribute());
@@ -2715,15 +2661,6 @@ static void originTrialEnabledLongAttributeAttributeGetter(const v8::FunctionCal
static void originTrialEnabledLongAttributeAttributeGetterCallback(const v8::FunctionCallbackInfo<v8::Value>& info)
{
- ExecutionContext* executionContext = currentExecutionContext(info.GetIsolate());
- String errorMessage;
- if (!OriginTrials::featureNameEnabled(executionContext, errorMessage)) {
- v8SetReturnValue(info, v8::Undefined(info.GetIsolate()));
- if (!errorMessage.isEmpty()) {
- executionContext->addConsoleMessage(ConsoleMessage::create(JSMessageSource, ErrorMessageLevel, errorMessage));
- }
- return;
- }
TestObjectV8Internal::originTrialEnabledLongAttributeAttributeGetter(info);
}
@@ -4595,15 +4532,6 @@ static void unscopeableLongAttributeAttributeSetterCallback(const v8::FunctionCa
static void unscopeableOriginTrialEnabledLongAttributeAttributeGetter(const v8::FunctionCallbackInfo<v8::Value>& info)
{
- ExecutionContext* executionContext = currentExecutionContext(info.GetIsolate());
- String errorMessage;
- if (!OriginTrials::featureNameEnabled(executionContext, errorMessage)) {
- v8SetReturnValue(info, v8::Undefined(info.GetIsolate()));
- if (!errorMessage.isEmpty()) {
- executionContext->addConsoleMessage(ConsoleMessage::create(JSMessageSource, ErrorMessageLevel, errorMessage));
- }
- return;
- }
v8::Local<v8::Object> holder = info.Holder();
TestObject* impl = V8TestObject::toImpl(holder);
v8SetReturnValueInt(info, impl->unscopeableOriginTrialEnabledLongAttribute());
@@ -4611,15 +4539,6 @@ static void unscopeableOriginTrialEnabledLongAttributeAttributeGetter(const v8::
static void unscopeableOriginTrialEnabledLongAttributeAttributeGetterCallback(const v8::FunctionCallbackInfo<v8::Value>& info)
{
- ExecutionContext* executionContext = currentExecutionContext(info.GetIsolate());
- String errorMessage;
- if (!OriginTrials::featureNameEnabled(executionContext, errorMessage)) {
- v8SetReturnValue(info, v8::Undefined(info.GetIsolate()));
- if (!errorMessage.isEmpty()) {
- executionContext->addConsoleMessage(ConsoleMessage::create(JSMessageSource, ErrorMessageLevel, errorMessage));
- }
- return;
- }
TestObjectV8Internal::unscopeableOriginTrialEnabledLongAttributeAttributeGetter(info);
}
@@ -9867,15 +9786,6 @@ static void originTrialEnabledVoidMethodMethod(const v8::FunctionCallbackInfo<v8
static void originTrialEnabledVoidMethodMethodCallback(const v8::FunctionCallbackInfo<v8::Value>& info)
{
- ExecutionContext* executionContext = currentExecutionContext(info.GetIsolate());
- String errorMessage;
- if (!OriginTrials::featureNameEnabled(executionContext, errorMessage)) {
- v8SetReturnValue(info, v8::Undefined(info.GetIsolate()));
- if (!errorMessage.isEmpty()) {
- executionContext->addConsoleMessage(ConsoleMessage::create(JSMessageSource, ErrorMessageLevel, errorMessage));
- }
- return;
- }
TestObjectV8Internal::originTrialEnabledVoidMethodMethod(info);
}
@@ -9887,15 +9797,6 @@ static void perWorldBindingsOriginTrialEnabledVoidMethodMethod(const v8::Functio
static void perWorldBindingsOriginTrialEnabledVoidMethodMethodCallback(const v8::FunctionCallbackInfo<v8::Value>& info)
{
- ExecutionContext* executionContext = currentExecutionContext(info.GetIsolate());
- String errorMessage;
- if (!OriginTrials::featureNameEnabled(executionContext, errorMessage)) {
- v8SetReturnValue(info, v8::Undefined(info.GetIsolate()));
- if (!errorMessage.isEmpty()) {
- executionContext->addConsoleMessage(ConsoleMessage::create(JSMessageSource, ErrorMessageLevel, errorMessage));
- }
- return;
- }
TestObjectV8Internal::perWorldBindingsOriginTrialEnabledVoidMethodMethod(info);
}
@@ -9907,15 +9808,6 @@ static void perWorldBindingsOriginTrialEnabledVoidMethodMethodForMainWorld(const
static void perWorldBindingsOriginTrialEnabledVoidMethodMethodCallbackForMainWorld(const v8::FunctionCallbackInfo<v8::Value>& info)
{
- ExecutionContext* executionContext = currentExecutionContext(info.GetIsolate());
- String errorMessage;
- if (!OriginTrials::featureNameEnabled(executionContext, errorMessage)) {
- v8SetReturnValue(info, v8::Undefined(info.GetIsolate()));
- if (!errorMessage.isEmpty()) {
- executionContext->addConsoleMessage(ConsoleMessage::create(JSMessageSource, ErrorMessageLevel, errorMessage));
- }
- return;
- }
TestObjectV8Internal::perWorldBindingsOriginTrialEnabledVoidMethodMethodForMainWorld(info);
}
@@ -11599,7 +11491,6 @@ const V8DOMConfiguration::AccessorConfiguration V8TestObjectAccessors[] = {
{"customSetterImplementedAsLongAttribute", TestObjectV8Internal::customSetterImplementedAsLongAttributeAttributeGetterCallback, TestObjectV8Internal::customSetterImplementedAsLongAttributeAttributeSetterCallback, 0, 0, 0, v8::DEFAULT, static_cast<v8::PropertyAttribute>(v8::None), V8DOMConfiguration::ExposedToAllScripts, V8DOMConfiguration::OnPrototype, V8DOMConfiguration::CheckHolder},
{"measureAsLongAttribute", TestObjectV8Internal::measureAsLongAttributeAttributeGetterCallback, TestObjectV8Internal::measureAsLongAttributeAttributeSetterCallback, 0, 0, 0, v8::DEFAULT, static_cast<v8::PropertyAttribute>(v8::None), V8DOMConfiguration::ExposedToAllScripts, V8DOMConfiguration::OnPrototype, V8DOMConfiguration::CheckHolder},
{"notEnumerableLongAttribute", TestObjectV8Internal::notEnumerableLongAttributeAttributeGetterCallback, TestObjectV8Internal::notEnumerableLongAttributeAttributeSetterCallback, 0, 0, 0, v8::DEFAULT, static_cast<v8::PropertyAttribute>(v8::DontEnum), V8DOMConfiguration::ExposedToAllScripts, V8DOMConfiguration::OnPrototype, V8DOMConfiguration::CheckHolder},
- {"originTrialEnabledLongAttribute", TestObjectV8Internal::originTrialEnabledLongAttributeAttributeGetterCallback, TestObjectV8Internal::originTrialEnabledLongAttributeAttributeSetterCallback, 0, 0, 0, v8::DEFAULT, static_cast<v8::PropertyAttribute>(v8::None), V8DOMConfiguration::ExposedToAllScripts, V8DOMConfiguration::OnPrototype, V8DOMConfiguration::CheckHolder},
{"perWorldBindingsReadonlyTestInterfaceEmptyAttribute", TestObjectV8Internal::perWorldBindingsReadonlyTestInterfaceEmptyAttributeAttributeGetterCallback, 0, TestObjectV8Internal::perWorldBindingsReadonlyTestInterfaceEmptyAttributeAttributeGetterCallbackForMainWorld, 0, 0, v8::DEFAULT, static_cast<v8::PropertyAttribute>(v8::ReadOnly), V8DOMConfiguration::ExposedToAllScripts, V8DOMConfiguration::OnPrototype, V8DOMConfiguration::CheckHolder},
{"activityLoggingAccessPerWorldBindingsLongAttribute", TestObjectV8Internal::activityLoggingAccessPerWorldBindingsLongAttributeAttributeGetterCallback, TestObjectV8Internal::activityLoggingAccessPerWorldBindingsLongAttributeAttributeSetterCallback, TestObjectV8Internal::activityLoggingAccessPerWorldBindingsLongAttributeAttributeGetterCallbackForMainWorld, TestObjectV8Internal::activityLoggingAccessPerWorldBindingsLongAttributeAttributeSetterCallbackForMainWorld, 0, v8::DEFAULT, static_cast<v8::PropertyAttribute>(v8::None), V8DOMConfiguration::ExposedToAllScripts, V8DOMConfiguration::OnPrototype, V8DOMConfiguration::CheckHolder},
{"activityLoggingAccessForIsolatedWorldsPerWorldBindingsLongAttribute", TestObjectV8Internal::activityLoggingAccessForIsolatedWorldsPerWorldBindingsLongAttributeAttributeGetterCallback, TestObjectV8Internal::activityLoggingAccessForIsolatedWorldsPerWorldBindingsLongAttributeAttributeSetterCallback, TestObjectV8Internal::activityLoggingAccessForIsolatedWorldsPerWorldBindingsLongAttributeAttributeGetterCallbackForMainWorld, TestObjectV8Internal::activityLoggingAccessForIsolatedWorldsPerWorldBindingsLongAttributeAttributeSetterCallbackForMainWorld, 0, v8::DEFAULT, static_cast<v8::PropertyAttribute>(v8::None), V8DOMConfiguration::ExposedToAllScripts, V8DOMConfiguration::OnPrototype, V8DOMConfiguration::CheckHolder},
@@ -11652,7 +11543,6 @@ const V8DOMConfiguration::AccessorConfiguration V8TestObjectAccessors[] = {
{"sameObjectAttribute", TestObjectV8Internal::sameObjectAttributeAttributeGetterCallback, 0, 0, 0, 0, v8::DEFAULT, static_cast<v8::PropertyAttribute>(v8::ReadOnly), V8DOMConfiguration::ExposedToAllScripts, V8DOMConfiguration::OnPrototype, V8DOMConfiguration::CheckHolder},
{"saveSameObjectAttribute", TestObjectV8Internal::saveSameObjectAttributeAttributeGetterCallback, 0, 0, 0, 0, v8::DEFAULT, static_cast<v8::PropertyAttribute>(v8::ReadOnly), V8DOMConfiguration::ExposedToAllScripts, V8DOMConfiguration::OnPrototype, V8DOMConfiguration::CheckHolder},
{"unscopeableLongAttribute", TestObjectV8Internal::unscopeableLongAttributeAttributeGetterCallback, TestObjectV8Internal::unscopeableLongAttributeAttributeSetterCallback, 0, 0, 0, v8::DEFAULT, static_cast<v8::PropertyAttribute>(v8::None), V8DOMConfiguration::ExposedToAllScripts, V8DOMConfiguration::OnPrototype, V8DOMConfiguration::CheckHolder},
- {"unscopeableOriginTrialEnabledLongAttribute", TestObjectV8Internal::unscopeableOriginTrialEnabledLongAttributeAttributeGetterCallback, TestObjectV8Internal::unscopeableOriginTrialEnabledLongAttributeAttributeSetterCallback, 0, 0, 0, v8::DEFAULT, static_cast<v8::PropertyAttribute>(v8::None), V8DOMConfiguration::ExposedToAllScripts, V8DOMConfiguration::OnPrototype, V8DOMConfiguration::CheckHolder},
{"testInterfaceAttribute", TestObjectV8Internal::testInterfaceAttributeAttributeGetterCallback, TestObjectV8Internal::testInterfaceAttributeAttributeSetterCallback, 0, 0, 0, v8::DEFAULT, static_cast<v8::PropertyAttribute>(v8::None), V8DOMConfiguration::ExposedToAllScripts, V8DOMConfiguration::OnPrototype, V8DOMConfiguration::CheckHolder},
{"testInterfaceGarbageCollectedAttribute", TestObjectV8Internal::testInterfaceGarbageCollectedAttributeAttributeGetterCallback, TestObjectV8Internal::testInterfaceGarbageCollectedAttributeAttributeSetterCallback, 0, 0, 0, v8::DEFAULT, static_cast<v8::PropertyAttribute>(v8::None), V8DOMConfiguration::ExposedToAllScripts, V8DOMConfiguration::OnPrototype, V8DOMConfiguration::CheckHolder},
{"testInterfaceGarbageCollectedOrNullAttribute", TestObjectV8Internal::testInterfaceGarbageCollectedOrNullAttributeAttributeGetterCallback, TestObjectV8Internal::testInterfaceGarbageCollectedOrNullAttributeAttributeSetterCallback, 0, 0, 0, v8::DEFAULT, static_cast<v8::PropertyAttribute>(v8::None), V8DOMConfiguration::ExposedToAllScripts, V8DOMConfiguration::OnPrototype, V8DOMConfiguration::CheckHolder},
@@ -12042,6 +11932,19 @@ static void installV8TestObjectTemplate(v8::Isolate* isolate, const DOMWrapperWo
V8DOMConfiguration::installMethod(isolate, world, instanceTemplate, prototypeTemplate, interfaceTemplate, signature, partiallyRuntimeEnabledOverloadedVoidMethodMethodConfiguration);
}
+
+void V8TestObject::installFeatureName(ScriptState* scriptState, v8::Local<v8::Object> instance)
+{
+ v8::Local<v8::Object> prototype = instance->GetPrototype()->ToObject(scriptState->isolate());
+ v8::Local<v8::Signature> signature;
+ ALLOW_UNUSED_LOCAL(signature);
+ const V8DOMConfiguration::AccessorConfiguration accessororiginTrialEnabledLongAttributeConfiguration = \
+ {"originTrialEnabledLongAttribute", TestObjectV8Internal::originTrialEnabledLongAttributeAttributeGetterCallback, TestObjectV8Internal::originTrialEnabledLongAttributeAttributeSetterCallback, 0, 0, 0, v8::DEFAULT, static_cast<v8::PropertyAttribute>(v8::None), V8DOMConfiguration::ExposedToAllScripts, V8DOMConfiguration::OnPrototype, V8DOMConfiguration::CheckHolder};
+ V8DOMConfiguration::installAccessor(scriptState->isolate(), scriptState->world(), instance, prototype, v8::Local<v8::Function>(), signature, accessororiginTrialEnabledLongAttributeConfiguration);
+ const V8DOMConfiguration::AccessorConfiguration accessorunscopeableOriginTrialEnabledLongAttributeConfiguration = \
+ {"unscopeableOriginTrialEnabledLongAttribute", TestObjectV8Internal::unscopeableOriginTrialEnabledLongAttributeAttributeGetterCallback, TestObjectV8Internal::unscopeableOriginTrialEnabledLongAttributeAttributeSetterCallback, 0, 0, 0, v8::DEFAULT, static_cast<v8::PropertyAttribute>(v8::None), V8DOMConfiguration::ExposedToAllScripts, V8DOMConfiguration::OnPrototype, V8DOMConfiguration::CheckHolder};
+ V8DOMConfiguration::installAccessor(scriptState->isolate(), scriptState->world(), instance, prototype, v8::Local<v8::Function>(), signature, accessorunscopeableOriginTrialEnabledLongAttributeConfiguration);
+}
v8::Local<v8::FunctionTemplate> V8TestObject::domTemplate(v8::Isolate* isolate, const DOMWrapperWorld& world)
{
return V8DOMConfiguration::domClassTemplate(isolate, world, const_cast<WrapperTypeInfo*>(&wrapperTypeInfo), installV8TestObjectTemplate);

Powered by Google App Engine
This is Rietveld 408576698