<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1//EN"
"http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head><meta http-equiv="content-type" content="text/html; charset=utf-8" />
<title>[198889] trunk</title>
</head>
<body>

<style type="text/css"><!--
#msg dl.meta { border: 1px #006 solid; background: #369; padding: 6px; color: #fff; }
#msg dl.meta dt { float: left; width: 6em; font-weight: bold; }
#msg dt:after { content:':';}
#msg dl, #msg dt, #msg ul, #msg li, #header, #footer, #logmsg { font-family: verdana,arial,helvetica,sans-serif; font-size: 10pt;  }
#msg dl a { font-weight: bold}
#msg dl a:link    { color:#fc3; }
#msg dl a:active  { color:#ff0; }
#msg dl a:visited { color:#cc6; }
h3 { font-family: verdana,arial,helvetica,sans-serif; font-size: 10pt; font-weight: bold; }
#msg pre { overflow: auto; background: #ffc; border: 1px #fa0 solid; padding: 6px; }
#logmsg { background: #ffc; border: 1px #fa0 solid; padding: 1em 1em 0 1em; }
#logmsg p, #logmsg pre, #logmsg blockquote { margin: 0 0 1em 0; }
#logmsg p, #logmsg li, #logmsg dt, #logmsg dd { line-height: 14pt; }
#logmsg h1, #logmsg h2, #logmsg h3, #logmsg h4, #logmsg h5, #logmsg h6 { margin: .5em 0; }
#logmsg h1:first-child, #logmsg h2:first-child, #logmsg h3:first-child, #logmsg h4:first-child, #logmsg h5:first-child, #logmsg h6:first-child { margin-top: 0; }
#logmsg ul, #logmsg ol { padding: 0; list-style-position: inside; margin: 0 0 0 1em; }
#logmsg ul { text-indent: -1em; padding-left: 1em; }#logmsg ol { text-indent: -1.5em; padding-left: 1.5em; }
#logmsg > ul, #logmsg > ol { margin: 0 0 1em 0; }
#logmsg pre { background: #eee; padding: 1em; }
#logmsg blockquote { border: 1px solid #fa0; border-left-width: 10px; padding: 1em 1em 0 1em; background: white;}
#logmsg dl { margin: 0; }
#logmsg dt { font-weight: bold; }
#logmsg dd { margin: 0; padding: 0 0 0.5em 0; }
#logmsg dd:before { content:'\00bb';}
#logmsg table { border-spacing: 0px; border-collapse: collapse; border-top: 4px solid #fa0; border-bottom: 1px solid #fa0; background: #fff; }
#logmsg table th { text-align: left; font-weight: normal; padding: 0.2em 0.5em; border-top: 1px dotted #fa0; }
#logmsg table td { text-align: right; border-top: 1px dotted #fa0; padding: 0.2em 0.5em; }
#logmsg table thead th { text-align: center; border-bottom: 1px solid #fa0; }
#logmsg table th.Corner { text-align: left; }
#logmsg hr { border: none 0; border-top: 2px dashed #fa0; height: 1px; }
#header, #footer { color: #fff; background: #636; border: 1px #300 solid; padding: 6px; }
#patch { width: 100%; }
#patch h4 {font-family: verdana,arial,helvetica,sans-serif;font-size:10pt;padding:8px;background:#369;color:#fff;margin:0;}
#patch .propset h4, #patch .binary h4 {margin:0;}
#patch pre {padding:0;line-height:1.2em;margin:0;}
#patch .diff {width:100%;background:#eee;padding: 0 0 10px 0;overflow:auto;}
#patch .propset .diff, #patch .binary .diff  {padding:10px 0;}
#patch span {display:block;padding:0 10px;}
#patch .modfile, #patch .addfile, #patch .delfile, #patch .propset, #patch .binary, #patch .copfile {border:1px solid #ccc;margin:10px 0;}
#patch ins {background:#dfd;text-decoration:none;display:block;padding:0 10px;}
#patch del {background:#fdd;text-decoration:none;display:block;padding:0 10px;}
#patch .lines, .info {color:#888;background:#fff;}
--></style>
<div id="msg">
<dl class="meta">
<dt>Revision</dt> <dd><a href="http://trac.webkit.org/projects/webkit/changeset/198889">198889</a></dd>
<dt>Author</dt> <dd>youenn.fablet@crf.canon.fr</dd>
<dt>Date</dt> <dd>2016-03-31 01:31:25 -0700 (Thu, 31 Mar 2016)</dd>
</dl>

<h3>Log Message</h3>
<pre>Remove forEach use from Fetch Headers builtin constructor
https://bugs.webkit.org/show_bug.cgi?id=155967

Reviewed by Joseph Pecoraro.

Source/WebCore:

Tests: fetch/shadowing-forEach.html
       streams/shadowing-Promise.html
       streams/shadowing-defineProperty.html

* Modules/fetch/FetchHeaders.idl: Adding fillFromJS private method.
* Modules/fetch/FetchHeaders.js:
(initializeFetchHeaders): Using fillFromJS private method. Using
instanceof test to check whether parameter is Headers or subclass of it.
* bindings/js/WebCoreBuiltinNames.h: Adding fillFromJS private symbol.

LayoutTests:

Renaming tests covering user scripts breaking some WebCore JS built ins.

* fetch/header-constructor-subclass-expected.txt: Added.
* fetch/header-constructor-subclass.html: Added.
* fetch/shadowing-forEach-expected.txt: Renamed from LayoutTests/streams/builtin-overrides-expected.txt.
* fetch/shadowing-forEach.html: Renamed from LayoutTests/fetch/builtin-overrides.html.
* streams/shadowing-Promise-expected.txt: Renamed from LayoutTests/streams/streams-promises-expected.txt.
* streams/shadowing-Promise.html: Renamed from LayoutTests/streams/streams-promises.html.
* streams/shadowing-defineProperty-expected.txt: Renamed from LayoutTests/fetch/builtin-overrides-expected.txt.
* streams/shadowing-defineProperty.html: Renamed from LayoutTests/streams/builtin-overrides.html.</pre>

<h3>Modified Paths</h3>
<ul>
<li><a href="#trunkLayoutTestsChangeLog">trunk/LayoutTests/ChangeLog</a></li>
<li><a href="#trunkSourceWebCoreChangeLog">trunk/Source/WebCore/ChangeLog</a></li>
<li><a href="#trunkSourceWebCoreModulesfetchFetchHeadersidl">trunk/Source/WebCore/Modules/fetch/FetchHeaders.idl</a></li>
<li><a href="#trunkSourceWebCoreModulesfetchFetchHeadersjs">trunk/Source/WebCore/Modules/fetch/FetchHeaders.js</a></li>
<li><a href="#trunkSourceWebCorebindingsjsWebCoreBuiltinNamesh">trunk/Source/WebCore/bindings/js/WebCoreBuiltinNames.h</a></li>
</ul>

<h3>Added Paths</h3>
<ul>
<li><a href="#trunkLayoutTestsfetchheaderconstructorsubclassexpectedtxt">trunk/LayoutTests/fetch/header-constructor-subclass-expected.txt</a></li>
<li><a href="#trunkLayoutTestsfetchheaderconstructorsubclasshtml">trunk/LayoutTests/fetch/header-constructor-subclass.html</a></li>
<li><a href="#trunkLayoutTestsfetchshadowingforEachexpectedtxt">trunk/LayoutTests/fetch/shadowing-forEach-expected.txt</a></li>
<li><a href="#trunkLayoutTestsfetchshadowingforEachhtml">trunk/LayoutTests/fetch/shadowing-forEach.html</a></li>
<li><a href="#trunkLayoutTestsstreamsshadowingPromiseexpectedtxt">trunk/LayoutTests/streams/shadowing-Promise-expected.txt</a></li>
<li><a href="#trunkLayoutTestsstreamsshadowingPromisehtml">trunk/LayoutTests/streams/shadowing-Promise.html</a></li>
<li><a href="#trunkLayoutTestsstreamsshadowingdefinePropertyexpectedtxt">trunk/LayoutTests/streams/shadowing-defineProperty-expected.txt</a></li>
<li><a href="#trunkLayoutTestsstreamsshadowingdefinePropertyhtml">trunk/LayoutTests/streams/shadowing-defineProperty.html</a></li>
</ul>

<h3>Removed Paths</h3>
<ul>
<li><a href="#trunkLayoutTestsfetchbuiltinoverridesexpectedtxt">trunk/LayoutTests/fetch/builtin-overrides-expected.txt</a></li>
<li><a href="#trunkLayoutTestsfetchbuiltinoverrideshtml">trunk/LayoutTests/fetch/builtin-overrides.html</a></li>
<li><a href="#trunkLayoutTestsstreamsbuiltinoverridesexpectedtxt">trunk/LayoutTests/streams/builtin-overrides-expected.txt</a></li>
<li><a href="#trunkLayoutTestsstreamsbuiltinoverrideshtml">trunk/LayoutTests/streams/builtin-overrides.html</a></li>
<li><a href="#trunkLayoutTestsstreamsstreamspromisesexpectedtxt">trunk/LayoutTests/streams/streams-promises-expected.txt</a></li>
<li><a href="#trunkLayoutTestsstreamsstreamspromiseshtml">trunk/LayoutTests/streams/streams-promises.html</a></li>
</ul>

</div>
<div id="patch">
<h3>Diff</h3>
<a id="trunkLayoutTestsChangeLog"></a>
<div class="modfile"><h4>Modified: trunk/LayoutTests/ChangeLog (198888 => 198889)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/LayoutTests/ChangeLog        2016-03-31 08:26:29 UTC (rev 198888)
+++ trunk/LayoutTests/ChangeLog        2016-03-31 08:31:25 UTC (rev 198889)
</span><span class="lines">@@ -1,5 +1,23 @@
</span><span class="cx"> 2016-03-31  Youenn Fablet  &lt;youenn.fablet@crf.canon.fr&gt;
</span><span class="cx"> 
</span><ins>+        Remove forEach use from Fetch Headers builtin constructor
+        https://bugs.webkit.org/show_bug.cgi?id=155967
+
+        Reviewed by Joseph Pecoraro.
+
+        Renaming tests covering user scripts breaking some WebCore JS built ins.
+
+        * fetch/header-constructor-subclass-expected.txt: Added.
+        * fetch/header-constructor-subclass.html: Added.
+        * fetch/shadowing-forEach-expected.txt: Renamed from LayoutTests/streams/builtin-overrides-expected.txt.
+        * fetch/shadowing-forEach.html: Renamed from LayoutTests/fetch/builtin-overrides.html.
+        * streams/shadowing-Promise-expected.txt: Renamed from LayoutTests/streams/streams-promises-expected.txt.
+        * streams/shadowing-Promise.html: Renamed from LayoutTests/streams/streams-promises.html.
+        * streams/shadowing-defineProperty-expected.txt: Renamed from LayoutTests/fetch/builtin-overrides-expected.txt.
+        * streams/shadowing-defineProperty.html: Renamed from LayoutTests/streams/builtin-overrides.html.
+
+2016-03-31  Youenn Fablet  &lt;youenn.fablet@crf.canon.fr&gt;
+
</ins><span class="cx">         [Fetch API] Update web-platform-test fetch API tests
</span><span class="cx">         https://bugs.webkit.org/show_bug.cgi?id=155969
</span><span class="cx"> 
</span></span></pre></div>
<a id="trunkLayoutTestsfetchbuiltinoverridesexpectedtxt"></a>
<div class="delfile"><h4>Deleted: trunk/LayoutTests/fetch/builtin-overrides-expected.txt (198888 => 198889)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/LayoutTests/fetch/builtin-overrides-expected.txt        2016-03-31 08:26:29 UTC (rev 198888)
+++ trunk/LayoutTests/fetch/builtin-overrides-expected.txt        2016-03-31 08:31:25 UTC (rev 198889)
</span><span class="lines">@@ -1,9 +0,0 @@
</span><del>-This test should run without throwing an exception.
-
-On success, you will see a series of &quot;PASS&quot; messages, followed by &quot;TEST COMPLETE&quot;.
-
-
-PASS successfullyParsed is true
-
-TEST COMPLETE
-
</del></span></pre></div>
<a id="trunkLayoutTestsfetchbuiltinoverrideshtml"></a>
<div class="delfile"><h4>Deleted: trunk/LayoutTests/fetch/builtin-overrides.html (198888 => 198889)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/LayoutTests/fetch/builtin-overrides.html        2016-03-31 08:26:29 UTC (rev 198888)
+++ trunk/LayoutTests/fetch/builtin-overrides.html        2016-03-31 08:31:25 UTC (rev 198889)
</span><span class="lines">@@ -1,18 +0,0 @@
</span><del>-&lt;!DOCTYPE HTML&gt;
-&lt;html&gt;
-&lt;head&gt;
-&lt;script src=&quot;../resources/js-test-pre.js&quot;&gt;&lt;/script&gt;
-&lt;/head&gt;
-&lt;body&gt;
-&lt;script&gt;
-description(&quot;This test should run without throwing an exception.&quot;);
-
-Array.prototype.forEach = function() {
-    throw &quot;User overriden&quot;;
-};
-
-new Headers({a:1});
-&lt;/script&gt;
-&lt;script src=&quot;../resources/js-test-post.js&quot;&gt;&lt;/script&gt;
-&lt;/body&gt;
-&lt;/html&gt;
</del></span></pre></div>
<a id="trunkLayoutTestsfetchheaderconstructorsubclassexpectedtxtfromrev198888trunkLayoutTestsstreamsbuiltinoverridesexpectedtxt"></a>
<div class="copfile"><h4>Copied: trunk/LayoutTests/fetch/header-constructor-subclass-expected.txt (from rev 198888, trunk/LayoutTests/streams/builtin-overrides-expected.txt) (0 => 198889)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/LayoutTests/fetch/header-constructor-subclass-expected.txt                                (rev 0)
+++ trunk/LayoutTests/fetch/header-constructor-subclass-expected.txt        2016-03-31 08:31:25 UTC (rev 198889)
</span><span class="lines">@@ -0,0 +1,10 @@
</span><ins>+This test should create a Headers from an object which is a subclass of Headers.
+
+On success, you will see a series of &quot;PASS&quot; messages, followed by &quot;TEST COMPLETE&quot;.
+
+
+PASS otherHeaders.get('a') is &quot;1&quot;
+PASS successfullyParsed is true
+
+TEST COMPLETE
+
</ins></span></pre></div>
<a id="trunkLayoutTestsfetchheaderconstructorsubclasshtml"></a>
<div class="addfile"><h4>Added: trunk/LayoutTests/fetch/header-constructor-subclass.html (0 => 198889)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/LayoutTests/fetch/header-constructor-subclass.html                                (rev 0)
+++ trunk/LayoutTests/fetch/header-constructor-subclass.html        2016-03-31 08:31:25 UTC (rev 198889)
</span><span class="lines">@@ -0,0 +1,23 @@
</span><ins>+&lt;!DOCTYPE HTML&gt;
+&lt;html&gt;
+&lt;head&gt;
+&lt;script src=&quot;../resources/js-test-pre.js&quot;&gt;&lt;/script&gt;
+&lt;/head&gt;
+&lt;body&gt;
+&lt;script&gt;
+description(&quot;This test should create a Headers from an object which is a subclass of Headers.&quot;);
+
+let SpecialHeaders = class SpecialHeaders extends Headers {
+    constructor() {
+        super(...arguments);
+    }
+};
+
+let specialHeaders = new SpecialHeaders({&quot;a&quot;: &quot;1&quot;});
+let otherHeaders = new Headers(specialHeaders);
+shouldBeEqualToString(&quot;otherHeaders.get('a')&quot;, &quot;1&quot;);
+
+&lt;/script&gt;
+&lt;script src=&quot;../resources/js-test-post.js&quot;&gt;&lt;/script&gt;
+&lt;/body&gt;
+&lt;/html&gt;
</ins></span></pre></div>
<a id="trunkLayoutTestsfetchshadowingforEachexpectedtxtfromrev198888trunkLayoutTestsstreamsbuiltinoverridesexpectedtxt"></a>
<div class="copfile"><h4>Copied: trunk/LayoutTests/fetch/shadowing-forEach-expected.txt (from rev 198888, trunk/LayoutTests/streams/builtin-overrides-expected.txt) (0 => 198889)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/LayoutTests/fetch/shadowing-forEach-expected.txt                                (rev 0)
+++ trunk/LayoutTests/fetch/shadowing-forEach-expected.txt        2016-03-31 08:31:25 UTC (rev 198889)
</span><span class="lines">@@ -0,0 +1,9 @@
</span><ins>+This test should run without throwing an exception.
+
+On success, you will see a series of &quot;PASS&quot; messages, followed by &quot;TEST COMPLETE&quot;.
+
+
+PASS successfullyParsed is true
+
+TEST COMPLETE
+
</ins></span></pre></div>
<a id="trunkLayoutTestsfetchshadowingforEachhtmlfromrev198888trunkLayoutTestsfetchbuiltinoverrideshtml"></a>
<div class="copfile"><h4>Copied: trunk/LayoutTests/fetch/shadowing-forEach.html (from rev 198888, trunk/LayoutTests/fetch/builtin-overrides.html) (0 => 198889)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/LayoutTests/fetch/shadowing-forEach.html                                (rev 0)
+++ trunk/LayoutTests/fetch/shadowing-forEach.html        2016-03-31 08:31:25 UTC (rev 198889)
</span><span class="lines">@@ -0,0 +1,20 @@
</span><ins>+&lt;!DOCTYPE HTML&gt;
+&lt;html&gt;
+&lt;head&gt;
+&lt;script src=&quot;../resources/js-test-pre.js&quot;&gt;&lt;/script&gt;
+&lt;/head&gt;
+&lt;body&gt;
+&lt;script&gt;
+description(&quot;This test should run without throwing an exception.&quot;);
+
+Array.prototype.forEach = function() {
+    throw &quot;User overriden&quot;;
+};
+
+let headers = new Headers({a:1});
+let headers2 = new Headers(headers);
+
+&lt;/script&gt;
+&lt;script src=&quot;../resources/js-test-post.js&quot;&gt;&lt;/script&gt;
+&lt;/body&gt;
+&lt;/html&gt;
</ins></span></pre></div>
<a id="trunkLayoutTestsstreamsbuiltinoverridesexpectedtxt"></a>
<div class="delfile"><h4>Deleted: trunk/LayoutTests/streams/builtin-overrides-expected.txt (198888 => 198889)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/LayoutTests/streams/builtin-overrides-expected.txt        2016-03-31 08:26:29 UTC (rev 198888)
+++ trunk/LayoutTests/streams/builtin-overrides-expected.txt        2016-03-31 08:31:25 UTC (rev 198889)
</span><span class="lines">@@ -1,9 +0,0 @@
</span><del>-This test should run without throwing an exception.
-
-On success, you will see a series of &quot;PASS&quot; messages, followed by &quot;TEST COMPLETE&quot;.
-
-
-PASS successfullyParsed is true
-
-TEST COMPLETE
-
</del></span></pre></div>
<a id="trunkLayoutTestsstreamsbuiltinoverrideshtml"></a>
<div class="delfile"><h4>Deleted: trunk/LayoutTests/streams/builtin-overrides.html (198888 => 198889)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/LayoutTests/streams/builtin-overrides.html        2016-03-31 08:26:29 UTC (rev 198888)
+++ trunk/LayoutTests/streams/builtin-overrides.html        2016-03-31 08:31:25 UTC (rev 198889)
</span><span class="lines">@@ -1,19 +0,0 @@
</span><del>-&lt;!DOCTYPE HTML&gt;
-&lt;html&gt;
-&lt;head&gt;
-&lt;script src=&quot;../resources/js-test-pre.js&quot;&gt;&lt;/script&gt;
-&lt;/head&gt;
-&lt;body&gt;
-&lt;script&gt;
-description(&quot;This test should run without throwing an exception.&quot;);
-
-Object.defineProperty = function() {
-    throw &quot;User overriden&quot;;
-};
-
-new ByteLengthQueuingStrategy({});
-new CountQueuingStrategy({});
-&lt;/script&gt;
-&lt;script src=&quot;../resources/js-test-post.js&quot;&gt;&lt;/script&gt;
-&lt;/body&gt;
-&lt;/html&gt;
</del></span></pre></div>
<a id="trunkLayoutTestsstreamsshadowingPromiseexpectedtxtfromrev198888trunkLayoutTestsstreamsstreamspromisesexpectedtxt"></a>
<div class="copfile"><h4>Copied: trunk/LayoutTests/streams/shadowing-Promise-expected.txt (from rev 198888, trunk/LayoutTests/streams/streams-promises-expected.txt) (0 => 198889)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/LayoutTests/streams/shadowing-Promise-expected.txt                                (rev 0)
+++ trunk/LayoutTests/streams/shadowing-Promise-expected.txt        2016-03-31 08:31:25 UTC (rev 198889)
</span><span class="lines">@@ -0,0 +1,13 @@
</span><ins>+
+PASS Streams and promises: replace Promise constructor 
+PASS Streams and promises: replace Promise.resolve 
+PASS Streams and promises: replace Promise.reject 
+PASS Streams and promises: replace prototype of a promise object 
+PASS Streams and promises: replace then method in Promise prototype 
+PASS Streams and promises: replace catch method in Promise prototype 
+PASS Streams and promises: replace then method in promise object 
+PASS Streams should not directly use Number and related methods 
+PASS Streams should not directly use ReadableStream public APIs 
+PASS Streams should not directly use ReadableStreamReader read public API 
+PASS Streams should not directly use array public APIs 
+
</ins></span></pre></div>
<a id="trunkLayoutTestsstreamsshadowingPromisehtmlfromrev198888trunkLayoutTestsstreamsstreamspromiseshtml"></a>
<div class="copfile"><h4>Copied: trunk/LayoutTests/streams/shadowing-Promise.html (from rev 198888, trunk/LayoutTests/streams/streams-promises.html) (0 => 198889)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/LayoutTests/streams/shadowing-Promise.html                                (rev 0)
+++ trunk/LayoutTests/streams/shadowing-Promise.html        2016-03-31 08:31:25 UTC (rev 198889)
</span><span class="lines">@@ -0,0 +1,206 @@
</span><ins>+&lt;!DOCTYPE html&gt;
+&lt;script src='../resources/testharness.js'&gt;&lt;/script&gt;
+&lt;script src='../resources/testharnessreport.js'&gt;&lt;/script&gt;
+&lt;script&gt;
+test(function() {
+    const PromiseBackup = Promise;
+
+    try {
+        Promise = function() { assert_unreached(&quot;streams should not use this Promise object&quot;); };
+
+        new ReadableStream();
+        new WritableStream();
+    } finally {
+        Promise = PromiseBackup;
+    }
+}, 'Streams and promises: replace Promise constructor');
+
+test(function() {
+    const PromiseResolveBackup = Promise.resolve;
+
+    try {
+        Promise.resolve = function() { assert_unreached(&quot;streams should not use this Promise.resolve method&quot;); };
+
+        new ReadableStream();
+        new WritableStream();
+    } finally {
+        Promise.resolve = PromiseResolveBackup;
+    }
+}, 'Streams and promises: replace Promise.resolve');
+
+test(function() {
+    const PromiseRejectBackup = Promise.reject;
+
+    try {
+        Promise.reject = function() { assert_unreached(&quot;streams should not use this Promise.reject method&quot;); };
+
+        ReadableStream.prototype.cancel.call({}, &quot;reason&quot;);
+        WritableStream.prototype.abort.call({}, &quot;reason&quot;);
+    } finally {
+        Promise.reject = PromiseRejectBackup;
+    }
+}, 'Streams and promises: replace Promise.reject');
+
+test(function() {
+    function createMangledPromise() {
+        const promise = Promise.resolve();
+        Object.setPrototypeOf(promise, { constructor: Promise, then: function() { assert_unreached(&quot;streams should not use this promise then method&quot;); } });
+        return promise;
+    }
+    new ReadableStream({ start: function() { return createMangledPromise(); } })
+    new WritableStream({ start: function() { return createMangledPromise(); } })
+}, 'Streams and promises: replace prototype of a promise object');
+
+test(function() {
+    const PromiseThenBackup = Promise.prototype.then;
+
+    try {
+        Promise.prototype.then = function() { assert_unreached(&quot;streams should not use this Promise.prototype.then method&quot;); };
+
+        new ReadableStream();
+        new WritableStream();
+    } finally {
+        Promise.prototype.then = PromiseThenBackup;
+    }
+}, 'Streams and promises: replace then method in Promise prototype');
+
+test(function() {
+    const PromiseCatchBackup = Promise.prototype.catch;
+    const PromiseThenBackup = Promise.prototype.then;
+
+    try {
+        Promise.prototype.catch = function() { assert_unreached(&quot;streams should not use this Promise.prototype.catch method&quot;); };
+        Promise.prototype.then = function() { assert_unreached(&quot;streams should not use this Promise.prototype.catch method&quot;); };
+
+        const rs = new ReadableStream();
+        rs.tee();
+    } finally {
+        Promise.prototype.catch = PromiseCatchBackup;
+        Promise.prototype.then = PromiseThenBackup;
+    }
+}, 'Streams and promises: replace catch method in Promise prototype');
+
+test(function() {
+    function createMangledPromise() {
+        const promise = Promise.resolve();
+        promise.then = function() { assert_unreached(&quot;streams should not use this promise then method&quot;); };
+        return promise;
+    }
+    new ReadableStream({ start: function() { return createMangledPromise(); } })
+    new WritableStream({ start: function() { return createMangledPromise(); } })
+}, 'Streams and promises: replace then method in promise object');
+
+test(function() {
+    const NumberBackup = Number;
+    const NumberIsNaNBackup = Number.isNaN;
+    const NumberIsFiniteBackup = Number.isFinite;
+
+    try {
+        Number.isNaN = function() { assert_unreached(&quot;streams should not use this Number.isNaN method&quot;); };
+        Number.isFinite = function() { assert_unreached(&quot;streams should not use this Number.isFinite method&quot;); };
+        Number = null;
+
+        new ReadableStream({
+            start: function(controller) {
+                controller.enqueue(&quot;small potato&quot;);
+            }
+        }, {
+            size: function(chunk) { return 2; },
+            highWaterMark: 1
+        });
+
+    } finally {
+        Number = NumberBackup;
+        Number.isNaN = NumberIsNaNBackup;
+        Number.isFinite = NumberIsFiniteBackup;
+    }
+}, 'Streams should not directly use Number and related methods');
+test(function() {
+    const ReadableStreamGetReaderBackup = ReadableStream.prototype.getReader;
+
+    try {
+        ReadableStream.prototype.getReader = function() { assert_unreached(&quot;streams should not use this ReadableStream.getReader method&quot;); };
+        new ReadableStream().tee();
+    } finally {
+        ReadableStream.prototype.getReader = ReadableStreamGetReaderBackup;
+    }
+}, 'Streams should not directly use ReadableStream public APIs');
+
+promise_test(function() {
+    const ReadableStreamReader = new ReadableStream().getReader().constructor;
+    const ReadableStreamReaderReadBackup = ReadableStreamReader.prototype.read;
+
+    function cleanTest() {
+        ReadableStreamReader.prototype.read = ReadableStreamReaderReadBackup;
+    }
+
+    try {
+        ReadableStreamReader.prototype.read = function() { assert_unreached(&quot;streams should not use this ReadableStreamReader.read method&quot;); };
+
+        [s1, s2] = new ReadableStream({
+            start: function(controller) {
+                controller.close();
+            }
+        }).tee();
+        return s1.getReader().closed.then(cleanTest, cleanTest);
+
+    } catch (error) {
+        cleanTest();
+        assert_unreached(&quot;test should not throw&quot;);
+    }
+}, 'Streams should not directly use ReadableStreamReader read public API');
+
+promise_test(function() {
+    const ArrayPushBackup = Array.prototype.push;
+    const ArrayShiftBackup = Array.prototype.shift;
+
+    // Use of testing variable to try not messing up testharness.js code.
+    // FIXME: this approach is far from perfect: push is used in case an assert fails.
+    // But cleanTest will not be called and we may end-up mask the real assertion failure by below assert_unreached messages.
+    // We might want to either improve testharness.js or  move these tests out of testharness.js.
+    let testing = true;
+    Array.prototype.push = function() {
+        if (testing) {
+            testing = false;
+            assert_unreached(&quot;Array.prototype.push called&quot;);
+        }
+        return ArrayPushBackup.apply(this, arguments);
+    }
+
+    Array.prototype.shift = function() {
+        if (testing) {
+            testing = false;
+            assert_unreached(&quot;Array.prototype.shift called&quot;);
+        }
+        return ArrayShiftBackup.call(this, arguments);
+    }
+
+    function cleanTest() {
+        Array.prototype.push = ArrayPushBackup;
+        Array.prototype.shift = ArrayShiftBackup;
+    }
+    try {
+        let _controller;
+        const reader = new ReadableStream({
+            start: function(controller) {
+                _controller = controller;
+            }
+        }).getReader();
+        // checking whether pushing/shifting pending read promises is shielded.
+        const readPromise = reader.read().then(function(result) {
+            assert_equals(result.value, &quot;half baked potato&quot;);
+            // checking whether pushing/shifting enqueued values is shielded.
+            _controller.enqueue(&quot;fully baked potato&quot;);
+            return reader.read().then(function(result) {
+                assert_equals(result.value, &quot;fully baked potato&quot;);
+                cleanTest();
+            }, cleanTest);
+        }, cleanTest);
+        _controller.enqueue(&quot;half baked potato&quot;);
+        return readPromise;
+    } catch (error) {
+        cleanTest();
+        return Promise.reject(error);
+    }
+}, 'Streams should not directly use array public APIs');
+&lt;/script&gt;
</ins></span></pre></div>
<a id="trunkLayoutTestsstreamsshadowingdefinePropertyexpectedtxtfromrev198888trunkLayoutTestsfetchbuiltinoverridesexpectedtxt"></a>
<div class="copfile"><h4>Copied: trunk/LayoutTests/streams/shadowing-defineProperty-expected.txt (from rev 198888, trunk/LayoutTests/fetch/builtin-overrides-expected.txt) (0 => 198889)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/LayoutTests/streams/shadowing-defineProperty-expected.txt                                (rev 0)
+++ trunk/LayoutTests/streams/shadowing-defineProperty-expected.txt        2016-03-31 08:31:25 UTC (rev 198889)
</span><span class="lines">@@ -0,0 +1,9 @@
</span><ins>+This test should run without throwing an exception.
+
+On success, you will see a series of &quot;PASS&quot; messages, followed by &quot;TEST COMPLETE&quot;.
+
+
+PASS successfullyParsed is true
+
+TEST COMPLETE
+
</ins></span></pre></div>
<a id="trunkLayoutTestsstreamsshadowingdefinePropertyhtmlfromrev198888trunkLayoutTestsstreamsbuiltinoverrideshtml"></a>
<div class="copfile"><h4>Copied: trunk/LayoutTests/streams/shadowing-defineProperty.html (from rev 198888, trunk/LayoutTests/streams/builtin-overrides.html) (0 => 198889)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/LayoutTests/streams/shadowing-defineProperty.html                                (rev 0)
+++ trunk/LayoutTests/streams/shadowing-defineProperty.html        2016-03-31 08:31:25 UTC (rev 198889)
</span><span class="lines">@@ -0,0 +1,19 @@
</span><ins>+&lt;!DOCTYPE HTML&gt;
+&lt;html&gt;
+&lt;head&gt;
+&lt;script src=&quot;../resources/js-test-pre.js&quot;&gt;&lt;/script&gt;
+&lt;/head&gt;
+&lt;body&gt;
+&lt;script&gt;
+description(&quot;This test should run without throwing an exception.&quot;);
+
+Object.defineProperty = function() {
+    throw &quot;User overriden&quot;;
+};
+
+new ByteLengthQueuingStrategy({});
+new CountQueuingStrategy({});
+&lt;/script&gt;
+&lt;script src=&quot;../resources/js-test-post.js&quot;&gt;&lt;/script&gt;
+&lt;/body&gt;
+&lt;/html&gt;
</ins></span></pre></div>
<a id="trunkLayoutTestsstreamsstreamspromisesexpectedtxt"></a>
<div class="delfile"><h4>Deleted: trunk/LayoutTests/streams/streams-promises-expected.txt (198888 => 198889)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/LayoutTests/streams/streams-promises-expected.txt        2016-03-31 08:26:29 UTC (rev 198888)
+++ trunk/LayoutTests/streams/streams-promises-expected.txt        2016-03-31 08:31:25 UTC (rev 198889)
</span><span class="lines">@@ -1,13 +0,0 @@
</span><del>-
-PASS Streams and promises: replace Promise constructor 
-PASS Streams and promises: replace Promise.resolve 
-PASS Streams and promises: replace Promise.reject 
-PASS Streams and promises: replace prototype of a promise object 
-PASS Streams and promises: replace then method in Promise prototype 
-PASS Streams and promises: replace catch method in Promise prototype 
-PASS Streams and promises: replace then method in promise object 
-PASS Streams should not directly use Number and related methods 
-PASS Streams should not directly use ReadableStream public APIs 
-PASS Streams should not directly use ReadableStreamReader read public API 
-PASS Streams should not directly use array public APIs 
-
</del></span></pre></div>
<a id="trunkLayoutTestsstreamsstreamspromiseshtml"></a>
<div class="delfile"><h4>Deleted: trunk/LayoutTests/streams/streams-promises.html (198888 => 198889)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/LayoutTests/streams/streams-promises.html        2016-03-31 08:26:29 UTC (rev 198888)
+++ trunk/LayoutTests/streams/streams-promises.html        2016-03-31 08:31:25 UTC (rev 198889)
</span><span class="lines">@@ -1,206 +0,0 @@
</span><del>-&lt;!DOCTYPE html&gt;
-&lt;script src='../resources/testharness.js'&gt;&lt;/script&gt;
-&lt;script src='../resources/testharnessreport.js'&gt;&lt;/script&gt;
-&lt;script&gt;
-test(function() {
-    const PromiseBackup = Promise;
-
-    try {
-        Promise = function() { assert_unreached(&quot;streams should not use this Promise object&quot;); };
-
-        new ReadableStream();
-        new WritableStream();
-    } finally {
-        Promise = PromiseBackup;
-    }
-}, 'Streams and promises: replace Promise constructor');
-
-test(function() {
-    const PromiseResolveBackup = Promise.resolve;
-
-    try {
-        Promise.resolve = function() { assert_unreached(&quot;streams should not use this Promise.resolve method&quot;); };
-
-        new ReadableStream();
-        new WritableStream();
-    } finally {
-        Promise.resolve = PromiseResolveBackup;
-    }
-}, 'Streams and promises: replace Promise.resolve');
-
-test(function() {
-    const PromiseRejectBackup = Promise.reject;
-
-    try {
-        Promise.reject = function() { assert_unreached(&quot;streams should not use this Promise.reject method&quot;); };
-
-        ReadableStream.prototype.cancel.call({}, &quot;reason&quot;);
-        WritableStream.prototype.abort.call({}, &quot;reason&quot;);
-    } finally {
-        Promise.reject = PromiseRejectBackup;
-    }
-}, 'Streams and promises: replace Promise.reject');
-
-test(function() {
-    function createMangledPromise() {
-        const promise = Promise.resolve();
-        Object.setPrototypeOf(promise, { constructor: Promise, then: function() { assert_unreached(&quot;streams should not use this promise then method&quot;); } });
-        return promise;
-    }
-    new ReadableStream({ start: function() { return createMangledPromise(); } })
-    new WritableStream({ start: function() { return createMangledPromise(); } })
-}, 'Streams and promises: replace prototype of a promise object');
-
-test(function() {
-    const PromiseThenBackup = Promise.prototype.then;
-
-    try {
-        Promise.prototype.then = function() { assert_unreached(&quot;streams should not use this Promise.prototype.then method&quot;); };
-
-        new ReadableStream();
-        new WritableStream();
-    } finally {
-        Promise.prototype.then = PromiseThenBackup;
-    }
-}, 'Streams and promises: replace then method in Promise prototype');
-
-test(function() {
-    const PromiseCatchBackup = Promise.prototype.catch;
-    const PromiseThenBackup = Promise.prototype.then;
-
-    try {
-        Promise.prototype.catch = function() { assert_unreached(&quot;streams should not use this Promise.prototype.catch method&quot;); };
-        Promise.prototype.then = function() { assert_unreached(&quot;streams should not use this Promise.prototype.catch method&quot;); };
-
-        const rs = new ReadableStream();
-        rs.tee();
-    } finally {
-        Promise.prototype.catch = PromiseCatchBackup;
-        Promise.prototype.then = PromiseThenBackup;
-    }
-}, 'Streams and promises: replace catch method in Promise prototype');
-
-test(function() {
-    function createMangledPromise() {
-        const promise = Promise.resolve();
-        promise.then = function() { assert_unreached(&quot;streams should not use this promise then method&quot;); };
-        return promise;
-    }
-    new ReadableStream({ start: function() { return createMangledPromise(); } })
-    new WritableStream({ start: function() { return createMangledPromise(); } })
-}, 'Streams and promises: replace then method in promise object');
-
-test(function() {
-    const NumberBackup = Number;
-    const NumberIsNaNBackup = Number.isNaN;
-    const NumberIsFiniteBackup = Number.isFinite;
-
-    try {
-        Number.isNaN = function() { assert_unreached(&quot;streams should not use this Number.isNaN method&quot;); };
-        Number.isFinite = function() { assert_unreached(&quot;streams should not use this Number.isFinite method&quot;); };
-        Number = null;
-
-        new ReadableStream({
-            start: function(controller) {
-                controller.enqueue(&quot;small potato&quot;);
-            }
-        }, {
-            size: function(chunk) { return 2; },
-            highWaterMark: 1
-        });
-
-    } finally {
-        Number = NumberBackup;
-        Number.isNaN = NumberIsNaNBackup;
-        Number.isFinite = NumberIsFiniteBackup;
-    }
-}, 'Streams should not directly use Number and related methods');
-test(function() {
-    const ReadableStreamGetReaderBackup = ReadableStream.prototype.getReader;
-
-    try {
-        ReadableStream.prototype.getReader = function() { assert_unreached(&quot;streams should not use this ReadableStream.getReader method&quot;); };
-        new ReadableStream().tee();
-    } finally {
-        ReadableStream.prototype.getReader = ReadableStreamGetReaderBackup;
-    }
-}, 'Streams should not directly use ReadableStream public APIs');
-
-promise_test(function() {
-    const ReadableStreamReader = new ReadableStream().getReader().constructor;
-    const ReadableStreamReaderReadBackup = ReadableStreamReader.prototype.read;
-
-    function cleanTest() {
-        ReadableStreamReader.prototype.read = ReadableStreamReaderReadBackup;
-    }
-
-    try {
-        ReadableStreamReader.prototype.read = function() { assert_unreached(&quot;streams should not use this ReadableStreamReader.read method&quot;); };
-
-        [s1, s2] = new ReadableStream({
-            start: function(controller) {
-                controller.close();
-            }
-        }).tee();
-        return s1.getReader().closed.then(cleanTest, cleanTest);
-
-    } catch (error) {
-        cleanTest();
-        assert_unreached(&quot;test should not throw&quot;);
-    }
-}, 'Streams should not directly use ReadableStreamReader read public API');
-
-promise_test(function() {
-    const ArrayPushBackup = Array.prototype.push;
-    const ArrayShiftBackup = Array.prototype.shift;
-
-    // Use of testing variable to try not messing up testharness.js code.
-    // FIXME: this approach is far from perfect: push is used in case an assert fails.
-    // But cleanTest will not be called and we may end-up mask the real assertion failure by below assert_unreached messages.
-    // We might want to either improve testharness.js or  move these tests out of testharness.js.
-    let testing = true;
-    Array.prototype.push = function() {
-        if (testing) {
-            testing = false;
-            assert_unreached(&quot;Array.prototype.push called&quot;);
-        }
-        return ArrayPushBackup.apply(this, arguments);
-    }
-
-    Array.prototype.shift = function() {
-        if (testing) {
-            testing = false;
-            assert_unreached(&quot;Array.prototype.shift called&quot;);
-        }
-        return ArrayShiftBackup.call(this, arguments);
-    }
-
-    function cleanTest() {
-        Array.prototype.push = ArrayPushBackup;
-        Array.prototype.shift = ArrayShiftBackup;
-    }
-    try {
-        let _controller;
-        const reader = new ReadableStream({
-            start: function(controller) {
-                _controller = controller;
-            }
-        }).getReader();
-        // checking whether pushing/shifting pending read promises is shielded.
-        const readPromise = reader.read().then(function(result) {
-            assert_equals(result.value, &quot;half baked potato&quot;);
-            // checking whether pushing/shifting enqueued values is shielded.
-            _controller.enqueue(&quot;fully baked potato&quot;);
-            return reader.read().then(function(result) {
-                assert_equals(result.value, &quot;fully baked potato&quot;);
-                cleanTest();
-            }, cleanTest);
-        }, cleanTest);
-        _controller.enqueue(&quot;half baked potato&quot;);
-        return readPromise;
-    } catch (error) {
-        cleanTest();
-        return Promise.reject(error);
-    }
-}, 'Streams should not directly use array public APIs');
-&lt;/script&gt;
</del></span></pre></div>
<a id="trunkSourceWebCoreChangeLog"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/ChangeLog (198888 => 198889)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/ChangeLog        2016-03-31 08:26:29 UTC (rev 198888)
+++ trunk/Source/WebCore/ChangeLog        2016-03-31 08:31:25 UTC (rev 198889)
</span><span class="lines">@@ -1,3 +1,20 @@
</span><ins>+2016-03-31  Youenn Fablet  &lt;youenn.fablet@crf.canon.fr&gt;
+
+        Remove forEach use from Fetch Headers builtin constructor
+        https://bugs.webkit.org/show_bug.cgi?id=155967
+
+        Reviewed by Joseph Pecoraro.
+
+        Tests: fetch/shadowing-forEach.html
+               streams/shadowing-Promise.html
+               streams/shadowing-defineProperty.html
+
+        * Modules/fetch/FetchHeaders.idl: Adding fillFromJS private method.
+        * Modules/fetch/FetchHeaders.js:
+        (initializeFetchHeaders): Using fillFromJS private method. Using
+        instanceof test to check whether parameter is Headers or subclass of it.
+        * bindings/js/WebCoreBuiltinNames.h: Adding fillFromJS private symbol.
+
</ins><span class="cx"> 2016-03-30  Alex Christensen  &lt;achristensen@webkit.org&gt;
</span><span class="cx"> 
</span><span class="cx">         Fix Windows build.
</span></span></pre></div>
<a id="trunkSourceWebCoreModulesfetchFetchHeadersidl"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/Modules/fetch/FetchHeaders.idl (198888 => 198889)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/Modules/fetch/FetchHeaders.idl        2016-03-31 08:26:29 UTC (rev 198888)
+++ trunk/Source/WebCore/Modules/fetch/FetchHeaders.idl        2016-03-31 08:31:25 UTC (rev 198889)
</span><span class="lines">@@ -43,4 +43,5 @@
</span><span class="cx">     iterable&lt;DOMString, DOMString&gt;;
</span><span class="cx"> 
</span><span class="cx">     [Private, RaisesException, ImplementedAs=append] void appendFromJS(DOMString name, DOMString value);
</span><ins>+    [Private, ImplementedAs=fill] void fillFromJS(FetchHeaders? headers);
</ins><span class="cx"> };
</span></span></pre></div>
<a id="trunkSourceWebCoreModulesfetchFetchHeadersjs"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/Modules/fetch/FetchHeaders.js (198888 => 198889)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/Modules/fetch/FetchHeaders.js        2016-03-31 08:26:29 UTC (rev 198888)
+++ trunk/Source/WebCore/Modules/fetch/FetchHeaders.js        2016-03-31 08:31:25 UTC (rev 198889)
</span><span class="lines">@@ -35,10 +35,9 @@
</span><span class="cx">     if (!@isObject(headersInit))
</span><span class="cx">         throw new @TypeError(&quot;headersInit must be an object&quot;);
</span><span class="cx"> 
</span><del>-    if (this.constructor === headersInit.constructor) {
-         headersInit.forEach((value, name) =&gt; {
-             this.@appendFromJS(name, value);
-         });
</del><ins>+    if (headersInit instanceof this.constructor) {
+        this.@fillFromJS(headersInit);
+        return this;
</ins><span class="cx">     }
</span><span class="cx"> 
</span><span class="cx">     if (headersInit instanceof @Array) {
</span></span></pre></div>
<a id="trunkSourceWebCorebindingsjsWebCoreBuiltinNamesh"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/bindings/js/WebCoreBuiltinNames.h (198888 => 198889)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/bindings/js/WebCoreBuiltinNames.h        2016-03-31 08:26:29 UTC (rev 198888)
+++ trunk/Source/WebCore/bindings/js/WebCoreBuiltinNames.h        2016-03-31 08:31:25 UTC (rev 198889)
</span><span class="lines">@@ -38,6 +38,7 @@
</span><span class="cx">     macro(controlledReadableStream) \
</span><span class="cx">     macro(controller) \
</span><span class="cx">     macro(disturbed) \
</span><ins>+    macro(fillFromJS) \
</ins><span class="cx">     macro(getUserMediaFromJS) \
</span><span class="cx">     macro(initializeWith) \
</span><span class="cx">     macro(operations) \
</span></span></pre>
</div>
</div>

</body>
</html>