Diff
Modified: trunk/LayoutTests/ChangeLog (202333 => 202334)
--- trunk/LayoutTests/ChangeLog 2016-06-22 17:16:27 UTC (rev 202333)
+++ trunk/LayoutTests/ChangeLog 2016-06-22 17:50:15 UTC (rev 202334)
@@ -1,3 +1,13 @@
+2016-06-22 Youenn Fablet <[email protected]>
+
+ JSDOMIterator forEach should support second optional parameter
+ https://bugs.webkit.org/show_bug.cgi?id=159020
+
+ Reviewed by Chris Dumez.
+
+ * fast/dom/nodeListIterator-expected.txt:
+ * fast/dom/nodeListIterator.html: Adding 'thisValue' various checks.
+
2016-06-22 Per Arne Vollan <[email protected]>
window.showModalDialog doesn't work in DumpRenderTree on Windows
Modified: trunk/LayoutTests/fast/dom/nodeListIterator-expected.txt (202333 => 202334)
--- trunk/LayoutTests/fast/dom/nodeListIterator-expected.txt 2016-06-22 17:16:27 UTC (rev 202333)
+++ trunk/LayoutTests/fast/dom/nodeListIterator-expected.txt 2016-06-22 17:50:15 UTC (rev 202334)
@@ -11,9 +11,15 @@
PASS forEachContainer is nodeList
PASS forEachIndex is index
PASS node is children[index++]
+PASS thisValue is window
PASS forEachContainer is nodeList
PASS forEachIndex is index
PASS node is children[index++]
+PASS thisValue is window
+PASS thisValue is window
+PASS thisValue is window
+PASS thisValue is givenThisValue
+PASS thisValue is givenThisValue
PASS iterator.next().value is children[0]
PASS iterator.next().value is children[1]
PASS end.done is true
Modified: trunk/LayoutTests/fast/dom/nodeListIterator.html (202333 => 202334)
--- trunk/LayoutTests/fast/dom/nodeListIterator.html 2016-06-22 17:16:27 UTC (rev 202333)
+++ trunk/LayoutTests/fast/dom/nodeListIterator.html 2016-06-22 17:50:15 UTC (rev 202334)
@@ -39,15 +39,29 @@
var node;
var forEachIndex;
var forEachContainer;
+ var thisValue;
nodeList.forEach(function(n, i, c) {
node = n;
forEachIndex = i;
forEachContainer = c;
+ thisValue = this;
shouldBe('forEachContainer', 'nodeList');
shouldBe('forEachIndex', 'index');
shouldBe('node', 'children[index++]');
+ shouldBe('thisValue', 'window');
});
-
+
+ nodeList.forEach(function() {
+ thisValue = this;
+ shouldBe('thisValue', 'window');
+ }, undefined);
+
+ var givenThisValue = nodeList;
+ nodeList.forEach(function() {
+ thisValue = this;
+ shouldBe('thisValue', 'givenThisValue');
+ }, givenThisValue);
+
var iterator = nodeList.keys();
shouldBe('iterator.next().value', 'children[0]');
shouldBe('iterator.next().value', 'children[1]');
Modified: trunk/Source/WebCore/ChangeLog (202333 => 202334)
--- trunk/Source/WebCore/ChangeLog 2016-06-22 17:16:27 UTC (rev 202333)
+++ trunk/Source/WebCore/ChangeLog 2016-06-22 17:50:15 UTC (rev 202334)
@@ -1,3 +1,15 @@
+2016-06-22 Youenn Fablet <[email protected]>
+
+ JSDOMIterator forEach should support second optional parameter
+ https://bugs.webkit.org/show_bug.cgi?id=159020
+
+ Reviewed by Chris Dumez.
+
+ Covered by beefed up test.
+
+ * bindings/js/JSDOMIterator.h:
+ (WebCore::iteratorForEach): Setting callback thisValue to the second argument passed to forEach.
+
2016-06-22 Jer Noble <[email protected]>
Media controls stop working after exiting PiP
Modified: trunk/Source/WebCore/bindings/js/JSDOMIterator.h (202333 => 202334)
--- trunk/Source/WebCore/bindings/js/JSDOMIterator.h 2016-06-22 17:16:27 UTC (rev 202333)
+++ trunk/Source/WebCore/bindings/js/JSDOMIterator.h 2016-06-22 17:50:15 UTC (rev 202334)
@@ -182,8 +182,11 @@
if (UNLIKELY(!wrapper))
return throwThisTypeError(state, JSWrapper::info()->className, propertyName);
+ JSC::JSValue callback = state.argument(0);
+ JSC::JSValue thisValue = state.argument(1);
+
JSC::CallData callData;
- JSC::CallType callType = JSC::getCallData(state.argument(0), callData);
+ JSC::CallType callType = JSC::getCallData(callback, callData);
if (callType == JSC::CallType::None)
return throwVMTypeError(&state);
@@ -193,10 +196,10 @@
JSC::MarkedArgumentBuffer arguments;
appendForEachArguments(state, wrapper->globalObject(), arguments, value, index);
arguments.append(wrapper);
- JSC::call(&state, state.argument(0), callType, callData, wrapper, arguments);
+ JSC::call(&state, callback, callType, callData, thisValue, arguments);
if (state.hadException())
break;
- }
+ }
return JSC::JSValue::encode(JSC::jsUndefined());
}