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

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

Issue 1526183004: Prevent SharedArrayBuffer views from being used in bindings (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: some tests 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
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 af019afcd3c41351d5c0560b51c98af985480646..fed3c907d71abd0c734d5065e2e719cda06d1c0c 100644
--- a/third_party/WebKit/Source/bindings/tests/results/core/V8TestObject.cpp
+++ b/third_party/WebKit/Source/bindings/tests/results/core/V8TestObject.cpp
@@ -11,6 +11,7 @@
// clang-format off
#include "V8TestObject.h"
+#include "bindings/core/v8/ArrayBufferOrArrayBufferView.h"
#include "bindings/core/v8/ArrayBufferOrArrayBufferViewOrDictionary.h"
#include "bindings/core/v8/BindingSecurity.h"
#include "bindings/core/v8/BooleanOrStringOrUnrestrictedDouble.h"
@@ -6051,6 +6052,10 @@ static void voidMethodArrayBufferViewArgMethod(const v8::FunctionCallbackInfo<v8
return;
}
+ if (arrayBufferViewArg->isShared()) {
+ V8ThrowException::throwTypeError(info.GetIsolate(), ExceptionMessages::failedToExecute("voidMethodArrayBufferViewArg", "TestObject", "parameter 1 is a view of a SharedArrayBuffer."));
+ return;
+ }
impl->voidMethodArrayBufferViewArg(arrayBufferViewArg);
}
@@ -6074,6 +6079,10 @@ static void voidMethodFlexibleArrayBufferViewArgMethod(const v8::FunctionCallbac
return;
}
+ if (arrayBufferViewArg.isShared()) {
+ V8ThrowException::throwTypeError(info.GetIsolate(), ExceptionMessages::failedToExecute("voidMethodFlexibleArrayBufferViewArg", "TestObject", "parameter 1 is a view of a SharedArrayBuffer."));
+ return;
+ }
impl->voidMethodFlexibleArrayBufferViewArg(arrayBufferViewArg);
}
@@ -6097,6 +6106,10 @@ static void voidMethodFlexibleArrayBufferViewTypedArgMethod(const v8::FunctionCa
return;
}
+ if (typedArrayBufferViewArg.isShared()) {
+ V8ThrowException::throwTypeError(info.GetIsolate(), ExceptionMessages::failedToExecute("voidMethodFlexibleArrayBufferViewTypedArg", "TestObject", "parameter 1 is a view of a SharedArrayBuffer."));
+ return;
+ }
impl->voidMethodFlexibleArrayBufferViewTypedArg(typedArrayBufferViewArg);
}
@@ -6120,6 +6133,10 @@ static void voidMethodFloat32ArrayArgMethod(const v8::FunctionCallbackInfo<v8::V
return;
}
+ if (float32ArrayArg->isShared()) {
+ V8ThrowException::throwTypeError(info.GetIsolate(), ExceptionMessages::failedToExecute("voidMethodFloat32ArrayArg", "TestObject", "parameter 1 is a view of a SharedArrayBuffer."));
+ return;
+ }
impl->voidMethodFloat32ArrayArg(float32ArrayArg);
}
@@ -6143,6 +6160,10 @@ static void voidMethodInt32ArrayArgMethod(const v8::FunctionCallbackInfo<v8::Val
return;
}
+ if (int32ArrayArg->isShared()) {
+ V8ThrowException::throwTypeError(info.GetIsolate(), ExceptionMessages::failedToExecute("voidMethodInt32ArrayArg", "TestObject", "parameter 1 is a view of a SharedArrayBuffer."));
+ return;
+ }
impl->voidMethodInt32ArrayArg(int32ArrayArg);
}
@@ -6166,6 +6187,10 @@ static void voidMethodUint8ArrayArgMethod(const v8::FunctionCallbackInfo<v8::Val
return;
}
+ if (uint8ArrayArg->isShared()) {
+ V8ThrowException::throwTypeError(info.GetIsolate(), ExceptionMessages::failedToExecute("voidMethodUint8ArrayArg", "TestObject", "parameter 1 is a view of a SharedArrayBuffer."));
+ return;
+ }
impl->voidMethodUint8ArrayArg(uint8ArrayArg);
}
@@ -6490,6 +6515,34 @@ void voidMethodTestInterfaceEmptyFrozenArrayMethodMethodCallback(const v8::Funct
TestObjectV8Internal::voidMethodTestInterfaceEmptyFrozenArrayMethodMethod(info);
}
+static void voidMethodSequenceUnionArrayBufferViewMethod(const v8::FunctionCallbackInfo<v8::Value>& info) {
+ ExceptionState exceptionState(info.GetIsolate(), ExceptionState::ExecutionContext, "TestObject", "voidMethodSequenceUnionArrayBufferView");
+
+ TestObject* impl = V8TestObject::toImpl(info.Holder());
+
+ if (UNLIKELY(info.Length() < 1)) {
+ exceptionState.throwTypeError(ExceptionMessages::notEnoughArguments(1, info.Length()));
+ return;
+ }
+
+ HeapVector<ArrayBufferOrArrayBufferView> unionSequenceArg;
+ unionSequenceArg = toImplArray<HeapVector<ArrayBufferOrArrayBufferView>>(info[0], 1, info.GetIsolate(), exceptionState);
+ if (exceptionState.hadException())
+ return;
+ for (size_t i= 0; i < unionSequenceArg.size(); ++i) {
+ if (unionSequenceArg[i].isArrayBufferView() && unionSequenceArg[i].getAsArrayBufferView()->isShared()) {
+ exceptionState.throwTypeError("sequence parameter 1 contains a view of a SharedArrayBuffer.");
+ return;
+ }
+ }
+
+ impl->voidMethodSequenceUnionArrayBufferView(unionSequenceArg);
+}
+
+void voidMethodSequenceUnionArrayBufferViewMethodCallback(const v8::FunctionCallbackInfo<v8::Value>& info) {
+ TestObjectV8Internal::voidMethodSequenceUnionArrayBufferViewMethod(info);
+}
+
static void nullableLongMethodMethod(const v8::FunctionCallbackInfo<v8::Value>& info) {
TestObject* impl = V8TestObject::toImpl(info.Holder());
@@ -6654,6 +6707,10 @@ static void voidMethodDOMStringOrArrayBufferOrArrayBufferViewArgMethod(const v8:
V8StringOrArrayBufferOrArrayBufferView::toImpl(info.GetIsolate(), info[0], arg, UnionTypeConversionMode::NotNullable, exceptionState);
if (exceptionState.hadException())
return;
+ if (arg.isArrayBufferView() && arg.getAsArrayBufferView()->isShared()) {
+ exceptionState.throwTypeError("parameter 1 is a view of a SharedArrayBuffer.");
+ return;
+ }
impl->voidMethodDOMStringOrArrayBufferOrArrayBufferViewArg(arg);
}
@@ -6676,6 +6733,10 @@ static void voidMethodArrayBufferOrArrayBufferViewOrDictionaryArgMethod(const v8
V8ArrayBufferOrArrayBufferViewOrDictionary::toImpl(info.GetIsolate(), info[0], arg, UnionTypeConversionMode::NotNullable, exceptionState);
if (exceptionState.hadException())
return;
+ if (arg.isArrayBufferView() && arg.getAsArrayBufferView()->isShared()) {
+ exceptionState.throwTypeError("parameter 1 is a view of a SharedArrayBuffer.");
+ return;
+ }
impl->voidMethodArrayBufferOrArrayBufferViewOrDictionaryArg(arg);
}
@@ -11429,6 +11490,7 @@ const V8DOMConfiguration::MethodConfiguration V8TestObjectMethods[] = {
{"longFrozenArrayMethod", TestObjectV8Internal::longFrozenArrayMethodMethodCallback, 0, 0, v8::None, V8DOMConfiguration::OnPrototype, V8DOMConfiguration::CheckHolder},
{"voidMethodStringFrozenArrayMethod", TestObjectV8Internal::voidMethodStringFrozenArrayMethodMethodCallback, 0, 1, v8::None, V8DOMConfiguration::OnPrototype, V8DOMConfiguration::CheckHolder},
{"voidMethodTestInterfaceEmptyFrozenArrayMethod", TestObjectV8Internal::voidMethodTestInterfaceEmptyFrozenArrayMethodMethodCallback, 0, 1, v8::None, V8DOMConfiguration::OnPrototype, V8DOMConfiguration::CheckHolder},
+ {"voidMethodSequenceUnionArrayBufferView", TestObjectV8Internal::voidMethodSequenceUnionArrayBufferViewMethodCallback, 0, 1, v8::None, V8DOMConfiguration::OnPrototype, V8DOMConfiguration::CheckHolder},
{"nullableLongMethod", TestObjectV8Internal::nullableLongMethodMethodCallback, 0, 0, v8::None, V8DOMConfiguration::OnPrototype, V8DOMConfiguration::CheckHolder},
{"nullableStringMethod", TestObjectV8Internal::nullableStringMethodMethodCallback, 0, 0, v8::None, V8DOMConfiguration::OnPrototype, V8DOMConfiguration::CheckHolder},
{"nullableTestInterfaceMethod", TestObjectV8Internal::nullableTestInterfaceMethodMethodCallback, 0, 0, v8::None, V8DOMConfiguration::OnPrototype, V8DOMConfiguration::CheckHolder},

Powered by Google App Engine
This is Rietveld 408576698