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

Unified Diff: third_party/WebKit/Source/bindings/tests/results/core/V8TestIntegerIndexedGlobal.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/V8TestIntegerIndexedGlobal.cpp
diff --git a/third_party/WebKit/Source/bindings/tests/results/core/V8TestIntegerIndexedGlobal.cpp b/third_party/WebKit/Source/bindings/tests/results/core/V8TestIntegerIndexedGlobal.cpp
index 7cbb68b50aa7e3dbcdb709a1ddcdebfa2df8d91d..809d9c6c71e178e9b8f31168261a3c8ae8d3dfa9 100644
--- a/third_party/WebKit/Source/bindings/tests/results/core/V8TestIntegerIndexedGlobal.cpp
+++ b/third_party/WebKit/Source/bindings/tests/results/core/V8TestIntegerIndexedGlobal.cpp
@@ -177,6 +177,28 @@ void V8TestIntegerIndexedGlobal::indexedPropertyDeleterCallback(uint32_t index,
V8TestIntegerIndexedGlobal::indexedPropertyDeleterCustom(index, info);
}
+void V8TestIntegerIndexedGlobal::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,
+ "TestIntegerIndexedGlobal");
+ exceptionState.ThrowTypeError("Accessor properties are not allowed.");
+ }
+ return;
+ }
+
+ // Return nothing and fall back to indexedPropertySetterCallback.
+}
+
static const V8DOMConfiguration::AccessorConfiguration V8TestIntegerIndexedGlobalAccessors[] = {
{ "length", V8TestIntegerIndexedGlobal::lengthAttributeGetterCallback, V8TestIntegerIndexedGlobal::lengthAttributeSetterCallback, nullptr, nullptr, static_cast<v8::PropertyAttribute>(v8::None), V8DOMConfiguration::kOnInstance, V8DOMConfiguration::kCheckHolder, V8DOMConfiguration::kAllWorlds },
};
@@ -214,7 +236,15 @@ static void installV8TestIntegerIndexedGlobalTemplate(
signature, V8TestIntegerIndexedGlobalMethods, WTF_ARRAY_LENGTH(V8TestIntegerIndexedGlobalMethods));
// Indexed properties
- v8::IndexedPropertyHandlerConfiguration indexedPropertyHandlerConfig(V8TestIntegerIndexedGlobal::indexedPropertyGetterCallback, V8TestIntegerIndexedGlobal::indexedPropertySetterCallback, nullptr, V8TestIntegerIndexedGlobal::indexedPropertyDeleterCallback, IndexedPropertyEnumerator<TestIntegerIndexedGlobal>, v8::Local<v8::Value>(), v8::PropertyHandlerFlags::kNone);
+ v8::IndexedPropertyHandlerConfiguration indexedPropertyHandlerConfig(
+ V8TestIntegerIndexedGlobal::indexedPropertyGetterCallback,
+ V8TestIntegerIndexedGlobal::indexedPropertySetterCallback,
+ nullptr,
+ V8TestIntegerIndexedGlobal::indexedPropertyDeleterCallback,
+ IndexedPropertyEnumerator<TestIntegerIndexedGlobal>,
+ V8TestIntegerIndexedGlobal::indexedPropertyDefinerCallback,
+ v8::Local<v8::Value>(),
+ v8::PropertyHandlerFlags::kNone);
instanceTemplate->SetHandler(indexedPropertyHandlerConfig);
// Array iterator (@@iterator)

Powered by Google App Engine
This is Rietveld 408576698