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

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

Issue 2832923003: v8binding: Don't allow author script to define indexed accessor prop. (Closed)
Patch Set: Added the test expectation. Created 3 years, 5 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/V8TestInterface.cpp
diff --git a/third_party/WebKit/Source/bindings/tests/results/core/V8TestInterface.cpp b/third_party/WebKit/Source/bindings/tests/results/core/V8TestInterface.cpp
index 28eff1b7ffdc463d96de89c6016cd7a6bdf196c7..0583c0ff680c8b014cde9dc6876f5428bc9938e1 100644
--- a/third_party/WebKit/Source/bindings/tests/results/core/V8TestInterface.cpp
+++ b/third_party/WebKit/Source/bindings/tests/results/core/V8TestInterface.cpp
@@ -2899,6 +2899,28 @@ void V8TestInterface::indexedPropertyDeleterCallback(uint32_t index, const v8::P
TestInterfaceImplementationV8Internal::indexedPropertyDeleter(index, info);
}
+void V8TestInterface::indexedPropertyDefinerCallback(
+ uint32_t index,
+ const v8::PropertyDescriptor& desc,
+ const v8::PropertyCallbackInfo<v8::Value>& info) {
+ // https://heycam.github.io/webidl/#legacy-platform-object-defineownproperty
+ // 3.9.3. [[DefineOwnProperty]]
+ // step 1.1. If the result of calling IsDataDescriptor(Desc) is false, then
+ // return false.
+ if (desc.has_get() || desc.has_set()) {
+ V8SetReturnValue(info, v8::Null(info.GetIsolate()));
+ if (info.ShouldThrowOnError()) {
+ ExceptionState exceptionState(info.GetIsolate(),
+ ExceptionState::kIndexedSetterContext,
+ "TestInterface");
+ exceptionState.ThrowTypeError("Accessor properties are not allowed.");
+ }
+ return;
+ }
+
+ // Return nothing and fall back to indexedPropertySetterCallback.
+}
+
// Suppress warning: global constructors, because AttributeConfiguration is trivial
// and does not depend on another global objects.
#if defined(COMPONENT_BUILD) && defined(WIN32) && defined(__clang__)
@@ -3032,7 +3054,15 @@ void V8TestInterface::installV8TestInterfaceTemplate(
signature, V8TestInterfaceMethods, WTF_ARRAY_LENGTH(V8TestInterfaceMethods));
// Indexed properties
- v8::IndexedPropertyHandlerConfiguration indexedPropertyHandlerConfig(V8TestInterface::indexedPropertyGetterCallback, V8TestInterface::indexedPropertySetterCallback, nullptr, V8TestInterface::indexedPropertyDeleterCallback, IndexedPropertyEnumerator<TestInterfaceImplementation>, v8::Local<v8::Value>(), v8::PropertyHandlerFlags::kNone);
+ v8::IndexedPropertyHandlerConfiguration indexedPropertyHandlerConfig(
+ V8TestInterface::indexedPropertyGetterCallback,
+ V8TestInterface::indexedPropertySetterCallback,
+ nullptr,
+ V8TestInterface::indexedPropertyDeleterCallback,
+ IndexedPropertyEnumerator<TestInterfaceImplementation>,
+ V8TestInterface::indexedPropertyDefinerCallback,
+ v8::Local<v8::Value>(),
+ v8::PropertyHandlerFlags::kNone);
instanceTemplate->SetHandler(indexedPropertyHandlerConfig);
// Named properties
v8::NamedPropertyHandlerConfiguration namedPropertyHandlerConfig(V8TestInterface::namedPropertyGetterCallback, V8TestInterface::namedPropertySetterCallback, V8TestInterface::namedPropertyQueryCallback, V8TestInterface::namedPropertyDeleterCallback, V8TestInterface::namedPropertyEnumeratorCallback, v8::Local<v8::Value>(), static_cast<v8::PropertyHandlerFlags>(int(v8::PropertyHandlerFlags::kOnlyInterceptStrings) | int(v8::PropertyHandlerFlags::kNonMasking)));

Powered by Google App Engine
This is Rietveld 408576698