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

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

Issue 807263007: IDL: Add forEach() method to iterable<>/maplike<>/setlike<> interfaces (Closed) Base URL: https://chromium.googlesource.com/chromium/blink.git@master
Patch Set: adjust test expectations Created 5 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: Source/bindings/tests/results/core/V8TestObject.cpp
diff --git a/Source/bindings/tests/results/core/V8TestObject.cpp b/Source/bindings/tests/results/core/V8TestObject.cpp
index 8fc444b145680d7c25f829d7a3886338f52483f3..7551698b97d052acf3ebcca47bfb3ac5a4498a89 100644
--- a/Source/bindings/tests/results/core/V8TestObject.cpp
+++ b/Source/bindings/tests/results/core/V8TestObject.cpp
@@ -10785,6 +10785,41 @@ static void entriesMethodCallback(const v8::FunctionCallbackInfo<v8::Value>& inf
TRACE_EVENT_SET_SAMPLING_STATE("v8", "V8Execution");
}
+static void forEachMethod(const v8::FunctionCallbackInfo<v8::Value>& info)
+{
+ ExceptionState exceptionState(ExceptionState::ExecutionContext, "forEach", "TestObject", info.Holder(), info.GetIsolate());
+ if (UNLIKELY(info.Length() < 1)) {
+ setMinimumArityTypeError(exceptionState, 1, info.Length());
+ exceptionState.throwIfNeeded();
+ return;
+ }
+ TestObject* impl = V8TestObject::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");
+ TestObjectV8Internal::forEachMethod(info);
+ TRACE_EVENT_SET_SAMPLING_STATE("v8", "V8Execution");
+}
+
static void toStringMethod(const v8::FunctionCallbackInfo<v8::Value>& info)
{
TestObject* impl = V8TestObject::toImpl(info.Holder());
@@ -11216,6 +11251,7 @@ static const V8DOMConfiguration::MethodConfiguration V8TestObjectMethods[] = {
{"keys", TestObjectV8Internal::keysMethodCallback, 0, 0, V8DOMConfiguration::ExposedToAllScripts},
{"values", TestObjectV8Internal::valuesMethodCallback, 0, 0, V8DOMConfiguration::ExposedToAllScripts},
{"entries", TestObjectV8Internal::entriesMethodCallback, 0, 0, V8DOMConfiguration::ExposedToAllScripts},
+ {"forEach", TestObjectV8Internal::forEachMethodCallback, 0, 1, V8DOMConfiguration::ExposedToAllScripts},
{"toString", TestObjectV8Internal::toStringMethodCallback, 0, 0, V8DOMConfiguration::ExposedToAllScripts},
};
« no previous file with comments | « Source/bindings/tests/results/core/V8TestInterface3.cpp ('k') | Source/bindings/tests/results/modules/V8TestInterface5.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698