Diff
Modified: branches/safari-603-branch/LayoutTests/ChangeLog (210697 => 210698)
--- 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)
@@ -1,5 +1,22 @@
2017-01-12 Matthew Hanson <matthew_han...@apple.com>
+ Merge r210593. rdar://problem/29970907
+
+ 2017-01-11 Chris Dumez <cdu...@apple.com>
+
+ Iterating over URLSearchParams does not work
+ https://bugs.webkit.org/show_bug.cgi?id=166921
+ <rdar://problem/29970907>
+
+ 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 <matthew_han...@apple.com>
+
Merge r210564. rdar://problem/29944582
2017-01-10 Ryosuke Niwa <rn...@webkit.org>
Added: branches/safari-603-branch/LayoutTests/fast/dom/DOMURL/searchparams-iterable-expected.txt (0 => 210698)
--- 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)
@@ -0,0 +1,19 @@
+Tests that URLSearchParams is iterable.
+
+On success, you will see a series of "PASS" messages, followed by "TEST COMPLETE".
+
+
+PASS pair.length is 2
+PASS pair[0] is "key1"
+PASS pair[1] is "value1"
+PASS pair.length is 2
+PASS pair[0] is "key2"
+PASS pair[1] is "value2"
+PASS pair.length is 2
+PASS pair[0] is "key3"
+PASS pair[1] is "value3"
+PASS iteration_count is 3
+PASS successfullyParsed is true
+
+TEST COMPLETE
+
Added: branches/safari-603-branch/LayoutTests/fast/dom/DOMURL/searchparams-iterable.html (0 => 210698)
--- 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)
@@ -0,0 +1,25 @@
+<!DOCTYPE html>
+<html>
+<body>
+<script src=""
+<script>
+description("Tests that URLSearchParams is iterable.");
+
+var searchParams = new URLSearchParams("key1=value1&key2=value2&key3=value3");
+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("pair.length", "2");
+ shouldBeEqualToString("pair[0]", "" + expected_key);
+ shouldBeEqualToString("pair[1]", "" + expected_value);
+ iteration_count++;
+}
+shouldBe("iteration_count", "3");
+</script>
+<script src=""
+</body>
+</html>
Modified: branches/safari-603-branch/LayoutTests/imported/w3c/ChangeLog (210697 => 210698)
--- 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)
@@ -1,5 +1,21 @@
2017-01-12 Matthew Hanson <matthew_han...@apple.com>
+ Merge r210593. rdar://problem/29970907
+
+ 2017-01-11 Chris Dumez <cdu...@apple.com>
+
+ Iterating over URLSearchParams does not work
+ https://bugs.webkit.org/show_bug.cgi?id=166921
+ <rdar://problem/29970907>
+
+ 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 <matthew_han...@apple.com>
+
Merge r210471. rdar://problem/29859121
2017-01-06 Chris Dumez <cdu...@apple.com>
Modified: branches/safari-603-branch/LayoutTests/imported/w3c/web-platform-tests/url/urlsearchparams-foreach-expected.txt (210697 => 210698)
--- 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)
@@ -1,8 +1,5 @@
-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)
+PASS ForEach Check
+PASS For-of Check
+PASS empty
Modified: branches/safari-603-branch/Source/WebCore/ChangeLog (210697 => 210698)
--- 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)
@@ -1,5 +1,29 @@
2017-01-12 Matthew Hanson <matthew_han...@apple.com>
+ Merge r210593. rdar://problem/29970907
+
+ 2017-01-11 Chris Dumez <cdu...@apple.com>
+
+ Iterating over URLSearchParams does not work
+ https://bugs.webkit.org/show_bug.cgi?id=166921
+ <rdar://problem/29970907>
+
+ 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 <matthew_han...@apple.com>
+
Merge r210564. rdar://problem/29944582
2017-01-10 Ryosuke Niwa <rn...@webkit.org>
Modified: branches/safari-603-branch/Source/WebCore/html/URLSearchParams.cpp (210697 => 210698)
--- 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)
@@ -123,5 +123,20 @@
String search = m_associatedURL->search();
m_pairs = search.startsWith('?') ? URLParser::parseURLEncodedForm(StringView(search).substring(1)) : URLParser::parseURLEncodedForm(search);
}
+
+std::optional<WTF::KeyValuePair<String, String>> URLSearchParams::Iterator::next()
+{
+ auto& pairs = m_target->pairs();
+ if (m_index >= pairs.size())
+ return std::nullopt;
+
+ auto& pair = pairs[m_index++];
+ return WTF::KeyValuePair<String, String> { pair.first, pair.second };
+}
+
+URLSearchParams::Iterator::Iterator(URLSearchParams& params)
+ : m_target(params)
+{
+}
}
Modified: branches/safari-603-branch/Source/WebCore/html/URLSearchParams.h (210697 => 210698)
--- 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)
@@ -44,9 +44,21 @@
bool has(const String& name) const;
void set(const String& name, const String& value);
String toString() const;
+ const Vector<std::pair<String, String>>& pairs() const { return m_pairs; }
operator const Vector<std::pair<String, String>>&() { return m_pairs; }
void updateFromAssociatedURL();
+ class Iterator {
+ public:
+ explicit Iterator(URLSearchParams&);
+ std::optional<WTF::KeyValuePair<String, String>> next();
+
+ private:
+ Ref<URLSearchParams> m_target;
+ size_t m_index { 0 };
+ };
+ Iterator createIterator() { return Iterator { *this }; }
+
private:
URLSearchParams(const String&, DOMURL*);
explicit URLSearchParams(const Vector<std::pair<String, String>>&);
Modified: branches/safari-603-branch/Source/WebCore/html/URLSearchParams.idl (210697 => 210698)
--- 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)
@@ -34,7 +34,7 @@
sequence<USVString> getAll(USVString name);
boolean has(USVString name);
void set(USVString name, USVString value);
- // FIXME: This should be iterable.
+ iterable<USVString, USVString>;
// FIXME: This should just be stringifier once that is supported in the bindings generator
DOMString toString();