<!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>[210698] branches/safari-603-branch</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/210698">210698</a></dd>
<dt>Author</dt> <dd>matthew_hanson@apple.com</dd>
<dt>Date</dt> <dd>2017-01-12 22:09:56 -0800 (Thu, 12 Jan 2017)</dd>
</dl>

<h3>Log Message</h3>
<pre>Merge <a href="http://trac.webkit.org/projects/webkit/changeset/210593">r210593</a>. rdar://problem/29970907</pre>

<h3>Modified Paths</h3>
<ul>
<li><a href="#branchessafari603branchLayoutTestsChangeLog">branches/safari-603-branch/LayoutTests/ChangeLog</a></li>
<li><a href="#branchessafari603branchLayoutTestsimportedw3cChangeLog">branches/safari-603-branch/LayoutTests/imported/w3c/ChangeLog</a></li>
<li><a href="#branchessafari603branchLayoutTestsimportedw3cwebplatformtestsurlurlsearchparamsforeachexpectedtxt">branches/safari-603-branch/LayoutTests/imported/w3c/web-platform-tests/url/urlsearchparams-foreach-expected.txt</a></li>
<li><a href="#branchessafari603branchSourceWebCoreChangeLog">branches/safari-603-branch/Source/WebCore/ChangeLog</a></li>
<li><a href="#branchessafari603branchSourceWebCorehtmlURLSearchParamscpp">branches/safari-603-branch/Source/WebCore/html/URLSearchParams.cpp</a></li>
<li><a href="#branchessafari603branchSourceWebCorehtmlURLSearchParamsh">branches/safari-603-branch/Source/WebCore/html/URLSearchParams.h</a></li>
<li><a href="#branchessafari603branchSourceWebCorehtmlURLSearchParamsidl">branches/safari-603-branch/Source/WebCore/html/URLSearchParams.idl</a></li>
</ul>

<h3>Added Paths</h3>
<ul>
<li><a href="#branchessafari603branchLayoutTestsfastdomDOMURLsearchparamsiterableexpectedtxt">branches/safari-603-branch/LayoutTests/fast/dom/DOMURL/searchparams-iterable-expected.txt</a></li>
<li><a href="#branchessafari603branchLayoutTestsfastdomDOMURLsearchparamsiterablehtml">branches/safari-603-branch/LayoutTests/fast/dom/DOMURL/searchparams-iterable.html</a></li>
</ul>

</div>
<div id="patch">
<h3>Diff</h3>
<a id="branchessafari603branchLayoutTestsChangeLog"></a>
<div class="modfile"><h4>Modified: branches/safari-603-branch/LayoutTests/ChangeLog (210697 => 210698)</h4>
<pre class="diff"><span>
<span class="info">--- branches/safari-603-branch/LayoutTests/ChangeLog        2017-01-13 06:01:38 UTC (rev 210697)
+++ branches/safari-603-branch/LayoutTests/ChangeLog        2017-01-13 06:09:56 UTC (rev 210698)
</span><span class="lines">@@ -1,5 +1,22 @@
</span><span class="cx"> 2017-01-12  Matthew Hanson  &lt;matthew_hanson@apple.com&gt;
</span><span class="cx"> 
</span><ins>+        Merge r210593. rdar://problem/29970907
+
+    2017-01-11  Chris Dumez  &lt;cdumez@apple.com&gt;
+
+            Iterating over URLSearchParams does not work
+            https://bugs.webkit.org/show_bug.cgi?id=166921
+            &lt;rdar://problem/29970907&gt;
+
+            Reviewed by Alex Christensen.
+
+            Add layout test coverage.
+
+            * fast/dom/DOMURL/searchparams-iterable-expected.txt: Added.
+            * fast/dom/DOMURL/searchparams-iterable.html: Added.
+
+2017-01-12  Matthew Hanson  &lt;matthew_hanson@apple.com&gt;
+
</ins><span class="cx">         Merge r210564. rdar://problem/29944582
</span><span class="cx"> 
</span><span class="cx">     2017-01-10  Ryosuke Niwa  &lt;rniwa@webkit.org&gt;
</span></span></pre></div>
<a id="branchessafari603branchLayoutTestsfastdomDOMURLsearchparamsiterableexpectedtxt"></a>
<div class="addfile"><h4>Added: branches/safari-603-branch/LayoutTests/fast/dom/DOMURL/searchparams-iterable-expected.txt (0 => 210698)</h4>
<pre class="diff"><span>
<span class="info">--- branches/safari-603-branch/LayoutTests/fast/dom/DOMURL/searchparams-iterable-expected.txt                                (rev 0)
+++ branches/safari-603-branch/LayoutTests/fast/dom/DOMURL/searchparams-iterable-expected.txt        2017-01-13 06:09:56 UTC (rev 210698)
</span><span class="lines">@@ -0,0 +1,19 @@
</span><ins>+Tests that URLSearchParams is iterable.
+
+On success, you will see a series of &quot;PASS&quot; messages, followed by &quot;TEST COMPLETE&quot;.
+
+
+PASS pair.length is 2
+PASS pair[0] is &quot;key1&quot;
+PASS pair[1] is &quot;value1&quot;
+PASS pair.length is 2
+PASS pair[0] is &quot;key2&quot;
+PASS pair[1] is &quot;value2&quot;
+PASS pair.length is 2
+PASS pair[0] is &quot;key3&quot;
+PASS pair[1] is &quot;value3&quot;
+PASS iteration_count is 3
+PASS successfullyParsed is true
+
+TEST COMPLETE
+
</ins></span></pre></div>
<a id="branchessafari603branchLayoutTestsfastdomDOMURLsearchparamsiterablehtml"></a>
<div class="addfile"><h4>Added: branches/safari-603-branch/LayoutTests/fast/dom/DOMURL/searchparams-iterable.html (0 => 210698)</h4>
<pre class="diff"><span>
<span class="info">--- branches/safari-603-branch/LayoutTests/fast/dom/DOMURL/searchparams-iterable.html                                (rev 0)
+++ branches/safari-603-branch/LayoutTests/fast/dom/DOMURL/searchparams-iterable.html        2017-01-13 06:09:56 UTC (rev 210698)
</span><span class="lines">@@ -0,0 +1,25 @@
</span><ins>+&lt;!DOCTYPE html&gt;
+&lt;html&gt;
+&lt;body&gt;
+&lt;script src=&quot;../../../resources/js-test-pre.js&quot;&gt;&lt;/script&gt;
+&lt;script&gt;
+description(&quot;Tests that URLSearchParams is iterable.&quot;);
+
+var searchParams = new URLSearchParams(&quot;key1=value1&amp;key2=value2&amp;key3=value3&quot;);
+var result = [['key1', 'value1'], ['key2', 'value2'], ['key3', 'value3']];
+
+var iteration_count = 0;
+for (var item of searchParams) {
+    pair = item;
+    expected_key = result[iteration_count][0];
+    expected_value = result[iteration_count][1];
+    shouldBe(&quot;pair.length&quot;, &quot;2&quot;);
+    shouldBeEqualToString(&quot;pair[0]&quot;, &quot;&quot; + expected_key);
+    shouldBeEqualToString(&quot;pair[1]&quot;, &quot;&quot; + expected_value);
+    iteration_count++;
+}
+shouldBe(&quot;iteration_count&quot;, &quot;3&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="branchessafari603branchLayoutTestsimportedw3cChangeLog"></a>
<div class="modfile"><h4>Modified: branches/safari-603-branch/LayoutTests/imported/w3c/ChangeLog (210697 => 210698)</h4>
<pre class="diff"><span>
<span class="info">--- branches/safari-603-branch/LayoutTests/imported/w3c/ChangeLog        2017-01-13 06:01:38 UTC (rev 210697)
+++ branches/safari-603-branch/LayoutTests/imported/w3c/ChangeLog        2017-01-13 06:09:56 UTC (rev 210698)
</span><span class="lines">@@ -1,5 +1,21 @@
</span><span class="cx"> 2017-01-12  Matthew Hanson  &lt;matthew_hanson@apple.com&gt;
</span><span class="cx"> 
</span><ins>+        Merge r210593. rdar://problem/29970907
+
+    2017-01-11  Chris Dumez  &lt;cdumez@apple.com&gt;
+
+            Iterating over URLSearchParams does not work
+            https://bugs.webkit.org/show_bug.cgi?id=166921
+            &lt;rdar://problem/29970907&gt;
+
+            Reviewed by Alex Christensen.
+
+            Rebaseline W3C test now that more checks are passing.
+
+            * web-platform-tests/url/urlsearchparams-foreach-expected.txt:
+
+2017-01-12  Matthew Hanson  &lt;matthew_hanson@apple.com&gt;
+
</ins><span class="cx">         Merge r210471. rdar://problem/29859121
</span><span class="cx"> 
</span><span class="cx">     2017-01-06  Chris Dumez  &lt;cdumez@apple.com&gt;
</span></span></pre></div>
<a id="branchessafari603branchLayoutTestsimportedw3cwebplatformtestsurlurlsearchparamsforeachexpectedtxt"></a>
<div class="modfile"><h4>Modified: branches/safari-603-branch/LayoutTests/imported/w3c/web-platform-tests/url/urlsearchparams-foreach-expected.txt (210697 => 210698)</h4>
<pre class="diff"><span>
<span class="info">--- branches/safari-603-branch/LayoutTests/imported/w3c/web-platform-tests/url/urlsearchparams-foreach-expected.txt        2017-01-13 06:01:38 UTC (rev 210697)
+++ branches/safari-603-branch/LayoutTests/imported/w3c/web-platform-tests/url/urlsearchparams-foreach-expected.txt        2017-01-13 06:09:56 UTC (rev 210698)
</span><span class="lines">@@ -1,8 +1,5 @@
</span><span class="cx"> 
</span><del>-FAIL ForEach Check params.forEach is not a function. (In 'params.forEach(function(value, key) {
-        keys.push(key);
-        values.push(value);
-    })', 'params.forEach' is undefined)
-FAIL For-of Check i of b is not a function. (In 'i of b', 'i of b' is undefined)
-FAIL empty i of b is not a function. (In 'i of b', 'i of b' is undefined)
</del><ins>+PASS ForEach Check 
+PASS For-of Check 
+PASS empty 
</ins><span class="cx"> 
</span></span></pre></div>
<a id="branchessafari603branchSourceWebCoreChangeLog"></a>
<div class="modfile"><h4>Modified: branches/safari-603-branch/Source/WebCore/ChangeLog (210697 => 210698)</h4>
<pre class="diff"><span>
<span class="info">--- branches/safari-603-branch/Source/WebCore/ChangeLog        2017-01-13 06:01:38 UTC (rev 210697)
+++ branches/safari-603-branch/Source/WebCore/ChangeLog        2017-01-13 06:09:56 UTC (rev 210698)
</span><span class="lines">@@ -1,5 +1,29 @@
</span><span class="cx"> 2017-01-12  Matthew Hanson  &lt;matthew_hanson@apple.com&gt;
</span><span class="cx"> 
</span><ins>+        Merge r210593. rdar://problem/29970907
+
+    2017-01-11  Chris Dumez  &lt;cdumez@apple.com&gt;
+
+            Iterating over URLSearchParams does not work
+            https://bugs.webkit.org/show_bug.cgi?id=166921
+            &lt;rdar://problem/29970907&gt;
+
+            Reviewed by Alex Christensen.
+
+            Make URLSearchParams iterable, as per:
+            - https://url.spec.whatwg.org/#urlsearchparams
+
+            Test: fast/dom/DOMURL/searchparams-iterable.html
+
+            * html/URLSearchParams.cpp:
+            (WebCore::URLSearchParams::Iterator::next):
+            (WebCore::URLSearchParams::Iterator::Iterator):
+            * html/URLSearchParams.h:
+            (WebCore::URLSearchParams::createIterator):
+            * html/URLSearchParams.idl:
+
+2017-01-12  Matthew Hanson  &lt;matthew_hanson@apple.com&gt;
+
</ins><span class="cx">         Merge r210564. rdar://problem/29944582
</span><span class="cx"> 
</span><span class="cx">     2017-01-10  Ryosuke Niwa  &lt;rniwa@webkit.org&gt;
</span></span></pre></div>
<a id="branchessafari603branchSourceWebCorehtmlURLSearchParamscpp"></a>
<div class="modfile"><h4>Modified: branches/safari-603-branch/Source/WebCore/html/URLSearchParams.cpp (210697 => 210698)</h4>
<pre class="diff"><span>
<span class="info">--- branches/safari-603-branch/Source/WebCore/html/URLSearchParams.cpp        2017-01-13 06:01:38 UTC (rev 210697)
+++ branches/safari-603-branch/Source/WebCore/html/URLSearchParams.cpp        2017-01-13 06:09:56 UTC (rev 210698)
</span><span class="lines">@@ -123,5 +123,20 @@
</span><span class="cx">     String search = m_associatedURL-&gt;search();
</span><span class="cx">     m_pairs = search.startsWith('?') ? URLParser::parseURLEncodedForm(StringView(search).substring(1)) : URLParser::parseURLEncodedForm(search);
</span><span class="cx"> }
</span><ins>+
+std::optional&lt;WTF::KeyValuePair&lt;String, String&gt;&gt; URLSearchParams::Iterator::next()
+{
+    auto&amp; pairs = m_target-&gt;pairs();
+    if (m_index &gt;= pairs.size())
+        return std::nullopt;
+
+    auto&amp; pair = pairs[m_index++];
+    return WTF::KeyValuePair&lt;String, String&gt; { pair.first, pair.second };
+}
+
+URLSearchParams::Iterator::Iterator(URLSearchParams&amp; params)
+    : m_target(params)
+{
+}
</ins><span class="cx">     
</span><span class="cx"> }
</span></span></pre></div>
<a id="branchessafari603branchSourceWebCorehtmlURLSearchParamsh"></a>
<div class="modfile"><h4>Modified: branches/safari-603-branch/Source/WebCore/html/URLSearchParams.h (210697 => 210698)</h4>
<pre class="diff"><span>
<span class="info">--- branches/safari-603-branch/Source/WebCore/html/URLSearchParams.h        2017-01-13 06:01:38 UTC (rev 210697)
+++ branches/safari-603-branch/Source/WebCore/html/URLSearchParams.h        2017-01-13 06:09:56 UTC (rev 210698)
</span><span class="lines">@@ -44,9 +44,21 @@
</span><span class="cx">     bool has(const String&amp; name) const;
</span><span class="cx">     void set(const String&amp; name, const String&amp; value);
</span><span class="cx">     String toString() const;
</span><ins>+    const Vector&lt;std::pair&lt;String, String&gt;&gt;&amp; pairs() const { return m_pairs; }
</ins><span class="cx">     operator const Vector&lt;std::pair&lt;String, String&gt;&gt;&amp;() { return m_pairs; }
</span><span class="cx">     void updateFromAssociatedURL();
</span><span class="cx"> 
</span><ins>+    class Iterator {
+    public:
+        explicit Iterator(URLSearchParams&amp;);
+        std::optional&lt;WTF::KeyValuePair&lt;String, String&gt;&gt; next();
+
+    private:
+        Ref&lt;URLSearchParams&gt; m_target;
+        size_t m_index { 0 };
+    };
+    Iterator createIterator() { return Iterator { *this }; }
+
</ins><span class="cx"> private:
</span><span class="cx">     URLSearchParams(const String&amp;, DOMURL*);
</span><span class="cx">     explicit URLSearchParams(const Vector&lt;std::pair&lt;String, String&gt;&gt;&amp;);
</span></span></pre></div>
<a id="branchessafari603branchSourceWebCorehtmlURLSearchParamsidl"></a>
<div class="modfile"><h4>Modified: branches/safari-603-branch/Source/WebCore/html/URLSearchParams.idl (210697 => 210698)</h4>
<pre class="diff"><span>
<span class="info">--- branches/safari-603-branch/Source/WebCore/html/URLSearchParams.idl        2017-01-13 06:01:38 UTC (rev 210697)
+++ branches/safari-603-branch/Source/WebCore/html/URLSearchParams.idl        2017-01-13 06:09:56 UTC (rev 210698)
</span><span class="lines">@@ -34,7 +34,7 @@
</span><span class="cx">     sequence&lt;USVString&gt; getAll(USVString name);
</span><span class="cx">     boolean has(USVString name);
</span><span class="cx">     void set(USVString name, USVString value);
</span><del>-    // FIXME: This should be iterable.
</del><ins>+    iterable&lt;USVString, USVString&gt;;
</ins><span class="cx"> 
</span><span class="cx">     // FIXME: This should just be stringifier once that is supported in the bindings generator
</span><span class="cx">     DOMString toString();
</span></span></pre>
</div>
</div>

</body>
</html>