Diff
Modified: trunk/LayoutTests/ChangeLog (210592 => 210593)
--- trunk/LayoutTests/ChangeLog 2017-01-11 18:48:34 UTC (rev 210592)
+++ trunk/LayoutTests/ChangeLog 2017-01-11 19:18:24 UTC (rev 210593)
@@ -1,5 +1,18 @@
2017-01-11 Chris Dumez <[email protected]>
+ 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-11 Chris Dumez <[email protected]>
+
[iOS][WK2] KeyboardEvent.key always returns an empty string
https://bugs.webkit.org/show_bug.cgi?id=166918
<rdar://problem/29861147>
Added: trunk/LayoutTests/fast/dom/DOMURL/searchparams-iterable-expected.txt (0 => 210593)
--- trunk/LayoutTests/fast/dom/DOMURL/searchparams-iterable-expected.txt (rev 0)
+++ trunk/LayoutTests/fast/dom/DOMURL/searchparams-iterable-expected.txt 2017-01-11 19:18:24 UTC (rev 210593)
@@ -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: trunk/LayoutTests/fast/dom/DOMURL/searchparams-iterable.html (0 => 210593)
--- trunk/LayoutTests/fast/dom/DOMURL/searchparams-iterable.html (rev 0)
+++ trunk/LayoutTests/fast/dom/DOMURL/searchparams-iterable.html 2017-01-11 19:18:24 UTC (rev 210593)
@@ -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: trunk/LayoutTests/imported/w3c/ChangeLog (210592 => 210593)
--- trunk/LayoutTests/imported/w3c/ChangeLog 2017-01-11 18:48:34 UTC (rev 210592)
+++ trunk/LayoutTests/imported/w3c/ChangeLog 2017-01-11 19:18:24 UTC (rev 210593)
@@ -1,3 +1,15 @@
+2017-01-11 Chris Dumez <[email protected]>
+
+ 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-10 Chris Dumez <[email protected]>
Make Event.initEvent()'s first parameter mandatory
Modified: trunk/LayoutTests/imported/w3c/web-platform-tests/url/urlsearchparams-foreach-expected.txt (210592 => 210593)
--- trunk/LayoutTests/imported/w3c/web-platform-tests/url/urlsearchparams-foreach-expected.txt 2017-01-11 18:48:34 UTC (rev 210592)
+++ trunk/LayoutTests/imported/w3c/web-platform-tests/url/urlsearchparams-foreach-expected.txt 2017-01-11 19:18:24 UTC (rev 210593)
@@ -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: trunk/Source/WebCore/ChangeLog (210592 => 210593)
--- trunk/Source/WebCore/ChangeLog 2017-01-11 18:48:34 UTC (rev 210592)
+++ trunk/Source/WebCore/ChangeLog 2017-01-11 19:18:24 UTC (rev 210593)
@@ -1,3 +1,23 @@
+2017-01-11 Chris Dumez <[email protected]>
+
+ 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-11 Myles C. Maxfield <[email protected]>
[Cocoa] Variation fonts without variations specified are not rendered as if the default variations were specified
Modified: trunk/Source/WebCore/html/URLSearchParams.cpp (210592 => 210593)
--- trunk/Source/WebCore/html/URLSearchParams.cpp 2017-01-11 18:48:34 UTC (rev 210592)
+++ trunk/Source/WebCore/html/URLSearchParams.cpp 2017-01-11 19:18:24 UTC (rev 210593)
@@ -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: trunk/Source/WebCore/html/URLSearchParams.h (210592 => 210593)
--- trunk/Source/WebCore/html/URLSearchParams.h 2017-01-11 18:48:34 UTC (rev 210592)
+++ trunk/Source/WebCore/html/URLSearchParams.h 2017-01-11 19:18:24 UTC (rev 210593)
@@ -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: trunk/Source/WebCore/html/URLSearchParams.idl (210592 => 210593)
--- trunk/Source/WebCore/html/URLSearchParams.idl 2017-01-11 18:48:34 UTC (rev 210592)
+++ trunk/Source/WebCore/html/URLSearchParams.idl 2017-01-11 19:18:24 UTC (rev 210593)
@@ -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();