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

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

Issue 2707243006: [SharedArrayBuffer] Prevent SharedArrayBuffer being used in Web APIs (Closed)
Patch Set: add missing tests Created 3 years, 8 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 b0e8d993943cb91b840dd25944f15227ccb8c9c2..78f97e6833f511152efab7ee4b8e9783bb006f62 100644
--- a/third_party/WebKit/Source/bindings/tests/results/core/V8TestObject.cpp
+++ b/third_party/WebKit/Source/bindings/tests/results/core/V8TestObject.cpp
@@ -61,6 +61,7 @@
#include "core/dom/DOMArrayBufferBase.h"
#include "core/dom/Document.h"
#include "core/dom/FlexibleArrayBufferView.h"
+#include "core/dom/NotShared.h"
#include "core/dom/TagCollection.h"
#include "core/dom/custom/V0CustomElementProcessingStack.h"
#include "core/frame/Deprecation.h"
@@ -1099,7 +1100,7 @@ static void float32ArrayAttributeAttributeGetter(const v8::FunctionCallbackInfo<
TestObject* impl = V8TestObject::toImpl(holder);
- V8SetReturnValueFast(info, WTF::GetPtr(impl->float32ArrayAttribute()), impl);
+ V8SetReturnValueFast(info, impl->float32ArrayAttribute(), impl);
}
static void float32ArrayAttributeAttributeSetter(v8::Local<v8::Value> v8Value, const v8::FunctionCallbackInfo<v8::Value>& info) {
@@ -1112,7 +1113,9 @@ static void float32ArrayAttributeAttributeSetter(v8::Local<v8::Value> v8Value, c
ExceptionState exceptionState(isolate, ExceptionState::kSetterContext, "TestObject", "float32ArrayAttribute");
// Prepare the value to be set.
- DOMFloat32Array* cppValue = v8Value->IsFloat32Array() ? V8Float32Array::toImpl(v8::Local<v8::Float32Array>::Cast(v8Value)) : 0;
+ NotShared<DOMFloat32Array> cppValue = ToNotShared<NotShared<DOMFloat32Array>>(info.GetIsolate(), v8Value, exceptionState);
+ if (exceptionState.HadException())
+ return;
// Type check per: http://heycam.github.io/webidl/#es-interface
if (!cppValue) {
@@ -1128,7 +1131,7 @@ static void uint8ArrayAttributeAttributeGetter(const v8::FunctionCallbackInfo<v8
TestObject* impl = V8TestObject::toImpl(holder);
- V8SetReturnValueFast(info, WTF::GetPtr(impl->uint8ArrayAttribute()), impl);
+ V8SetReturnValueFast(info, impl->uint8ArrayAttribute(), impl);
}
static void uint8ArrayAttributeAttributeSetter(v8::Local<v8::Value> v8Value, const v8::FunctionCallbackInfo<v8::Value>& info) {
@@ -1141,7 +1144,9 @@ static void uint8ArrayAttributeAttributeSetter(v8::Local<v8::Value> v8Value, con
ExceptionState exceptionState(isolate, ExceptionState::kSetterContext, "TestObject", "uint8ArrayAttribute");
// Prepare the value to be set.
- DOMUint8Array* cppValue = v8Value->IsUint8Array() ? V8Uint8Array::toImpl(v8::Local<v8::Uint8Array>::Cast(v8Value)) : 0;
+ NotShared<DOMUint8Array> cppValue = ToNotShared<NotShared<DOMUint8Array>>(info.GetIsolate(), v8Value, exceptionState);
+ if (exceptionState.HadException())
+ return;
// Type check per: http://heycam.github.io/webidl/#es-interface
if (!cppValue) {
@@ -4663,6 +4668,18 @@ static void arrayBufferViewMethodMethod(const v8::FunctionCallbackInfo<v8::Value
V8SetReturnValue(info, impl->arrayBufferViewMethod());
}
+static void arrayBufferViewMethodRaisesExceptionMethod(const v8::FunctionCallbackInfo<v8::Value>& info) {
+ ExceptionState exceptionState(info.GetIsolate(), ExceptionState::kExecutionContext, "TestObject", "arrayBufferViewMethodRaisesException");
+
+ TestObject* impl = V8TestObject::toImpl(info.Holder());
+
+ NotShared<TestArrayBufferView> result = impl->arrayBufferViewMethodRaisesException(exceptionState);
+ if (exceptionState.HadException()) {
+ return;
+ }
+ V8SetReturnValue(info, result);
+}
+
static void float32ArrayMethodMethod(const v8::FunctionCallbackInfo<v8::Value>& info) {
TestObject* impl = V8TestObject::toImpl(info.Holder());
@@ -4709,7 +4726,7 @@ static void voidMethodArrayBufferOrNullArgMethod(const v8::FunctionCallbackInfo<
}
TestArrayBuffer* arrayBufferArg;
- arrayBufferArg = info[0]->IsArrayBuffer() ? V8ArrayBuffer::toImpl(v8::Local<v8::ArrayBuffer>::Cast(info[0])) : 0;
+ arrayBufferArg = V8ArrayBuffer::toImplWithTypeCheck(info.GetIsolate(), info[0]);
if (!arrayBufferArg && !IsUndefinedOrNull(info[0])) {
V8ThrowException::ThrowTypeError(info.GetIsolate(), ExceptionMessages::FailedToExecute("voidMethodArrayBufferOrNullArg", "TestObject", "parameter 1 is not of type 'ArrayBuffer'."));
@@ -4720,17 +4737,21 @@ static void voidMethodArrayBufferOrNullArgMethod(const v8::FunctionCallbackInfo<
}
static void voidMethodArrayBufferViewArgMethod(const v8::FunctionCallbackInfo<v8::Value>& info) {
+ ExceptionState exceptionState(info.GetIsolate(), ExceptionState::kExecutionContext, "TestObject", "voidMethodArrayBufferViewArg");
+
TestObject* impl = V8TestObject::toImpl(info.Holder());
if (UNLIKELY(info.Length() < 1)) {
- V8ThrowException::ThrowTypeError(info.GetIsolate(), ExceptionMessages::FailedToExecute("voidMethodArrayBufferViewArg", "TestObject", ExceptionMessages::NotEnoughArguments(1, info.Length())));
+ exceptionState.ThrowTypeError(ExceptionMessages::NotEnoughArguments(1, info.Length()));
return;
}
- TestArrayBufferView* arrayBufferViewArg;
- arrayBufferViewArg = info[0]->IsArrayBufferView() ? V8ArrayBufferView::toImpl(v8::Local<v8::ArrayBufferView>::Cast(info[0])) : 0;
+ NotShared<TestArrayBufferView> arrayBufferViewArg;
+ arrayBufferViewArg = ToNotShared<NotShared<TestArrayBufferView>>(info.GetIsolate(), info[0], exceptionState);
+ if (exceptionState.HadException())
+ return;
if (!arrayBufferViewArg) {
- V8ThrowException::ThrowTypeError(info.GetIsolate(), ExceptionMessages::FailedToExecute("voidMethodArrayBufferViewArg", "TestObject", "parameter 1 is not of type 'ArrayBufferView'."));
+ exceptionState.ThrowTypeError("parameter 1 is not of type 'ArrayBufferView'.");
return;
}
@@ -4739,17 +4760,19 @@ static void voidMethodArrayBufferViewArgMethod(const v8::FunctionCallbackInfo<v8
}
static void voidMethodFlexibleArrayBufferViewArgMethod(const v8::FunctionCallbackInfo<v8::Value>& info) {
+ ExceptionState exceptionState(info.GetIsolate(), ExceptionState::kExecutionContext, "TestObject", "voidMethodFlexibleArrayBufferViewArg");
+
TestObject* impl = V8TestObject::toImpl(info.Holder());
if (UNLIKELY(info.Length() < 1)) {
- V8ThrowException::ThrowTypeError(info.GetIsolate(), ExceptionMessages::FailedToExecute("voidMethodFlexibleArrayBufferViewArg", "TestObject", ExceptionMessages::NotEnoughArguments(1, info.Length())));
+ exceptionState.ThrowTypeError(ExceptionMessages::NotEnoughArguments(1, info.Length()));
return;
}
FlexibleArrayBufferView arrayBufferViewArg;
ToFlexibleArrayBufferView(info.GetIsolate(), info[0], arrayBufferViewArg, allocateFlexibleArrayBufferViewStorage(info[0]));
if (!arrayBufferViewArg) {
- V8ThrowException::ThrowTypeError(info.GetIsolate(), ExceptionMessages::FailedToExecute("voidMethodFlexibleArrayBufferViewArg", "TestObject", "parameter 1 is not of type 'ArrayBufferView'."));
+ exceptionState.ThrowTypeError("parameter 1 is not of type 'ArrayBufferView'.");
return;
}
@@ -4758,17 +4781,19 @@ static void voidMethodFlexibleArrayBufferViewArgMethod(const v8::FunctionCallbac
}
static void voidMethodFlexibleArrayBufferViewTypedArgMethod(const v8::FunctionCallbackInfo<v8::Value>& info) {
+ ExceptionState exceptionState(info.GetIsolate(), ExceptionState::kExecutionContext, "TestObject", "voidMethodFlexibleArrayBufferViewTypedArg");
+
TestObject* impl = V8TestObject::toImpl(info.Holder());
if (UNLIKELY(info.Length() < 1)) {
- V8ThrowException::ThrowTypeError(info.GetIsolate(), ExceptionMessages::FailedToExecute("voidMethodFlexibleArrayBufferViewTypedArg", "TestObject", ExceptionMessages::NotEnoughArguments(1, info.Length())));
+ exceptionState.ThrowTypeError(ExceptionMessages::NotEnoughArguments(1, info.Length()));
return;
}
FlexibleFloat32ArrayView typedArrayBufferViewArg;
ToFlexibleArrayBufferView(info.GetIsolate(), info[0], typedArrayBufferViewArg, allocateFlexibleArrayBufferViewStorage(info[0]));
if (!typedArrayBufferViewArg) {
- V8ThrowException::ThrowTypeError(info.GetIsolate(), ExceptionMessages::FailedToExecute("voidMethodFlexibleArrayBufferViewTypedArg", "TestObject", "parameter 1 is not of type 'Float32Array'."));
+ exceptionState.ThrowTypeError("parameter 1 is not of type 'Float32Array'.");
return;
}
@@ -4777,17 +4802,21 @@ static void voidMethodFlexibleArrayBufferViewTypedArgMethod(const v8::FunctionCa
}
static void voidMethodFloat32ArrayArgMethod(const v8::FunctionCallbackInfo<v8::Value>& info) {
+ ExceptionState exceptionState(info.GetIsolate(), ExceptionState::kExecutionContext, "TestObject", "voidMethodFloat32ArrayArg");
+
TestObject* impl = V8TestObject::toImpl(info.Holder());
if (UNLIKELY(info.Length() < 1)) {
- V8ThrowException::ThrowTypeError(info.GetIsolate(), ExceptionMessages::FailedToExecute("voidMethodFloat32ArrayArg", "TestObject", ExceptionMessages::NotEnoughArguments(1, info.Length())));
+ exceptionState.ThrowTypeError(ExceptionMessages::NotEnoughArguments(1, info.Length()));
return;
}
- DOMFloat32Array* float32ArrayArg;
- float32ArrayArg = info[0]->IsFloat32Array() ? V8Float32Array::toImpl(v8::Local<v8::Float32Array>::Cast(info[0])) : 0;
+ NotShared<DOMFloat32Array> float32ArrayArg;
+ float32ArrayArg = ToNotShared<NotShared<DOMFloat32Array>>(info.GetIsolate(), info[0], exceptionState);
+ if (exceptionState.HadException())
+ return;
if (!float32ArrayArg) {
- V8ThrowException::ThrowTypeError(info.GetIsolate(), ExceptionMessages::FailedToExecute("voidMethodFloat32ArrayArg", "TestObject", "parameter 1 is not of type 'Float32Array'."));
+ exceptionState.ThrowTypeError("parameter 1 is not of type 'Float32Array'.");
return;
}
@@ -4796,17 +4825,21 @@ static void voidMethodFloat32ArrayArgMethod(const v8::FunctionCallbackInfo<v8::V
}
static void voidMethodInt32ArrayArgMethod(const v8::FunctionCallbackInfo<v8::Value>& info) {
+ ExceptionState exceptionState(info.GetIsolate(), ExceptionState::kExecutionContext, "TestObject", "voidMethodInt32ArrayArg");
+
TestObject* impl = V8TestObject::toImpl(info.Holder());
if (UNLIKELY(info.Length() < 1)) {
- V8ThrowException::ThrowTypeError(info.GetIsolate(), ExceptionMessages::FailedToExecute("voidMethodInt32ArrayArg", "TestObject", ExceptionMessages::NotEnoughArguments(1, info.Length())));
+ exceptionState.ThrowTypeError(ExceptionMessages::NotEnoughArguments(1, info.Length()));
return;
}
- DOMInt32Array* int32ArrayArg;
- int32ArrayArg = info[0]->IsInt32Array() ? V8Int32Array::toImpl(v8::Local<v8::Int32Array>::Cast(info[0])) : 0;
+ NotShared<DOMInt32Array> int32ArrayArg;
+ int32ArrayArg = ToNotShared<NotShared<DOMInt32Array>>(info.GetIsolate(), info[0], exceptionState);
+ if (exceptionState.HadException())
+ return;
if (!int32ArrayArg) {
- V8ThrowException::ThrowTypeError(info.GetIsolate(), ExceptionMessages::FailedToExecute("voidMethodInt32ArrayArg", "TestObject", "parameter 1 is not of type 'Int32Array'."));
+ exceptionState.ThrowTypeError("parameter 1 is not of type 'Int32Array'.");
return;
}
@@ -4815,17 +4848,21 @@ static void voidMethodInt32ArrayArgMethod(const v8::FunctionCallbackInfo<v8::Val
}
static void voidMethodUint8ArrayArgMethod(const v8::FunctionCallbackInfo<v8::Value>& info) {
+ ExceptionState exceptionState(info.GetIsolate(), ExceptionState::kExecutionContext, "TestObject", "voidMethodUint8ArrayArg");
+
TestObject* impl = V8TestObject::toImpl(info.Holder());
if (UNLIKELY(info.Length() < 1)) {
- V8ThrowException::ThrowTypeError(info.GetIsolate(), ExceptionMessages::FailedToExecute("voidMethodUint8ArrayArg", "TestObject", ExceptionMessages::NotEnoughArguments(1, info.Length())));
+ exceptionState.ThrowTypeError(ExceptionMessages::NotEnoughArguments(1, info.Length()));
return;
}
- DOMUint8Array* uint8ArrayArg;
- uint8ArrayArg = info[0]->IsUint8Array() ? V8Uint8Array::toImpl(v8::Local<v8::Uint8Array>::Cast(info[0])) : 0;
+ NotShared<DOMUint8Array> uint8ArrayArg;
+ uint8ArrayArg = ToNotShared<NotShared<DOMUint8Array>>(info.GetIsolate(), info[0], exceptionState);
+ if (exceptionState.HadException())
+ return;
if (!uint8ArrayArg) {
- V8ThrowException::ThrowTypeError(info.GetIsolate(), ExceptionMessages::FailedToExecute("voidMethodUint8ArrayArg", "TestObject", "parameter 1 is not of type 'Uint8Array'."));
+ exceptionState.ThrowTypeError("parameter 1 is not of type 'Uint8Array'.");
return;
}
@@ -10904,6 +10941,10 @@ void V8TestObject::arrayBufferViewMethodMethodCallback(const v8::FunctionCallbac
TestObjectV8Internal::arrayBufferViewMethodMethod(info);
}
+void V8TestObject::arrayBufferViewMethodRaisesExceptionMethodCallback(const v8::FunctionCallbackInfo<v8::Value>& info) {
+ TestObjectV8Internal::arrayBufferViewMethodRaisesExceptionMethod(info);
+}
+
void V8TestObject::float32ArrayMethodMethodCallback(const v8::FunctionCallbackInfo<v8::Value>& info) {
TestObjectV8Internal::float32ArrayMethodMethod(info);
}
@@ -12010,6 +12051,7 @@ static const V8DOMConfiguration::MethodConfiguration V8TestObjectMethods[] = {
{"voidMethodNodeArg", V8TestObject::voidMethodNodeArgMethodCallback, 1, v8::None, V8DOMConfiguration::kOnPrototype, V8DOMConfiguration::kCheckHolder, V8DOMConfiguration::kDoNotCheckAccess, V8DOMConfiguration::kAllWorlds},
{"arrayBufferMethod", V8TestObject::arrayBufferMethodMethodCallback, 0, v8::None, V8DOMConfiguration::kOnPrototype, V8DOMConfiguration::kCheckHolder, V8DOMConfiguration::kDoNotCheckAccess, V8DOMConfiguration::kAllWorlds},
{"arrayBufferViewMethod", V8TestObject::arrayBufferViewMethodMethodCallback, 0, v8::None, V8DOMConfiguration::kOnPrototype, V8DOMConfiguration::kCheckHolder, V8DOMConfiguration::kDoNotCheckAccess, V8DOMConfiguration::kAllWorlds},
+ {"arrayBufferViewMethodRaisesException", V8TestObject::arrayBufferViewMethodRaisesExceptionMethodCallback, 0, v8::None, V8DOMConfiguration::kOnPrototype, V8DOMConfiguration::kCheckHolder, V8DOMConfiguration::kDoNotCheckAccess, V8DOMConfiguration::kAllWorlds},
{"float32ArrayMethod", V8TestObject::float32ArrayMethodMethodCallback, 0, v8::None, V8DOMConfiguration::kOnPrototype, V8DOMConfiguration::kCheckHolder, V8DOMConfiguration::kDoNotCheckAccess, V8DOMConfiguration::kAllWorlds},
{"int32ArrayMethod", V8TestObject::int32ArrayMethodMethodCallback, 0, v8::None, V8DOMConfiguration::kOnPrototype, V8DOMConfiguration::kCheckHolder, V8DOMConfiguration::kDoNotCheckAccess, V8DOMConfiguration::kAllWorlds},
{"uint8ArrayMethod", V8TestObject::uint8ArrayMethodMethodCallback, 0, v8::None, V8DOMConfiguration::kOnPrototype, V8DOMConfiguration::kCheckHolder, V8DOMConfiguration::kDoNotCheckAccess, V8DOMConfiguration::kAllWorlds},

Powered by Google App Engine
This is Rietveld 408576698