Chromium Code Reviews| Index: Source/bindings/tests/results/core/V8TestInterfaceGarbageCollected.cpp |
| diff --git a/Source/bindings/tests/results/core/V8TestInterfaceGarbageCollected.cpp b/Source/bindings/tests/results/core/V8TestInterfaceGarbageCollected.cpp |
| index 7ee9e0ad26845e035cbdf718a8e6d29ef48d098f..07c4ee2bf6518064a0a3361c301b7382e68b2635 100644 |
| --- a/Source/bindings/tests/results/core/V8TestInterfaceGarbageCollected.cpp |
| +++ b/Source/bindings/tests/results/core/V8TestInterfaceGarbageCollected.cpp |
| @@ -8,8 +8,11 @@ |
| #include "V8TestInterfaceGarbageCollected.h" |
| #include "bindings/core/v8/ExceptionState.h" |
| +#include "bindings/core/v8/ScriptState.h" |
| +#include "bindings/core/v8/ScriptValue.h" |
| #include "bindings/core/v8/V8DOMConfiguration.h" |
| #include "bindings/core/v8/V8HiddenValue.h" |
| +#include "bindings/core/v8/V8Iterator.h" |
| #include "bindings/core/v8/V8ObjectConstructor.h" |
| #include "bindings/core/v8/V8TestInterfaceGarbageCollected.h" |
| #include "core/dom/ContextFeatures.h" |
| @@ -81,6 +84,227 @@ static void funcMethodCallback(const v8::FunctionCallbackInfo<v8::Value>& info) |
| TRACE_EVENT_SET_SAMPLING_STATE("v8", "V8Execution"); |
| } |
| +static void keysMethod(const v8::FunctionCallbackInfo<v8::Value>& info) |
| +{ |
| + ExceptionState exceptionState(ExceptionState::ExecutionContext, "keys", "TestInterfaceGarbageCollected", info.Holder(), info.GetIsolate()); |
| + TestInterfaceGarbageCollected* impl = V8TestInterfaceGarbageCollected::toImpl(info.Holder()); |
| + ScriptState* scriptState = ScriptState::current(info.GetIsolate()); |
| + RawPtr<Iterator> result = impl->keys(scriptState, exceptionState); |
| + if (exceptionState.hadException()) { |
| + exceptionState.throwIfNeeded(); |
| + return; |
| + } |
| + v8SetReturnValue(info, result.release()); |
| +} |
| + |
| +static void keysMethodCallback(const v8::FunctionCallbackInfo<v8::Value>& info) |
| +{ |
| + TRACE_EVENT_SET_SAMPLING_STATE("blink", "DOMMethod"); |
| + TestInterfaceGarbageCollectedV8Internal::keysMethod(info); |
| + TRACE_EVENT_SET_SAMPLING_STATE("v8", "V8Execution"); |
| +} |
| + |
| +static void valuesMethod(const v8::FunctionCallbackInfo<v8::Value>& info) |
| +{ |
| + ExceptionState exceptionState(ExceptionState::ExecutionContext, "values", "TestInterfaceGarbageCollected", info.Holder(), info.GetIsolate()); |
| + TestInterfaceGarbageCollected* impl = V8TestInterfaceGarbageCollected::toImpl(info.Holder()); |
| + ScriptState* scriptState = ScriptState::current(info.GetIsolate()); |
| + RawPtr<Iterator> result = impl->values(scriptState, exceptionState); |
| + if (exceptionState.hadException()) { |
| + exceptionState.throwIfNeeded(); |
| + return; |
| + } |
| + v8SetReturnValue(info, result.release()); |
| +} |
| + |
| +static void valuesMethodCallback(const v8::FunctionCallbackInfo<v8::Value>& info) |
| +{ |
| + TRACE_EVENT_SET_SAMPLING_STATE("blink", "DOMMethod"); |
| + TestInterfaceGarbageCollectedV8Internal::valuesMethod(info); |
| + TRACE_EVENT_SET_SAMPLING_STATE("v8", "V8Execution"); |
| +} |
| + |
| +static void entriesMethod(const v8::FunctionCallbackInfo<v8::Value>& info) |
| +{ |
| + ExceptionState exceptionState(ExceptionState::ExecutionContext, "entries", "TestInterfaceGarbageCollected", info.Holder(), info.GetIsolate()); |
| + TestInterfaceGarbageCollected* impl = V8TestInterfaceGarbageCollected::toImpl(info.Holder()); |
| + ScriptState* scriptState = ScriptState::current(info.GetIsolate()); |
| + RawPtr<Iterator> result = impl->entries(scriptState, exceptionState); |
| + if (exceptionState.hadException()) { |
| + exceptionState.throwIfNeeded(); |
| + return; |
| + } |
| + v8SetReturnValue(info, result.release()); |
| +} |
| + |
| +static void entriesMethodCallback(const v8::FunctionCallbackInfo<v8::Value>& info) |
| +{ |
| + TRACE_EVENT_SET_SAMPLING_STATE("blink", "DOMMethod"); |
| + TestInterfaceGarbageCollectedV8Internal::entriesMethod(info); |
| + TRACE_EVENT_SET_SAMPLING_STATE("v8", "V8Execution"); |
| +} |
| + |
| +static void forEachMethod(const v8::FunctionCallbackInfo<v8::Value>& info) |
| +{ |
| + ExceptionState exceptionState(ExceptionState::ExecutionContext, "forEach", "TestInterfaceGarbageCollected", info.Holder(), info.GetIsolate()); |
| + if (UNLIKELY(info.Length() < 1)) { |
| + setMinimumArityTypeError(exceptionState, 1, info.Length()); |
| + exceptionState.throwIfNeeded(); |
| + return; |
| + } |
| + TestInterfaceGarbageCollected* impl = V8TestInterfaceGarbageCollected::toImpl(info.Holder()); |
| + ScriptValue callback; |
| + ScriptValue thisArg; |
| + { |
| + if (!info[0]->IsFunction()) { |
| + exceptionState.throwTypeError("The callback provided as parameter 1 is not a function."); |
| + exceptionState.throwIfNeeded(); |
| + return; |
| + } |
| + callback = ScriptValue(ScriptState::current(info.GetIsolate()), info[0]); |
| + thisArg = ScriptValue(ScriptState::current(info.GetIsolate()), info[1]); |
| + } |
| + ScriptState* scriptState = ScriptState::current(info.GetIsolate()); |
| + impl->forEach(scriptState, ScriptValue(scriptState, info.This()), callback, thisArg, exceptionState); |
| + if (exceptionState.hadException()) { |
| + exceptionState.throwIfNeeded(); |
| + return; |
| + } |
| +} |
| + |
| +static void forEachMethodCallback(const v8::FunctionCallbackInfo<v8::Value>& info) |
| +{ |
| + TRACE_EVENT_SET_SAMPLING_STATE("blink", "DOMMethod"); |
| + TestInterfaceGarbageCollectedV8Internal::forEachMethod(info); |
| + TRACE_EVENT_SET_SAMPLING_STATE("v8", "V8Execution"); |
| +} |
| + |
| +static void hasMethod(const v8::FunctionCallbackInfo<v8::Value>& info) |
| +{ |
| + ExceptionState exceptionState(ExceptionState::ExecutionContext, "has", "TestInterfaceGarbageCollected", info.Holder(), info.GetIsolate()); |
| + if (UNLIKELY(info.Length() < 1)) { |
| + setMinimumArityTypeError(exceptionState, 1, info.Length()); |
| + exceptionState.throwIfNeeded(); |
| + return; |
| + } |
| + TestInterfaceGarbageCollected* impl = V8TestInterfaceGarbageCollected::toImpl(info.Holder()); |
| + V8StringResource<> value; |
| + { |
| + TOSTRING_VOID_INTERNAL(value, info[0]); |
| + } |
| + ScriptState* scriptState = ScriptState::current(info.GetIsolate()); |
| + bool result = impl->has(scriptState, value, exceptionState); |
| + if (exceptionState.hadException()) { |
| + exceptionState.throwIfNeeded(); |
| + return; |
| + } |
| + v8SetReturnValueBool(info, result); |
| +} |
| + |
| +static void hasMethodCallback(const v8::FunctionCallbackInfo<v8::Value>& info) |
| +{ |
| + TRACE_EVENT_SET_SAMPLING_STATE("blink", "DOMMethod"); |
| + TestInterfaceGarbageCollectedV8Internal::hasMethod(info); |
| + TRACE_EVENT_SET_SAMPLING_STATE("v8", "V8Execution"); |
| +} |
| + |
| +static void addMethod(const v8::FunctionCallbackInfo<v8::Value>& info) |
| +{ |
| + ExceptionState exceptionState(ExceptionState::ExecutionContext, "add", "TestInterfaceGarbageCollected", info.Holder(), info.GetIsolate()); |
| + if (UNLIKELY(info.Length() < 1)) { |
| + setMinimumArityTypeError(exceptionState, 1, info.Length()); |
| + exceptionState.throwIfNeeded(); |
| + return; |
| + } |
| + TestInterfaceGarbageCollected* impl = V8TestInterfaceGarbageCollected::toImpl(info.Holder()); |
| + V8StringResource<> value; |
| + { |
| + TOSTRING_VOID_INTERNAL(value, info[0]); |
| + } |
| + ScriptState* scriptState = ScriptState::current(info.GetIsolate()); |
| + RawPtr<TestInterfaceGarbageCollected> result = impl->add(scriptState, value, exceptionState); |
|
Jens Widell
2015/02/09 12:29:19
A somewhat appealing alternative would be to imple
haraken
2015/02/09 13:53:11
Good point, shall we file a bug against the spec?
Jens Widell
2015/02/09 15:03:05
Yes, I will look into it. Last time I looked at th
|
| + if (exceptionState.hadException()) { |
| + exceptionState.throwIfNeeded(); |
| + return; |
| + } |
| + v8SetReturnValue(info, result.release()); |
| +} |
| + |
| +static void addMethodCallback(const v8::FunctionCallbackInfo<v8::Value>& info) |
| +{ |
| + TRACE_EVENT_SET_SAMPLING_STATE("blink", "DOMMethod"); |
| + TestInterfaceGarbageCollectedV8Internal::addMethod(info); |
| + TRACE_EVENT_SET_SAMPLING_STATE("v8", "V8Execution"); |
| +} |
| + |
| +static void clearMethod(const v8::FunctionCallbackInfo<v8::Value>& info) |
| +{ |
| + ExceptionState exceptionState(ExceptionState::ExecutionContext, "clear", "TestInterfaceGarbageCollected", info.Holder(), info.GetIsolate()); |
| + TestInterfaceGarbageCollected* impl = V8TestInterfaceGarbageCollected::toImpl(info.Holder()); |
| + ScriptState* scriptState = ScriptState::current(info.GetIsolate()); |
| + impl->clear(scriptState, exceptionState); |
| + if (exceptionState.hadException()) { |
| + exceptionState.throwIfNeeded(); |
| + return; |
| + } |
| +} |
| + |
| +static void clearMethodCallback(const v8::FunctionCallbackInfo<v8::Value>& info) |
| +{ |
| + TRACE_EVENT_SET_SAMPLING_STATE("blink", "DOMMethod"); |
| + TestInterfaceGarbageCollectedV8Internal::clearMethod(info); |
| + TRACE_EVENT_SET_SAMPLING_STATE("v8", "V8Execution"); |
| +} |
| + |
| +static void deleteMethod(const v8::FunctionCallbackInfo<v8::Value>& info) |
| +{ |
| + ExceptionState exceptionState(ExceptionState::ExecutionContext, "delete", "TestInterfaceGarbageCollected", info.Holder(), info.GetIsolate()); |
| + if (UNLIKELY(info.Length() < 1)) { |
| + setMinimumArityTypeError(exceptionState, 1, info.Length()); |
| + exceptionState.throwIfNeeded(); |
| + return; |
| + } |
| + TestInterfaceGarbageCollected* impl = V8TestInterfaceGarbageCollected::toImpl(info.Holder()); |
| + V8StringResource<> value; |
| + { |
| + TOSTRING_VOID_INTERNAL(value, info[0]); |
| + } |
| + ScriptState* scriptState = ScriptState::current(info.GetIsolate()); |
| + bool result = impl->delete(scriptState, value, exceptionState); |
|
Jens Widell
2015/02/09 15:03:05
It occurs to me that "delete" is not a good functi
haraken
2015/02/09 15:53:53
We normally use deleteForBinding or deleteFunction
Jens Widell
2015/02/09 15:56:48
Changed to "deleteForBinding".
|
| + if (exceptionState.hadException()) { |
| + exceptionState.throwIfNeeded(); |
| + return; |
| + } |
| + v8SetReturnValueBool(info, result); |
| +} |
| + |
| +static void deleteMethodCallback(const v8::FunctionCallbackInfo<v8::Value>& info) |
| +{ |
| + TRACE_EVENT_SET_SAMPLING_STATE("blink", "DOMMethod"); |
| + TestInterfaceGarbageCollectedV8Internal::deleteMethod(info); |
| + TRACE_EVENT_SET_SAMPLING_STATE("v8", "V8Execution"); |
| +} |
| + |
| +static void iteratorMethod(const v8::FunctionCallbackInfo<v8::Value>& info) |
| +{ |
| + ExceptionState exceptionState(ExceptionState::ExecutionContext, "iterator", "TestInterfaceGarbageCollected", info.Holder(), info.GetIsolate()); |
| + TestInterfaceGarbageCollected* impl = V8TestInterfaceGarbageCollected::toImpl(info.Holder()); |
| + ScriptState* scriptState = ScriptState::current(info.GetIsolate()); |
| + RawPtr<Iterator> result = impl->iterator(scriptState, exceptionState); |
| + if (exceptionState.hadException()) { |
| + exceptionState.throwIfNeeded(); |
| + return; |
| + } |
| + v8SetReturnValue(info, result.release()); |
| +} |
| + |
| +static void iteratorMethodCallback(const v8::FunctionCallbackInfo<v8::Value>& info) |
| +{ |
| + TRACE_EVENT_SET_SAMPLING_STATE("blink", "DOMMethod"); |
| + TestInterfaceGarbageCollectedV8Internal::iteratorMethod(info); |
| + TRACE_EVENT_SET_SAMPLING_STATE("v8", "V8Execution"); |
| +} |
| + |
| static void constructor(const v8::FunctionCallbackInfo<v8::Value>& info) |
| { |
| if (UNLIKELY(info.Length() < 1)) { |
| @@ -105,6 +329,14 @@ static const V8DOMConfiguration::AttributeConfiguration V8TestInterfaceGarbageCo |
| static const V8DOMConfiguration::MethodConfiguration V8TestInterfaceGarbageCollectedMethods[] = { |
| {"func", TestInterfaceGarbageCollectedV8Internal::funcMethodCallback, 0, 1, V8DOMConfiguration::ExposedToAllScripts}, |
| + {"keys", TestInterfaceGarbageCollectedV8Internal::keysMethodCallback, 0, 0, V8DOMConfiguration::ExposedToAllScripts}, |
| + {"values", TestInterfaceGarbageCollectedV8Internal::valuesMethodCallback, 0, 0, V8DOMConfiguration::ExposedToAllScripts}, |
| + {"entries", TestInterfaceGarbageCollectedV8Internal::entriesMethodCallback, 0, 0, V8DOMConfiguration::ExposedToAllScripts}, |
| + {"forEach", TestInterfaceGarbageCollectedV8Internal::forEachMethodCallback, 0, 1, V8DOMConfiguration::ExposedToAllScripts}, |
| + {"has", TestInterfaceGarbageCollectedV8Internal::hasMethodCallback, 0, 1, V8DOMConfiguration::ExposedToAllScripts}, |
| + {"add", TestInterfaceGarbageCollectedV8Internal::addMethodCallback, 0, 1, V8DOMConfiguration::ExposedToAllScripts}, |
| + {"clear", TestInterfaceGarbageCollectedV8Internal::clearMethodCallback, 0, 0, V8DOMConfiguration::ExposedToAllScripts}, |
| + {"delete", TestInterfaceGarbageCollectedV8Internal::deleteMethodCallback, 0, 1, V8DOMConfiguration::ExposedToAllScripts}, |
| }; |
| void V8TestInterfaceGarbageCollected::constructorCallback(const v8::FunctionCallbackInfo<v8::Value>& info) |
| @@ -138,6 +370,8 @@ static void installV8TestInterfaceGarbageCollectedTemplate(v8::Local<v8::Functio |
| ALLOW_UNUSED_LOCAL(instanceTemplate); |
| v8::Local<v8::ObjectTemplate> prototypeTemplate = functionTemplate->PrototypeTemplate(); |
| ALLOW_UNUSED_LOCAL(prototypeTemplate); |
| + static const V8DOMConfiguration::SymbolKeyedMethodConfiguration symbolKeyedIteratorConfiguration = { v8::Symbol::GetIterator, TestInterfaceGarbageCollectedV8Internal::iteratorMethodCallback, 0, V8DOMConfiguration::ExposedToAllScripts }; |
| + V8DOMConfiguration::installMethod(prototypeTemplate, defaultSignature, v8::DontDelete, symbolKeyedIteratorConfiguration, isolate); |
| // Custom toString template |
| functionTemplate->Set(v8AtomicString(isolate, "toString"), V8PerIsolateData::from(isolate)->toStringTemplate()); |