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

Unified Diff: third_party/WebKit/Source/bindings/tests/results/core/V8TestInterface2.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/V8TestInterface2.cpp
diff --git a/third_party/WebKit/Source/bindings/tests/results/core/V8TestInterface2.cpp b/third_party/WebKit/Source/bindings/tests/results/core/V8TestInterface2.cpp
index 670b815d062b31e3892d7484300955d2d14b77cc..7613d4bd9ea221a0bf6906f49db2a4a5e3480f1c 100644
--- a/third_party/WebKit/Source/bindings/tests/results/core/V8TestInterface2.cpp
+++ b/third_party/WebKit/Source/bindings/tests/results/core/V8TestInterface2.cpp
@@ -587,6 +587,28 @@ void V8TestInterface2::indexedPropertyDeleterCallback(uint32_t index, const v8::
TestInterface2V8Internal::indexedPropertyDeleter(index, info);
}
+void V8TestInterface2::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,
+ "TestInterface2");
+ exceptionState.ThrowTypeError("Accessor properties are not allowed.");
+ }
+ return;
+ }
+
+ // Return nothing and fall back to indexedPropertySetterCallback.
+}
+
static const V8DOMConfiguration::AccessorConfiguration V8TestInterface2Accessors[] = {
{ "size", V8TestInterface2::sizeAttributeGetterCallback, nullptr, nullptr, nullptr, static_cast<v8::PropertyAttribute>(v8::DontEnum | v8::ReadOnly), V8DOMConfiguration::kOnPrototype, V8DOMConfiguration::kCheckHolder, V8DOMConfiguration::kAllWorlds },
};
@@ -647,7 +669,15 @@ void V8TestInterface2::installV8TestInterface2Template(
signature, V8TestInterface2Methods, WTF_ARRAY_LENGTH(V8TestInterface2Methods));
// Indexed properties
- v8::IndexedPropertyHandlerConfiguration indexedPropertyHandlerConfig(V8TestInterface2::indexedPropertyGetterCallback, V8TestInterface2::indexedPropertySetterCallback, nullptr, V8TestInterface2::indexedPropertyDeleterCallback, IndexedPropertyEnumerator<TestInterface2>, v8::Local<v8::Value>(), v8::PropertyHandlerFlags::kNone);
+ v8::IndexedPropertyHandlerConfiguration indexedPropertyHandlerConfig(
+ V8TestInterface2::indexedPropertyGetterCallback,
+ V8TestInterface2::indexedPropertySetterCallback,
+ nullptr,
+ V8TestInterface2::indexedPropertyDeleterCallback,
+ IndexedPropertyEnumerator<TestInterface2>,
+ V8TestInterface2::indexedPropertyDefinerCallback,
+ v8::Local<v8::Value>(),
+ v8::PropertyHandlerFlags::kNone);
instanceTemplate->SetHandler(indexedPropertyHandlerConfig);
// Named properties
v8::NamedPropertyHandlerConfiguration namedPropertyHandlerConfig(V8TestInterface2::namedPropertyGetterCallback, V8TestInterface2::namedPropertySetterCallback, V8TestInterface2::namedPropertyQueryCallback, V8TestInterface2::namedPropertyDeleterCallback, V8TestInterface2::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