Implement URLSearchParams
authorachristensen@apple.com <achristensen@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Wed, 14 Sep 2016 01:34:27 +0000 (01:34 +0000)
committerachristensen@apple.com <achristensen@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Wed, 14 Sep 2016 01:34:27 +0000 (01:34 +0000)
https://bugs.webkit.org/show_bug.cgi?id=161920

Reviewed by Chris Dumez.

LayoutTests/imported/w3c:

* web-platform-tests/XMLHttpRequest/send-usp-expected.txt:
* web-platform-tests/fetch/api/request/request-init-002-expected.txt:
* web-platform-tests/fetch/api/response/response-init-002-expected.txt:
* web-platform-tests/url/interfaces-expected.txt:
* web-platform-tests/url/url-constructor-expected.txt:
* web-platform-tests/url/urlsearchparams-append-expected.txt:
* web-platform-tests/url/urlsearchparams-constructor-expected.txt:
* web-platform-tests/url/urlsearchparams-delete-expected.txt:
* web-platform-tests/url/urlsearchparams-get-expected.txt:
* web-platform-tests/url/urlsearchparams-getall-expected.txt:
* web-platform-tests/url/urlsearchparams-has-expected.txt:
* web-platform-tests/url/urlsearchparams-set-expected.txt:
* web-platform-tests/url/urlsearchparams-stringifier-expected.txt:

Source/WebCore:

Covered by newly passing web platform tests.

* CMakeLists.txt:
* DerivedSources.make:
* WebCore.xcodeproj/project.pbxproj:
* html/DOMURL.cpp:
(WebCore::DOMURL::setQuery):
(WebCore::DOMURL::searchParams):
* html/DOMURL.h:
* html/URLSearchParams.cpp: Added.
(WebCore::URLSearchParams::URLSearchParams):
(WebCore::URLSearchParams::get):
(WebCore::URLSearchParams::has):
(WebCore::URLSearchParams::set):
(WebCore::URLSearchParams::append):
(WebCore::URLSearchParams::getAll):
(WebCore::URLSearchParams::remove):
(WebCore::URLSearchParams::toString):
(WebCore::URLSearchParams::updateURL):
(WebCore::URLSearchParams::Iterator::Iterator):
* html/URLSearchParams.h: Added.
(WebCore::URLSearchParams::create):
(WebCore::URLSearchParams::createIterator):
* html/URLSearchParams.idl: Added.
* html/URLUtils.idl:
* platform/URLParser.cpp:
(WebCore::percentDecode):
(WebCore::URLParser::parseHost):
(WebCore::formURLDecode):
(WebCore::serializeURLEncodedForm):
(WebCore::URLParser::serialize):
* platform/URLParser.h:

Source/WTF:

* wtf/text/StringView.h:
(WTF::StringView::split): Added.

LayoutTests:

* js/dom/global-constructors-attributes-dedicated-worker-expected.txt:
* platform/mac-wk1/js/dom/global-constructors-attributes-expected.txt:
* platform/mac/imported/w3c/web-platform-tests/XMLHttpRequest/setrequestheader-content-type-expected.txt:

git-svn-id: https://svn.webkit.org/repository/webkit/trunk@205893 268f45cc-cd09-0410-ab3c-d52691b4dbfc

37 files changed:
LayoutTests/ChangeLog
LayoutTests/fast/dom/DOMURL/searchparams-expected.txt [new file with mode: 0644]
LayoutTests/fast/dom/DOMURL/searchparams.html [new file with mode: 0644]
LayoutTests/imported/w3c/ChangeLog
LayoutTests/imported/w3c/web-platform-tests/XMLHttpRequest/send-usp-expected.txt
LayoutTests/imported/w3c/web-platform-tests/fetch/api/request/request-init-002-expected.txt
LayoutTests/imported/w3c/web-platform-tests/fetch/api/response/response-init-002-expected.txt
LayoutTests/imported/w3c/web-platform-tests/url/interfaces-expected.txt
LayoutTests/imported/w3c/web-platform-tests/url/url-constructor-expected.txt
LayoutTests/imported/w3c/web-platform-tests/url/urlsearchparams-append-expected.txt
LayoutTests/imported/w3c/web-platform-tests/url/urlsearchparams-constructor-expected.txt
LayoutTests/imported/w3c/web-platform-tests/url/urlsearchparams-delete-expected.txt
LayoutTests/imported/w3c/web-platform-tests/url/urlsearchparams-get-expected.txt
LayoutTests/imported/w3c/web-platform-tests/url/urlsearchparams-getall-expected.txt
LayoutTests/imported/w3c/web-platform-tests/url/urlsearchparams-has-expected.txt
LayoutTests/imported/w3c/web-platform-tests/url/urlsearchparams-set-expected.txt
LayoutTests/imported/w3c/web-platform-tests/url/urlsearchparams-stringifier-expected.txt
LayoutTests/js/dom/global-constructors-attributes-dedicated-worker-expected.txt
LayoutTests/platform/mac-wk1/js/dom/global-constructors-attributes-expected.txt
LayoutTests/platform/mac/imported/w3c/web-platform-tests/XMLHttpRequest/setrequestheader-content-type-expected.txt
LayoutTests/platform/mac/js/dom/global-constructors-attributes-expected.txt
Source/WTF/ChangeLog
Source/WTF/wtf/text/StringView.cpp
Source/WTF/wtf/text/StringView.h
Source/WebCore/CMakeLists.txt
Source/WebCore/ChangeLog
Source/WebCore/DerivedSources.make
Source/WebCore/WebCore.xcodeproj/project.pbxproj
Source/WebCore/html/DOMURL.cpp
Source/WebCore/html/DOMURL.h
Source/WebCore/html/URLSearchParams.cpp [new file with mode: 0644]
Source/WebCore/html/URLSearchParams.h [new file with mode: 0644]
Source/WebCore/html/URLSearchParams.idl [new file with mode: 0644]
Source/WebCore/html/URLUtils.h
Source/WebCore/html/URLUtils.idl
Source/WebCore/platform/URLParser.cpp
Source/WebCore/platform/URLParser.h

index c6cb4d7df38c894b05faf24393da0453cc3f7fbe..c5d47603e336c9c51275a62635831d5488edf7ea 100644 (file)
@@ -1,3 +1,14 @@
+2016-09-13  Alex Christensen  <achristensen@webkit.org>
+
+        Implement URLSearchParams
+        https://bugs.webkit.org/show_bug.cgi?id=161920
+
+        Reviewed by Chris Dumez.
+
+        * js/dom/global-constructors-attributes-dedicated-worker-expected.txt:
+        * platform/mac-wk1/js/dom/global-constructors-attributes-expected.txt:
+        * platform/mac/imported/w3c/web-platform-tests/XMLHttpRequest/setrequestheader-content-type-expected.txt:
+
 2016-09-13  Jer Noble  <jer.noble@apple.com>
 
         [media-source] MediaSource.addSourceBuffer(null) should throw an exception
diff --git a/LayoutTests/fast/dom/DOMURL/searchparams-expected.txt b/LayoutTests/fast/dom/DOMURL/searchparams-expected.txt
new file mode 100644 (file)
index 0000000..d301fb3
--- /dev/null
@@ -0,0 +1,3 @@
+CONSOLE MESSAGE: line 8: PASS
+CONSOLE MESSAGE: line 11: PASS
+
diff --git a/LayoutTests/fast/dom/DOMURL/searchparams.html b/LayoutTests/fast/dom/DOMURL/searchparams.html
new file mode 100644 (file)
index 0000000..0f099d2
--- /dev/null
@@ -0,0 +1,12 @@
+<script>
+if (window.testRunner)
+    testRunner.dumpAsText();
+var u = new URL("http://example.com?q=foo");
+u.searchParams.foo = 1;
+if (window.GCController)
+       GCController.collect();
+console.log(u.searchParams.foo == 1 ? "PASS" : "FAIL");
+
+var x = new URLSearchParams("a=ß");
+console.log(x == "a=%C3%83%C5%B8" ? "PASS" : "FAIL");
+</script>
index 5fa93200522f1c0450d10cb562d4d246be870c49..4306fd6fd1d9517bfe56160a91daa69133b96b71 100644 (file)
@@ -1,3 +1,24 @@
+2016-09-13  Alex Christensen  <achristensen@webkit.org>
+
+        Implement URLSearchParams
+        https://bugs.webkit.org/show_bug.cgi?id=161920
+
+        Reviewed by Chris Dumez.
+
+        * web-platform-tests/XMLHttpRequest/send-usp-expected.txt:
+        * web-platform-tests/fetch/api/request/request-init-002-expected.txt:
+        * web-platform-tests/fetch/api/response/response-init-002-expected.txt:
+        * web-platform-tests/url/interfaces-expected.txt:
+        * web-platform-tests/url/url-constructor-expected.txt:
+        * web-platform-tests/url/urlsearchparams-append-expected.txt:
+        * web-platform-tests/url/urlsearchparams-constructor-expected.txt:
+        * web-platform-tests/url/urlsearchparams-delete-expected.txt:
+        * web-platform-tests/url/urlsearchparams-get-expected.txt:
+        * web-platform-tests/url/urlsearchparams-getall-expected.txt:
+        * web-platform-tests/url/urlsearchparams-has-expected.txt:
+        * web-platform-tests/url/urlsearchparams-set-expected.txt:
+        * web-platform-tests/url/urlsearchparams-stringifier-expected.txt:
+
 2016-09-13  Chris Dumez  <cdumez@apple.com>
 
         Drop support for <isindex>
index 5db987e6352082224fd2b1d205b37ce2c567faa1..b9c1099b79da7954891579851da8473fc1936cea 100644 (file)
-CONSOLE MESSAGE: line 43: ReferenceError: Can't find variable: URLSearchParams
 
-Harness Error (FAIL), message = ReferenceError: Can't find variable: URLSearchParams
-
-NOTRUN Overall fetch with URLSearchParams 
-NOTRUN XMLHttpRequest.send(URLSearchParams) (0) 
-NOTRUN XMLHttpRequest.send(URLSearchParams) (1) 
-NOTRUN XMLHttpRequest.send(URLSearchParams) (2) 
-NOTRUN XMLHttpRequest.send(URLSearchParams) (3) 
-NOTRUN XMLHttpRequest.send(URLSearchParams) (4) 
-NOTRUN XMLHttpRequest.send(URLSearchParams) (5) 
-NOTRUN XMLHttpRequest.send(URLSearchParams) (6) 
-NOTRUN XMLHttpRequest.send(URLSearchParams) (7) 
-NOTRUN XMLHttpRequest.send(URLSearchParams) (8) 
-NOTRUN XMLHttpRequest.send(URLSearchParams) (9) 
-NOTRUN XMLHttpRequest.send(URLSearchParams) (10) 
-NOTRUN XMLHttpRequest.send(URLSearchParams) (11) 
-NOTRUN XMLHttpRequest.send(URLSearchParams) (12) 
-NOTRUN XMLHttpRequest.send(URLSearchParams) (13) 
-NOTRUN XMLHttpRequest.send(URLSearchParams) (14) 
-NOTRUN XMLHttpRequest.send(URLSearchParams) (15) 
-NOTRUN XMLHttpRequest.send(URLSearchParams) (16) 
-NOTRUN XMLHttpRequest.send(URLSearchParams) (17) 
-NOTRUN XMLHttpRequest.send(URLSearchParams) (18) 
-NOTRUN XMLHttpRequest.send(URLSearchParams) (19) 
-NOTRUN XMLHttpRequest.send(URLSearchParams) (20) 
-NOTRUN XMLHttpRequest.send(URLSearchParams) (21) 
-NOTRUN XMLHttpRequest.send(URLSearchParams) (22) 
-NOTRUN XMLHttpRequest.send(URLSearchParams) (23) 
-NOTRUN XMLHttpRequest.send(URLSearchParams) (24) 
-NOTRUN XMLHttpRequest.send(URLSearchParams) (25) 
-NOTRUN XMLHttpRequest.send(URLSearchParams) (26) 
-NOTRUN XMLHttpRequest.send(URLSearchParams) (27) 
-NOTRUN XMLHttpRequest.send(URLSearchParams) (28) 
-NOTRUN XMLHttpRequest.send(URLSearchParams) (29) 
-NOTRUN XMLHttpRequest.send(URLSearchParams) (30) 
-NOTRUN XMLHttpRequest.send(URLSearchParams) (31) 
-NOTRUN XMLHttpRequest.send(URLSearchParams) (32) 
-NOTRUN XMLHttpRequest.send(URLSearchParams) (33) 
-NOTRUN XMLHttpRequest.send(URLSearchParams) (34) 
-NOTRUN XMLHttpRequest.send(URLSearchParams) (35) 
-NOTRUN XMLHttpRequest.send(URLSearchParams) (36) 
-NOTRUN XMLHttpRequest.send(URLSearchParams) (37) 
-NOTRUN XMLHttpRequest.send(URLSearchParams) (38) 
-NOTRUN XMLHttpRequest.send(URLSearchParams) (39) 
-NOTRUN XMLHttpRequest.send(URLSearchParams) (40) 
-NOTRUN XMLHttpRequest.send(URLSearchParams) (41) 
-NOTRUN XMLHttpRequest.send(URLSearchParams) (42) 
-NOTRUN XMLHttpRequest.send(URLSearchParams) (43) 
-NOTRUN XMLHttpRequest.send(URLSearchParams) (44) 
-NOTRUN XMLHttpRequest.send(URLSearchParams) (45) 
-NOTRUN XMLHttpRequest.send(URLSearchParams) (46) 
-NOTRUN XMLHttpRequest.send(URLSearchParams) (47) 
-NOTRUN XMLHttpRequest.send(URLSearchParams) (48) 
-NOTRUN XMLHttpRequest.send(URLSearchParams) (49) 
-NOTRUN XMLHttpRequest.send(URLSearchParams) (50) 
-NOTRUN XMLHttpRequest.send(URLSearchParams) (51) 
-NOTRUN XMLHttpRequest.send(URLSearchParams) (52) 
-NOTRUN XMLHttpRequest.send(URLSearchParams) (53) 
-NOTRUN XMLHttpRequest.send(URLSearchParams) (54) 
-NOTRUN XMLHttpRequest.send(URLSearchParams) (55) 
-NOTRUN XMLHttpRequest.send(URLSearchParams) (56) 
-NOTRUN XMLHttpRequest.send(URLSearchParams) (57) 
-NOTRUN XMLHttpRequest.send(URLSearchParams) (58) 
-NOTRUN XMLHttpRequest.send(URLSearchParams) (59) 
-NOTRUN XMLHttpRequest.send(URLSearchParams) (60) 
-NOTRUN XMLHttpRequest.send(URLSearchParams) (61) 
-NOTRUN XMLHttpRequest.send(URLSearchParams) (62) 
-NOTRUN XMLHttpRequest.send(URLSearchParams) (63) 
-NOTRUN XMLHttpRequest.send(URLSearchParams) (64) 
-NOTRUN XMLHttpRequest.send(URLSearchParams) (65) 
-NOTRUN XMLHttpRequest.send(URLSearchParams) (66) 
-NOTRUN XMLHttpRequest.send(URLSearchParams) (67) 
-NOTRUN XMLHttpRequest.send(URLSearchParams) (68) 
-NOTRUN XMLHttpRequest.send(URLSearchParams) (69) 
-NOTRUN XMLHttpRequest.send(URLSearchParams) (70) 
-NOTRUN XMLHttpRequest.send(URLSearchParams) (71) 
-NOTRUN XMLHttpRequest.send(URLSearchParams) (72) 
-NOTRUN XMLHttpRequest.send(URLSearchParams) (73) 
-NOTRUN XMLHttpRequest.send(URLSearchParams) (74) 
-NOTRUN XMLHttpRequest.send(URLSearchParams) (75) 
-NOTRUN XMLHttpRequest.send(URLSearchParams) (76) 
-NOTRUN XMLHttpRequest.send(URLSearchParams) (77) 
-NOTRUN XMLHttpRequest.send(URLSearchParams) (78) 
-NOTRUN XMLHttpRequest.send(URLSearchParams) (79) 
-NOTRUN XMLHttpRequest.send(URLSearchParams) (80) 
-NOTRUN XMLHttpRequest.send(URLSearchParams) (81) 
-NOTRUN XMLHttpRequest.send(URLSearchParams) (82) 
-NOTRUN XMLHttpRequest.send(URLSearchParams) (83) 
-NOTRUN XMLHttpRequest.send(URLSearchParams) (84) 
-NOTRUN XMLHttpRequest.send(URLSearchParams) (85) 
-NOTRUN XMLHttpRequest.send(URLSearchParams) (86) 
-NOTRUN XMLHttpRequest.send(URLSearchParams) (87) 
-NOTRUN XMLHttpRequest.send(URLSearchParams) (88) 
-NOTRUN XMLHttpRequest.send(URLSearchParams) (89) 
-NOTRUN XMLHttpRequest.send(URLSearchParams) (90) 
-NOTRUN XMLHttpRequest.send(URLSearchParams) (91) 
-NOTRUN XMLHttpRequest.send(URLSearchParams) (92) 
-NOTRUN XMLHttpRequest.send(URLSearchParams) (93) 
-NOTRUN XMLHttpRequest.send(URLSearchParams) (94) 
-NOTRUN XMLHttpRequest.send(URLSearchParams) (95) 
-NOTRUN XMLHttpRequest.send(URLSearchParams) (96) 
-NOTRUN XMLHttpRequest.send(URLSearchParams) (97) 
-NOTRUN XMLHttpRequest.send(URLSearchParams) (98) 
-NOTRUN XMLHttpRequest.send(URLSearchParams) (99) 
-NOTRUN XMLHttpRequest.send(URLSearchParams) (100) 
-NOTRUN XMLHttpRequest.send(URLSearchParams) (101) 
-NOTRUN XMLHttpRequest.send(URLSearchParams) (102) 
-NOTRUN XMLHttpRequest.send(URLSearchParams) (103) 
-NOTRUN XMLHttpRequest.send(URLSearchParams) (104) 
-NOTRUN XMLHttpRequest.send(URLSearchParams) (105) 
-NOTRUN XMLHttpRequest.send(URLSearchParams) (106) 
-NOTRUN XMLHttpRequest.send(URLSearchParams) (107) 
-NOTRUN XMLHttpRequest.send(URLSearchParams) (108) 
-NOTRUN XMLHttpRequest.send(URLSearchParams) (109) 
-NOTRUN XMLHttpRequest.send(URLSearchParams) (110) 
-NOTRUN XMLHttpRequest.send(URLSearchParams) (111) 
-NOTRUN XMLHttpRequest.send(URLSearchParams) (112) 
-NOTRUN XMLHttpRequest.send(URLSearchParams) (113) 
-NOTRUN XMLHttpRequest.send(URLSearchParams) (114) 
-NOTRUN XMLHttpRequest.send(URLSearchParams) (115) 
-NOTRUN XMLHttpRequest.send(URLSearchParams) (116) 
-NOTRUN XMLHttpRequest.send(URLSearchParams) (117) 
-NOTRUN XMLHttpRequest.send(URLSearchParams) (118) 
-NOTRUN XMLHttpRequest.send(URLSearchParams) (119) 
-NOTRUN XMLHttpRequest.send(URLSearchParams) (120) 
-NOTRUN XMLHttpRequest.send(URLSearchParams) (121) 
-NOTRUN XMLHttpRequest.send(URLSearchParams) (122) 
-NOTRUN XMLHttpRequest.send(URLSearchParams) (123) 
-NOTRUN XMLHttpRequest.send(URLSearchParams) (124) 
-NOTRUN XMLHttpRequest.send(URLSearchParams) (125) 
-NOTRUN XMLHttpRequest.send(URLSearchParams) (126) 
-NOTRUN XMLHttpRequest.send(URLSearchParams) (127) 
+PASS Overall fetch with URLSearchParams 
+PASS XMLHttpRequest.send(URLSearchParams) (0) 
+PASS XMLHttpRequest.send(URLSearchParams) (1) 
+PASS XMLHttpRequest.send(URLSearchParams) (2) 
+PASS XMLHttpRequest.send(URLSearchParams) (3) 
+PASS XMLHttpRequest.send(URLSearchParams) (4) 
+PASS XMLHttpRequest.send(URLSearchParams) (5) 
+PASS XMLHttpRequest.send(URLSearchParams) (6) 
+PASS XMLHttpRequest.send(URLSearchParams) (7) 
+PASS XMLHttpRequest.send(URLSearchParams) (8) 
+PASS XMLHttpRequest.send(URLSearchParams) (9) 
+PASS XMLHttpRequest.send(URLSearchParams) (10) 
+PASS XMLHttpRequest.send(URLSearchParams) (11) 
+PASS XMLHttpRequest.send(URLSearchParams) (12) 
+PASS XMLHttpRequest.send(URLSearchParams) (13) 
+PASS XMLHttpRequest.send(URLSearchParams) (14) 
+PASS XMLHttpRequest.send(URLSearchParams) (15) 
+PASS XMLHttpRequest.send(URLSearchParams) (16) 
+PASS XMLHttpRequest.send(URLSearchParams) (17) 
+PASS XMLHttpRequest.send(URLSearchParams) (18) 
+PASS XMLHttpRequest.send(URLSearchParams) (19) 
+PASS XMLHttpRequest.send(URLSearchParams) (20) 
+PASS XMLHttpRequest.send(URLSearchParams) (21) 
+PASS XMLHttpRequest.send(URLSearchParams) (22) 
+PASS XMLHttpRequest.send(URLSearchParams) (23) 
+PASS XMLHttpRequest.send(URLSearchParams) (24) 
+PASS XMLHttpRequest.send(URLSearchParams) (25) 
+PASS XMLHttpRequest.send(URLSearchParams) (26) 
+PASS XMLHttpRequest.send(URLSearchParams) (27) 
+PASS XMLHttpRequest.send(URLSearchParams) (28) 
+PASS XMLHttpRequest.send(URLSearchParams) (29) 
+PASS XMLHttpRequest.send(URLSearchParams) (30) 
+PASS XMLHttpRequest.send(URLSearchParams) (31) 
+PASS XMLHttpRequest.send(URLSearchParams) (32) 
+PASS XMLHttpRequest.send(URLSearchParams) (33) 
+PASS XMLHttpRequest.send(URLSearchParams) (34) 
+PASS XMLHttpRequest.send(URLSearchParams) (35) 
+PASS XMLHttpRequest.send(URLSearchParams) (36) 
+PASS XMLHttpRequest.send(URLSearchParams) (37) 
+PASS XMLHttpRequest.send(URLSearchParams) (38) 
+PASS XMLHttpRequest.send(URLSearchParams) (39) 
+PASS XMLHttpRequest.send(URLSearchParams) (40) 
+PASS XMLHttpRequest.send(URLSearchParams) (41) 
+PASS XMLHttpRequest.send(URLSearchParams) (42) 
+PASS XMLHttpRequest.send(URLSearchParams) (43) 
+PASS XMLHttpRequest.send(URLSearchParams) (44) 
+PASS XMLHttpRequest.send(URLSearchParams) (45) 
+PASS XMLHttpRequest.send(URLSearchParams) (46) 
+PASS XMLHttpRequest.send(URLSearchParams) (47) 
+PASS XMLHttpRequest.send(URLSearchParams) (48) 
+PASS XMLHttpRequest.send(URLSearchParams) (49) 
+PASS XMLHttpRequest.send(URLSearchParams) (50) 
+PASS XMLHttpRequest.send(URLSearchParams) (51) 
+PASS XMLHttpRequest.send(URLSearchParams) (52) 
+PASS XMLHttpRequest.send(URLSearchParams) (53) 
+PASS XMLHttpRequest.send(URLSearchParams) (54) 
+PASS XMLHttpRequest.send(URLSearchParams) (55) 
+PASS XMLHttpRequest.send(URLSearchParams) (56) 
+PASS XMLHttpRequest.send(URLSearchParams) (57) 
+PASS XMLHttpRequest.send(URLSearchParams) (58) 
+PASS XMLHttpRequest.send(URLSearchParams) (59) 
+PASS XMLHttpRequest.send(URLSearchParams) (60) 
+PASS XMLHttpRequest.send(URLSearchParams) (61) 
+PASS XMLHttpRequest.send(URLSearchParams) (62) 
+PASS XMLHttpRequest.send(URLSearchParams) (63) 
+PASS XMLHttpRequest.send(URLSearchParams) (64) 
+PASS XMLHttpRequest.send(URLSearchParams) (65) 
+PASS XMLHttpRequest.send(URLSearchParams) (66) 
+PASS XMLHttpRequest.send(URLSearchParams) (67) 
+PASS XMLHttpRequest.send(URLSearchParams) (68) 
+PASS XMLHttpRequest.send(URLSearchParams) (69) 
+PASS XMLHttpRequest.send(URLSearchParams) (70) 
+PASS XMLHttpRequest.send(URLSearchParams) (71) 
+PASS XMLHttpRequest.send(URLSearchParams) (72) 
+PASS XMLHttpRequest.send(URLSearchParams) (73) 
+PASS XMLHttpRequest.send(URLSearchParams) (74) 
+PASS XMLHttpRequest.send(URLSearchParams) (75) 
+PASS XMLHttpRequest.send(URLSearchParams) (76) 
+PASS XMLHttpRequest.send(URLSearchParams) (77) 
+PASS XMLHttpRequest.send(URLSearchParams) (78) 
+PASS XMLHttpRequest.send(URLSearchParams) (79) 
+PASS XMLHttpRequest.send(URLSearchParams) (80) 
+PASS XMLHttpRequest.send(URLSearchParams) (81) 
+PASS XMLHttpRequest.send(URLSearchParams) (82) 
+PASS XMLHttpRequest.send(URLSearchParams) (83) 
+PASS XMLHttpRequest.send(URLSearchParams) (84) 
+PASS XMLHttpRequest.send(URLSearchParams) (85) 
+PASS XMLHttpRequest.send(URLSearchParams) (86) 
+PASS XMLHttpRequest.send(URLSearchParams) (87) 
+PASS XMLHttpRequest.send(URLSearchParams) (88) 
+PASS XMLHttpRequest.send(URLSearchParams) (89) 
+PASS XMLHttpRequest.send(URLSearchParams) (90) 
+PASS XMLHttpRequest.send(URLSearchParams) (91) 
+PASS XMLHttpRequest.send(URLSearchParams) (92) 
+PASS XMLHttpRequest.send(URLSearchParams) (93) 
+PASS XMLHttpRequest.send(URLSearchParams) (94) 
+PASS XMLHttpRequest.send(URLSearchParams) (95) 
+PASS XMLHttpRequest.send(URLSearchParams) (96) 
+PASS XMLHttpRequest.send(URLSearchParams) (97) 
+PASS XMLHttpRequest.send(URLSearchParams) (98) 
+PASS XMLHttpRequest.send(URLSearchParams) (99) 
+PASS XMLHttpRequest.send(URLSearchParams) (100) 
+PASS XMLHttpRequest.send(URLSearchParams) (101) 
+PASS XMLHttpRequest.send(URLSearchParams) (102) 
+PASS XMLHttpRequest.send(URLSearchParams) (103) 
+PASS XMLHttpRequest.send(URLSearchParams) (104) 
+PASS XMLHttpRequest.send(URLSearchParams) (105) 
+PASS XMLHttpRequest.send(URLSearchParams) (106) 
+PASS XMLHttpRequest.send(URLSearchParams) (107) 
+PASS XMLHttpRequest.send(URLSearchParams) (108) 
+PASS XMLHttpRequest.send(URLSearchParams) (109) 
+PASS XMLHttpRequest.send(URLSearchParams) (110) 
+PASS XMLHttpRequest.send(URLSearchParams) (111) 
+PASS XMLHttpRequest.send(URLSearchParams) (112) 
+PASS XMLHttpRequest.send(URLSearchParams) (113) 
+PASS XMLHttpRequest.send(URLSearchParams) (114) 
+PASS XMLHttpRequest.send(URLSearchParams) (115) 
+PASS XMLHttpRequest.send(URLSearchParams) (116) 
+PASS XMLHttpRequest.send(URLSearchParams) (117) 
+PASS XMLHttpRequest.send(URLSearchParams) (118) 
+PASS XMLHttpRequest.send(URLSearchParams) (119) 
+PASS XMLHttpRequest.send(URLSearchParams) (120) 
+PASS XMLHttpRequest.send(URLSearchParams) (121) 
+PASS XMLHttpRequest.send(URLSearchParams) (122) 
+PASS XMLHttpRequest.send(URLSearchParams) (123) 
+PASS XMLHttpRequest.send(URLSearchParams) (124) 
+PASS XMLHttpRequest.send(URLSearchParams) (125) 
+PASS XMLHttpRequest.send(URLSearchParams) (126) 
+PASS XMLHttpRequest.send(URLSearchParams) (127) 
 
index 13ec4eb237cd2e8291cc1edadaf00f76e9852adb..88c5a7b20e7c7e40d08dd36bb1fbed55f87b9109 100644 (file)
@@ -5,5 +5,5 @@ PASS Initialize Request's body with null
 PASS Initialize Request's body with application/octet-binary 
 FAIL Initialize Request's body with multipart/form-data promise_test: Unhandled rejection with value: undefined
 PASS Initialize Request's body with text/plain;charset=UTF-8 
-FAIL Initialize Request's body with application/x-www-form-urlencoded;charset=UTF-8 promise_test: Unhandled rejection with value: "URLSearchParams not supported"
+FAIL Initialize Request's body with application/x-www-form-urlencoded;charset=UTF-8 Type error
 
index a42a0105e85c342daae73fe17a8f9ce191b11290..d0efa7cf07f20a262537444e53bdbb0c9d9213a2 100644 (file)
@@ -2,7 +2,7 @@
 PASS Initialize Response with headers values 
 PASS Initialize Response's body with application/octet-binary 
 FAIL Initialize Response's body with multipart/form-data promise_test: Unhandled rejection with value: undefined
-FAIL Initialize Response's body with application/x-www-form-urlencoded;charset=UTF-8 assert_true: Content-Type header should be "application/x-www-form-urlencoded;charset=UTF-8"  expected true got false
+FAIL Initialize Response's body with application/x-www-form-urlencoded;charset=UTF-8 assert_true: Content-Type header should be "application/x-www-form-urlencoded;charset=UTF-8"  expected true got null
 PASS Initialize Response's body with text/plain;charset=UTF-8 
 PASS Read Response's body as readableStream 
 PASS Testing empty Response Content-Type header 
index 849cc4a01145b00a988eba03b3bb42e94dcfc4c3..b53dec6e5b72557416d2189f7bfeb8664c5903ce 100644 (file)
@@ -19,7 +19,7 @@ PASS URL interface: attribute hostname
 PASS URL interface: attribute port 
 PASS URL interface: attribute pathname 
 PASS URL interface: attribute search 
-FAIL URL interface: attribute searchParams assert_true: The prototype object must have a property "searchParams" expected true got false
+PASS URL interface: attribute searchParams 
 PASS URL interface: attribute hash 
 PASS URL must be primary interface of new URL("http://foo") 
 PASS Stringification of new URL("http://foo") 
@@ -37,18 +37,18 @@ PASS URL interface: new URL("http://foo") must inherit property "hostname" with
 PASS URL interface: new URL("http://foo") must inherit property "port" with the proper type (9) 
 PASS URL interface: new URL("http://foo") must inherit property "pathname" with the proper type (10) 
 PASS URL interface: new URL("http://foo") must inherit property "search" with the proper type (11) 
-FAIL URL interface: new URL("http://foo") must inherit property "searchParams" with the proper type (12) assert_inherits: property "searchParams" not found in prototype chain
+PASS URL interface: new URL("http://foo") must inherit property "searchParams" with the proper type (12) 
 PASS URL interface: new URL("http://foo") must inherit property "hash" with the proper type (13) 
-FAIL URLSearchParams interface: existence and properties of interface object assert_own_property: self does not have own property "URLSearchParams" expected property "URLSearchParams" missing
-FAIL URLSearchParams interface object length assert_own_property: self does not have own property "URLSearchParams" expected property "URLSearchParams" missing
-FAIL URLSearchParams interface object name assert_own_property: self does not have own property "URLSearchParams" expected property "URLSearchParams" missing
-FAIL URLSearchParams interface: existence and properties of interface prototype object assert_own_property: self does not have own property "URLSearchParams" expected property "URLSearchParams" missing
-FAIL URLSearchParams interface: existence and properties of interface prototype object's "constructor" property assert_own_property: self does not have own property "URLSearchParams" expected property "URLSearchParams" missing
-FAIL URLSearchParams interface: operation append(USVString,USVString) assert_own_property: self does not have own property "URLSearchParams" expected property "URLSearchParams" missing
-FAIL URLSearchParams interface: operation delete(USVString) assert_own_property: self does not have own property "URLSearchParams" expected property "URLSearchParams" missing
-FAIL URLSearchParams interface: operation get(USVString) assert_own_property: self does not have own property "URLSearchParams" expected property "URLSearchParams" missing
-FAIL URLSearchParams interface: operation getAll(USVString) assert_own_property: self does not have own property "URLSearchParams" expected property "URLSearchParams" missing
-FAIL URLSearchParams interface: operation has(USVString) assert_own_property: self does not have own property "URLSearchParams" expected property "URLSearchParams" missing
-FAIL URLSearchParams interface: operation set(USVString,USVString) assert_own_property: self does not have own property "URLSearchParams" expected property "URLSearchParams" missing
-FAIL URLSearchParams interface: stringifier assert_own_property: self does not have own property "URLSearchParams" expected property "URLSearchParams" missing
+PASS URLSearchParams interface: existence and properties of interface object 
+PASS URLSearchParams interface object length 
+PASS URLSearchParams interface object name 
+PASS URLSearchParams interface: existence and properties of interface prototype object 
+PASS URLSearchParams interface: existence and properties of interface prototype object's "constructor" property 
+PASS URLSearchParams interface: operation append(USVString,USVString) 
+PASS URLSearchParams interface: operation delete(USVString) 
+PASS URLSearchParams interface: operation get(USVString) 
+PASS URLSearchParams interface: operation getAll(USVString) 
+PASS URLSearchParams interface: operation has(USVString) 
+PASS URLSearchParams interface: operation set(USVString,USVString) 
+PASS URLSearchParams interface: stringifier 
 
index 2bda6ab0fcd8af1d48e43659d4007fbe2653da55..017dfe8abb4490eecaede8898fa54611d7f88e5b 100644 (file)
@@ -1,8 +1,8 @@
 
-FAIL URL.searchParams getter assert_true: expected true got false
-FAIL URL.searchParams updating, clearing assert_true: expected true got false
-FAIL URL.searchParams setter, invalid values assert_throws: function "function () { url.searchParams = new URLSearchParams(urlS..." threw object "ReferenceError: Can't find variable: URLSearchParams" ("ReferenceError") expected object "TypeError" ("TypeError")
-FAIL URL.searchParams and URL.search setters, update propagation assert_true: expected true got false
+PASS URL.searchParams getter 
+FAIL URL.searchParams updating, clearing assert_equals: expected "" but got "a=b"
+PASS URL.searchParams setter, invalid values 
+FAIL URL.searchParams and URL.search setters, update propagation assert_equals: expected "e=f&g=h" but got "a=b&c=d"
 PASS Loading data… 
 PASS Parsing: <http://example  .
 org> against <http://example.org/foo/bar> 
@@ -349,9 +349,9 @@ e
 ry#f   r
 a
 g> against <about:blank> 
-FAIL Parsing: <?a=b&c=d> against <http://example.org/foo/bar> assert_true: expected true got false
-FAIL Parsing: <??a=b&c=d> against <http://example.org/foo/bar> assert_true: expected true got false
-FAIL Parsing: <http:> against <http://example.org/foo/bar> assert_true: expected true got false
+PASS Parsing: <?a=b&c=d> against <http://example.org/foo/bar> 
+FAIL Parsing: <??a=b&c=d> against <http://example.org/foo/bar> assert_equals: searchParams expected "%3Fa=b&c=d" but got "a=b&c=d"
+PASS Parsing: <http:> against <http://example.org/foo/bar> 
 FAIL Parsing: <http:> against <https://example.org/foo/bar> assert_throws: function "function () {
           bURL(expected.input, expected.bas..." did not throw
 FAIL Parsing: <sc:> against <https://example.org/foo/bar> assert_equals: origin expected "null" but got "sc://"
index 7a1814ed4fa7255beadfd3f47eb5197bb65bf6b3..099b11c9ff2306406dfa07362c42e6ff70492444 100644 (file)
@@ -1,6 +1,6 @@
 
-FAIL Append same name Can't find variable: URLSearchParams
-FAIL Append empty strings Can't find variable: URLSearchParams
-FAIL Append null Can't find variable: URLSearchParams
-FAIL Append multiple Can't find variable: URLSearchParams
+PASS Append same name 
+PASS Append empty strings 
+PASS Append null 
+PASS Append multiple 
 
index 71d9ef07f4e99510f725a560f26f62686d41ae83..7a165b30d3b1fa2ab047d4bb8777658dfb00addf 100644 (file)
@@ -1,15 +1,15 @@
 
-FAIL Basic URLSearchParams construction Can't find variable: URLSearchParams
-FAIL URLSearchParams constructor, empty. assert_throws: Calling 'URLSearchParams' without 'new' should throw. function "function () { URLSearchParams(); }" threw object "ReferenceError: Can't find variable: URLSearchParams" ("ReferenceError") expected object "TypeError" ("TypeError")
-FAIL URLSearchParams constructor, string. Can't find variable: URLSearchParams
-FAIL URLSearchParams constructor, object. Can't find variable: URLSearchParams
-FAIL Parse + Can't find variable: URLSearchParams
-FAIL Parse space Can't find variable: URLSearchParams
-FAIL Parse %20 Can't find variable: URLSearchParams
-FAIL Parse \0 Can't find variable: URLSearchParams
-FAIL Parse %00 Can't find variable: URLSearchParams
-FAIL Parse βŽ„ Can't find variable: URLSearchParams
-FAIL Parse %e2%8e%84 Can't find variable: URLSearchParams
-FAIL Parse πŸ’© Can't find variable: URLSearchParams
-FAIL Parse %f0%9f%92%a9 Can't find variable: URLSearchParams
+PASS Basic URLSearchParams construction 
+PASS URLSearchParams constructor, empty. 
+PASS URLSearchParams constructor, string. 
+PASS URLSearchParams constructor, object. 
+PASS Parse + 
+PASS Parse space 
+PASS Parse %20 
+PASS Parse \0 
+PASS Parse %00 
+PASS Parse βŽ„ 
+PASS Parse %e2%8e%84 
+PASS Parse πŸ’© 
+PASS Parse %f0%9f%92%a9 
 
index 3ae250e418efd21e8d3fc42d17d478a7c73f184b..c1e9c5a2010b45d2ae08f7c4c1d54431c3f3f5bb 100644 (file)
@@ -1,4 +1,4 @@
 
-FAIL Delete basics Can't find variable: URLSearchParams
-FAIL Deleting appended multiple Can't find variable: URLSearchParams
+PASS Delete basics 
+PASS Deleting appended multiple 
 
index a944a5ab243a7e2ba78e5f70eeedb047f07218a1..f6b68497ab794e86e1e7d46610fd3cf4a3ec0af7 100644 (file)
@@ -1,4 +1,4 @@
 
-FAIL Get basics Can't find variable: URLSearchParams
-FAIL More get() basics Can't find variable: URLSearchParams
+PASS Get basics 
+PASS More get() basics 
 
index 9856e176c7c3241f97249e9c3ff8d51c154888f3..2b7ffd0af37adeee71100a01eea1f957874da2aa 100644 (file)
@@ -1,4 +1,4 @@
 
-FAIL getAll() basics Can't find variable: URLSearchParams
-FAIL getAll() multiples Can't find variable: URLSearchParams
+PASS getAll() basics 
+PASS getAll() multiples 
 
index 340709c39f53aeec35ddfcd7f2e4cdd337f43d05..98d9c2d96eebe3e2432dbf1382f6187418b2ffe2 100644 (file)
@@ -1,4 +1,4 @@
 
-FAIL Has basics Can't find variable: URLSearchParams
-FAIL has() following delete() Can't find variable: URLSearchParams
+PASS Has basics 
+PASS has() following delete() 
 
index a1ee62fe33e00508c345f8fdaf89626769788ef6..724adaf71978a4294c34c09ebb62531307374189 100644 (file)
@@ -1,4 +1,4 @@
 
-FAIL Set basics Can't find variable: URLSearchParams
-FAIL URLSearchParams.set Can't find variable: URLSearchParams
+PASS Set basics 
+PASS URLSearchParams.set 
 
index 75648d1d68d094ffa433580fb7d6ab327edc4964..6bb7e2b9725b3e7804b904a9f0c9ea93edff4c90 100644 (file)
@@ -1,14 +1,14 @@
 
-FAIL Serialize space Can't find variable: URLSearchParams
-FAIL Serialize empty value Can't find variable: URLSearchParams
-FAIL Serialize empty name Can't find variable: URLSearchParams
-FAIL Serialize empty name and value Can't find variable: URLSearchParams
-FAIL Serialize + Can't find variable: URLSearchParams
-FAIL Serialize = Can't find variable: URLSearchParams
-FAIL Serialize & Can't find variable: URLSearchParams
-FAIL Serialize *-._ Can't find variable: URLSearchParams
-FAIL Serialize % Can't find variable: URLSearchParams
-FAIL Serialize \0 Can't find variable: URLSearchParams
-FAIL Serialize πŸ’© Can't find variable: URLSearchParams
-FAIL URLSearchParams.toString Can't find variable: URLSearchParams
+PASS Serialize space 
+PASS Serialize empty value 
+PASS Serialize empty name 
+PASS Serialize empty name and value 
+PASS Serialize + 
+PASS Serialize = 
+PASS Serialize & 
+PASS Serialize *-._ 
+PASS Serialize % 
+PASS Serialize \0 
+PASS Serialize πŸ’© 
+PASS URLSearchParams.toString 
 
index 1db19846af67bba87e8c9b661812e63f5dbf20b7..79b23d01ed7c1c0e65522c69334b64c02ec8572d 100644 (file)
@@ -244,6 +244,11 @@ PASS [Worker] Object.getOwnPropertyDescriptor(global, 'URL').hasOwnProperty('get
 PASS [Worker] Object.getOwnPropertyDescriptor(global, 'URL').hasOwnProperty('set') is false
 PASS [Worker] Object.getOwnPropertyDescriptor(global, 'URL').enumerable is false
 PASS [Worker] Object.getOwnPropertyDescriptor(global, 'URL').configurable is true
+PASS [Worker] Object.getOwnPropertyDescriptor(global, 'URLSearchParams').value is URLSearchParams
+PASS [Worker] Object.getOwnPropertyDescriptor(global, 'URLSearchParams').hasOwnProperty('get') is false
+PASS [Worker] Object.getOwnPropertyDescriptor(global, 'URLSearchParams').hasOwnProperty('set') is false
+PASS [Worker] Object.getOwnPropertyDescriptor(global, 'URLSearchParams').enumerable is false
+PASS [Worker] Object.getOwnPropertyDescriptor(global, 'URLSearchParams').configurable is true
 PASS [Worker] Object.getOwnPropertyDescriptor(global, 'Uint16Array').value is Uint16Array
 PASS [Worker] Object.getOwnPropertyDescriptor(global, 'Uint16Array').hasOwnProperty('get') is false
 PASS [Worker] Object.getOwnPropertyDescriptor(global, 'Uint16Array').hasOwnProperty('set') is false
index a3e45a7604cdd0b9d392b213d8d6c3d79b0a5296..28964153ef604431744024990801400a484af48f 100644 (file)
@@ -2108,6 +2108,11 @@ PASS Object.getOwnPropertyDescriptor(global, 'URL').hasOwnProperty('get') is fal
 PASS Object.getOwnPropertyDescriptor(global, 'URL').hasOwnProperty('set') is false
 PASS Object.getOwnPropertyDescriptor(global, 'URL').enumerable is false
 PASS Object.getOwnPropertyDescriptor(global, 'URL').configurable is true
+PASS Object.getOwnPropertyDescriptor(global, 'URLSearchParams').value is URLSearchParams
+PASS Object.getOwnPropertyDescriptor(global, 'URLSearchParams').hasOwnProperty('get') is false
+PASS Object.getOwnPropertyDescriptor(global, 'URLSearchParams').hasOwnProperty('set') is false
+PASS Object.getOwnPropertyDescriptor(global, 'URLSearchParams').enumerable is false
+PASS Object.getOwnPropertyDescriptor(global, 'URLSearchParams').configurable is true
 PASS Object.getOwnPropertyDescriptor(global, 'Uint16Array').value is Uint16Array
 PASS Object.getOwnPropertyDescriptor(global, 'Uint16Array').hasOwnProperty('get') is false
 PASS Object.getOwnPropertyDescriptor(global, 'Uint16Array').hasOwnProperty('set') is false
index c491ccb29e5e60759eb0ab04f2784268d16bb871..41de5e6162c28541c55d948cd3853de7bb490c9c 100644 (file)
@@ -28,9 +28,9 @@ PASS ArrayBufferView request keeps setRequestHeader() Content-Type and charset
 PASS FormData request respects setRequestHeader("") 
 PASS FormData request has correct default Content-Type of "multipart/form-data;boundary=_" 
 PASS FormData request keeps setRequestHeader() Content-Type and charset 
-FAIL URLSearchParams respects setRequestHeader("") assert_unreached: Skipping test as could not create a URLSearchParams;  Reached unreachable code
-FAIL URLSearchParams request has correct default Content-Type of "application/x-www-form-urlencoded;charset=UTF-8" assert_unreached: Skipping test as could not create a URLSearchParams;  Reached unreachable code
-FAIL URLSearchParams request keeps setRequestHeader() Content-Type, with charset adjusted to UTF-8 assert_unreached: Skipping test as could not create a URLSearchParams;  Reached unreachable code
+PASS URLSearchParams respects setRequestHeader("") 
+FAIL URLSearchParams request has correct default Content-Type of "application/x-www-form-urlencoded;charset=UTF-8" assert_equals: expected "content-type: application/x-www-form-urlencoded;charset=utf-8" but got "content-type: text/plain;charset=utf-8"
+PASS URLSearchParams request keeps setRequestHeader() Content-Type, with charset adjusted to UTF-8 
 PASS ReadableStream request respects setRequestHeader("") 
 FAIL ReadableStream request with under type sends no Content-Type without setRequestHeader() call assert_equals: expected "" but got "content-type: text/plain;charset=utf-8"
 FAIL ReadableStream request keeps setRequestHeader() Content-Type and charset assert_equals: expected "content-type: application/xml;charset=ascii" but got "content-type: application/xml;charset=utf-8"
index c5894d57d8ed416995743a6dc5634d4daa55b9c6..065cd16d80abeed344d445a6059565c32d49c38d 100644 (file)
@@ -2123,6 +2123,11 @@ PASS Object.getOwnPropertyDescriptor(global, 'URL').hasOwnProperty('get') is fal
 PASS Object.getOwnPropertyDescriptor(global, 'URL').hasOwnProperty('set') is false
 PASS Object.getOwnPropertyDescriptor(global, 'URL').enumerable is false
 PASS Object.getOwnPropertyDescriptor(global, 'URL').configurable is true
+PASS Object.getOwnPropertyDescriptor(global, 'URLSearchParams').value is URLSearchParams
+PASS Object.getOwnPropertyDescriptor(global, 'URLSearchParams').hasOwnProperty('get') is false
+PASS Object.getOwnPropertyDescriptor(global, 'URLSearchParams').hasOwnProperty('set') is false
+PASS Object.getOwnPropertyDescriptor(global, 'URLSearchParams').enumerable is false
+PASS Object.getOwnPropertyDescriptor(global, 'URLSearchParams').configurable is true
 PASS Object.getOwnPropertyDescriptor(global, 'Uint16Array').value is Uint16Array
 PASS Object.getOwnPropertyDescriptor(global, 'Uint16Array').hasOwnProperty('get') is false
 PASS Object.getOwnPropertyDescriptor(global, 'Uint16Array').hasOwnProperty('set') is false
index 5a94886f31b870bb39150f087f69ab1f80fcd43e..58494072a88863168b45a3563de705c152e03aaf 100644 (file)
@@ -1,3 +1,13 @@
+2016-09-13  Alex Christensen  <achristensen@webkit.org>
+
+        Implement URLSearchParams
+        https://bugs.webkit.org/show_bug.cgi?id=161920
+
+        Reviewed by Chris Dumez.
+
+        * wtf/text/StringView.h:
+        (WTF::StringView::split): Added.
+
 2016-09-12  Filip Pizlo  <fpizlo@apple.com>
 
         ParkingLot is going to have a bad time with threads dying
index 1061aba189bb22d98f464a05d4b31929f6cee936..bf6cd4426b1805d895288e75a7f3639b70ed3946 100644 (file)
@@ -141,6 +141,21 @@ private:
     unsigned m_indexEnd;
 };
 
+Vector<StringView> StringView::split(UChar separator)
+{
+    Vector<StringView> result;
+    unsigned startPos = 0;
+    size_t endPos;
+    while ((endPos = find(separator, startPos)) != notFound) {
+        if (startPos != endPos)
+            result.append(substring(startPos, endPos - startPos));
+        startPos = endPos + 1;
+    }
+    if (startPos != length())
+        result.append(substring(startPos));
+    return result;
+}
+
 StringView::GraphemeClusters::Iterator::Iterator(const StringView& stringView, unsigned index)
     : m_impl(std::make_unique<Impl>(stringView, stringView.isNull() ? Nullopt : Optional<NonSharedCharacterBreakIterator>(NonSharedCharacterBreakIterator(stringView)), index))
 {
index a39ea07d207c955608154a1e4b85706a01660a39..d8cc26c8ff7e06ecd6e666abcff76923f41fad8b 100644 (file)
@@ -115,6 +115,7 @@ public:
     void getCharactersWithUpconvert(UChar*) const;
 
     StringView substring(unsigned start, unsigned length = std::numeric_limits<unsigned>::max()) const;
+    WTF_EXPORT_STRING_API Vector<StringView> split(UChar);
 
     size_t find(UChar, unsigned start = 0) const;
     size_t find(CharacterMatchFunction, unsigned start = 0) const;
index 6a8f62dc1dcdb6bdd6985dc6a9524bf4ea7d4315..ca669abebd75375f007ebb0d26d8284937c51ce7 100644 (file)
@@ -538,6 +538,7 @@ set(WebCore_NON_SVG_IDL_FILES
     html/RadioNodeList.idl
     html/TextMetrics.idl
     html/TimeRanges.idl
+    html/URLSearchParams.idl
     html/URLUtils.idl
     html/ValidityState.idl
     html/VoidCallback.idl
@@ -1750,6 +1751,7 @@ set(WebCore_SOURCES
     html/TimeRanges.cpp
     html/TypeAhead.cpp
     html/URLInputType.cpp
+    html/URLSearchParams.cpp
     html/ValidationMessage.cpp
     html/WeekInputType.cpp
 
index 518ba7eeeb832afeb99f8655906fbc7a26f5d23b..9c20016aef021a8f0f55fb144ded65a074f79490 100644 (file)
@@ -1,3 +1,43 @@
+2016-09-13  Alex Christensen  <achristensen@webkit.org>
+
+        Implement URLSearchParams
+        https://bugs.webkit.org/show_bug.cgi?id=161920
+
+        Reviewed by Chris Dumez.
+
+        Covered by newly passing web platform tests.
+
+        * CMakeLists.txt:
+        * DerivedSources.make:
+        * WebCore.xcodeproj/project.pbxproj:
+        * html/DOMURL.cpp:
+        (WebCore::DOMURL::setQuery):
+        (WebCore::DOMURL::searchParams):
+        * html/DOMURL.h:
+        * html/URLSearchParams.cpp: Added.
+        (WebCore::URLSearchParams::URLSearchParams):
+        (WebCore::URLSearchParams::get):
+        (WebCore::URLSearchParams::has):
+        (WebCore::URLSearchParams::set):
+        (WebCore::URLSearchParams::append):
+        (WebCore::URLSearchParams::getAll):
+        (WebCore::URLSearchParams::remove):
+        (WebCore::URLSearchParams::toString):
+        (WebCore::URLSearchParams::updateURL):
+        (WebCore::URLSearchParams::Iterator::Iterator):
+        * html/URLSearchParams.h: Added.
+        (WebCore::URLSearchParams::create):
+        (WebCore::URLSearchParams::createIterator):
+        * html/URLSearchParams.idl: Added.
+        * html/URLUtils.idl:
+        * platform/URLParser.cpp:
+        (WebCore::percentDecode):
+        (WebCore::URLParser::parseHost):
+        (WebCore::formURLDecode):
+        (WebCore::serializeURLEncodedForm):
+        (WebCore::URLParser::serialize):
+        * platform/URLParser.h:
+
 2016-09-12  Dean Jackson  <dino@apple.com>
 
         Replace RGBA32 with Color in member variables
index d689e011da2821e2914cd753a53a3786a8e7b7b0..38e98dd1b5cf688a86d91eb43ab1a464d1ddabd6 100644 (file)
@@ -447,6 +447,7 @@ JS_BINDING_IDLS = \
     $(WebCore)/html/RadioNodeList.idl \
     $(WebCore)/html/TextMetrics.idl \
     $(WebCore)/html/TimeRanges.idl \
+    $(WebCore)/html/URLSearchParams.idl \
     $(WebCore)/html/URLUtils.idl \
     $(WebCore)/html/ValidityState.idl \
     $(WebCore)/html/VoidCallback.idl \
index 8124dc6c204b83993ea674e0902b04cbb5190e87..96d6b5331432a3e7a245aa95d33c4f8a10a04273 100644 (file)
                5C4304B1191AC908000E2BC0 /* EXTShaderTextureLOD.h in Headers */ = {isa = PBXBuildFile; fileRef = 5C4304AE191AC908000E2BC0 /* EXTShaderTextureLOD.h */; };
                5C4304B5191AEF46000E2BC0 /* JSEXTShaderTextureLOD.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 5C4304B3191AEF46000E2BC0 /* JSEXTShaderTextureLOD.cpp */; };
                5C4304B6191AEF46000E2BC0 /* JSEXTShaderTextureLOD.h in Headers */ = {isa = PBXBuildFile; fileRef = 5C4304B4191AEF46000E2BC0 /* JSEXTShaderTextureLOD.h */; };
+               5C5381B21D87D4B200E2EBE6 /* URLSearchParams.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 5C5381B01D87D45700E2EBE6 /* URLSearchParams.cpp */; };
+               5C5381B51D87E08700E2EBE6 /* JSURLSearchParams.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 5C5381B31D87E08100E2EBE6 /* JSURLSearchParams.cpp */; };
                5C688AA11D380BF8000B54FA /* ThreadableWebSocketChannel.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 5C688AA01D380509000B54FA /* ThreadableWebSocketChannel.cpp */; };
                5C688AA31D3814BF000B54FA /* SocketProvider.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 5C688AA21D38126F000B54FA /* SocketProvider.cpp */; };
                5C6E65421D5CEFB900F7862E /* URLParser.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 5C6E653F1D5CEDC900F7862E /* URLParser.cpp */; };
                5C4304AF191AC908000E2BC0 /* EXTShaderTextureLOD.idl */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text; path = EXTShaderTextureLOD.idl; sourceTree = "<group>"; };
                5C4304B3191AEF46000E2BC0 /* JSEXTShaderTextureLOD.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = JSEXTShaderTextureLOD.cpp; sourceTree = "<group>"; };
                5C4304B4191AEF46000E2BC0 /* JSEXTShaderTextureLOD.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = JSEXTShaderTextureLOD.h; sourceTree = "<group>"; };
+               5C5381AE1D8791CA00E2EBE6 /* URLUtils.idl */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text; path = URLUtils.idl; sourceTree = "<group>"; };
+               5C5381AF1D8793E000E2EBE6 /* URLSearchParams.idl */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text; path = URLSearchParams.idl; sourceTree = "<group>"; };
+               5C5381B01D87D45700E2EBE6 /* URLSearchParams.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = URLSearchParams.cpp; sourceTree = "<group>"; };
+               5C5381B11D87D45700E2EBE6 /* URLSearchParams.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = URLSearchParams.h; sourceTree = "<group>"; };
+               5C5381B31D87E08100E2EBE6 /* JSURLSearchParams.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = JSURLSearchParams.cpp; path = JSURLSearchParams.cpp; sourceTree = "<group>"; };
+               5C5381B41D87E08100E2EBE6 /* JSURLSearchParams.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = JSURLSearchParams.h; path = JSURLSearchParams.h; sourceTree = "<group>"; };
                5C688AA01D380509000B54FA /* ThreadableWebSocketChannel.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = ThreadableWebSocketChannel.cpp; sourceTree = "<group>"; };
                5C688AA21D38126F000B54FA /* SocketProvider.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = SocketProvider.cpp; sourceTree = "<group>"; };
                5C6E653F1D5CEDC900F7862E /* URLParser.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = URLParser.cpp; sourceTree = "<group>"; };
                93EEC1EC09C2877700C515D1 /* html */ = {
                        isa = PBXGroup;
                        children = (
+                               5C5381B01D87D45700E2EBE6 /* URLSearchParams.cpp */,
+                               5C5381B11D87D45700E2EBE6 /* URLSearchParams.h */,
+                               5C5381AF1D8793E000E2EBE6 /* URLSearchParams.idl */,
+                               5C5381AE1D8791CA00E2EBE6 /* URLUtils.idl */,
                                49484FAE102CF01E00187DD3 /* canvas */,
                                1A88A90117553CD7000C74F9 /* forms */,
                                97C1F5511228558800EDE616 /* parser */,
                A83B79080CCAFF2B000B0825 /* HTML */ = {
                        isa = PBXGroup;
                        children = (
+                               5C5381B31D87E08100E2EBE6 /* JSURLSearchParams.cpp */,
+                               5C5381B41D87E08100E2EBE6 /* JSURLSearchParams.h */,
                                31A795C41888BAD100382F90 /* JSANGLEInstancedArrays.cpp */,
                                31A795C51888BAD100382F90 /* JSANGLEInstancedArrays.h */,
                                BE8EF03E171C8FF9009B48C3 /* JSAudioTrack.cpp */,
                                E164A2ED191AE6350010737D /* BlobDataFileReferenceMac.mm in Sources */,
                                E14A94D716DFDF950068DE82 /* BlobRegistry.cpp in Sources */,
                                2EDEF1F6121B0EFC00726DB2 /* BlobRegistryImpl.cpp in Sources */,
+                               5C5381B21D87D4B200E2EBE6 /* URLSearchParams.cpp in Sources */,
                                2EB4BCD2121F03E300EC4885 /* BlobResourceHandle.cpp in Sources */,
                                976D6C7E122B8A3D001FD1F7 /* BlobURL.cpp in Sources */,
                                58AEE2F418D4BCCF0022E7FE /* BorderEdge.cpp in Sources */,
                                B2FA3DBA0AB75A6F000E5AC4 /* JSSVGPathSegArcRel.cpp in Sources */,
                                B2FA3DBC0AB75A6F000E5AC4 /* JSSVGPathSegClosePath.cpp in Sources */,
                                B2FA3DBE0AB75A6F000E5AC4 /* JSSVGPathSegCurvetoCubicAbs.cpp in Sources */,
+                               5C5381B51D87E08700E2EBE6 /* JSURLSearchParams.cpp in Sources */,
                                B2FA3DC00AB75A6F000E5AC4 /* JSSVGPathSegCurvetoCubicRel.cpp in Sources */,
                                B2FA3DC20AB75A6F000E5AC4 /* JSSVGPathSegCurvetoCubicSmoothAbs.cpp in Sources */,
                                B2FA3DC40AB75A6F000E5AC4 /* JSSVGPathSegCurvetoCubicSmoothRel.cpp in Sources */,
index 2ce573a9c3fbe7288e63a1a26318cb418b1c99b4..4fb5e274f140093495e585624d0deeefa1f1065f 100644 (file)
@@ -34,6 +34,7 @@
 #include "PublicURLManager.h"
 #include "ResourceRequest.h"
 #include "ScriptExecutionContext.h"
+#include "URLSearchParams.h"
 #include <wtf/MainThread.h>
 
 namespace WebCore {
@@ -82,6 +83,11 @@ void DOMURL::setHref(const String& url)
     m_url = URL(m_baseURL, url);
 }
 
+void DOMURL::setQuery(const String& query)
+{
+    m_url.setQuery(query);
+}
+
 void DOMURL::setHref(const String& url, ExceptionCode& ec)
 {
     setHref(url);
@@ -107,6 +113,11 @@ String DOMURL::createPublicURL(ScriptExecutionContext& scriptExecutionContext, U
     return publicURL.string();
 }
 
+Ref<URLSearchParams> DOMURL::searchParams()
+{
+    return URLSearchParams::create(m_url.query(), this);
+}
+    
 void DOMURL::revokeObjectURL(ScriptExecutionContext& scriptExecutionContext, const String& urlString)
 {
     URL url(URL(), urlString);
index e096ccd51208a01388763ae4ccee86b547139caa..c6d7d30938afd04e33fc16bf0451aedbe235eb57 100644 (file)
@@ -24,8 +24,7 @@
  * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
  */
 
-#ifndef DOMURL_h
-#define DOMURL_h
+#pragma once
 
 #include "ExceptionCode.h"
 #include "URL.h"
@@ -39,9 +38,9 @@ namespace WebCore {
 class Blob;
 class ScriptExecutionContext;
 class URLRegistrable;
+class URLSearchParams;
 
 class DOMURL : public RefCounted<DOMURL>, public URLUtils<DOMURL> {
-
 public:
     static Ref<DOMURL> create(const String& url, const String& base, ExceptionCode&);
     static Ref<DOMURL> create(const String& url, const DOMURL& base, ExceptionCode&);
@@ -50,6 +49,9 @@ public:
     URL href() const { return m_url; }
     void setHref(const String& url);
     void setHref(const String&, ExceptionCode&);
+    void setQuery(const String&);
+
+    Ref<URLSearchParams> searchParams();
 
     static String createObjectURL(ScriptExecutionContext&, Blob*);
     static void revokeObjectURL(ScriptExecutionContext&, const String&);
@@ -66,5 +68,3 @@ private:
 };
 
 } // namespace WebCore
-
-#endif // DOMURL_h
diff --git a/Source/WebCore/html/URLSearchParams.cpp b/Source/WebCore/html/URLSearchParams.cpp
new file mode 100644 (file)
index 0000000..2a55b01
--- /dev/null
@@ -0,0 +1,120 @@
+/*
+ * Copyright (C) 2016 Apple Inc. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ *    notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ *    notice, this list of conditions and the following disclaimer in the
+ *    documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY APPLE INC. ``AS IS'' AND ANY
+ * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED.  IN NO EVENT SHALL APPLE INC. OR
+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
+ * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+ * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
+ * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+ * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#include "config.h"
+#include "URLSearchParams.h"
+
+#include "DOMURL.h"
+#include "URLParser.h"
+
+namespace WebCore {
+
+URLSearchParams::URLSearchParams(const String& init, DOMURL* associatedURL)
+    : m_associatedURL(associatedURL)
+    , m_pairs(init.startsWith('?') ? URLParser::parseURLEncodedForm(StringView(init).substring(1)) : URLParser::parseURLEncodedForm(init))
+{
+}
+
+URLSearchParams::URLSearchParams(const Vector<std::pair<String, String>>& pairs)
+    : m_pairs(pairs)
+{
+}
+
+String URLSearchParams::get(const String& name) const
+{
+    for (const auto& pair : m_pairs) {
+        if (pair.first == name)
+            return pair.second;
+    }
+    return String();
+}
+
+bool URLSearchParams::has(const String& name) const
+{
+    for (const auto& pair : m_pairs) {
+        if (pair.first == name)
+            return true;
+    }
+    return false;
+}
+
+void URLSearchParams::set(const String& name, const String& value)
+{
+    for (auto& pair : m_pairs) {
+        if (pair.first != name)
+            continue;
+        if (pair.second != value)
+            pair.second = value;
+        bool skippedFirstMatch = false;
+        m_pairs.removeAllMatching([&] (const auto& pair) {
+            bool nameMatches = pair.first == name;
+            if (nameMatches) {
+                if (skippedFirstMatch)
+                    return true;
+                skippedFirstMatch = true;
+            }
+            return false;
+        });
+        updateURL();
+        return;
+    }
+    m_pairs.append({name, value});
+    updateURL();
+}
+
+void URLSearchParams::append(const String& name, const String& value)
+{
+    m_pairs.append({name, value});
+    updateURL();
+}
+
+Vector<String> URLSearchParams::getAll(const String& name) const
+{
+    Vector<String> values;
+    values.reserveInitialCapacity(m_pairs.size());
+    for (const auto& pair : m_pairs) {
+        if (pair.first == name)
+            values.uncheckedAppend(pair.second);
+    }
+    return values;
+}
+
+void URLSearchParams::remove(const String& name)
+{
+    if (m_pairs.removeAllMatching([&] (const auto& pair) { return pair.first == name; }))
+        updateURL();
+}
+
+String URLSearchParams::toString()
+{
+    return URLParser::serialize(m_pairs);
+}
+
+void URLSearchParams::updateURL()
+{
+    if (m_associatedURL)
+        m_associatedURL->setQuery(URLParser::serialize(m_pairs));
+}
+
+}
diff --git a/Source/WebCore/html/URLSearchParams.h b/Source/WebCore/html/URLSearchParams.h
new file mode 100644 (file)
index 0000000..5ae292f
--- /dev/null
@@ -0,0 +1,56 @@
+/*
+ * Copyright (C) 2016 Apple Inc. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ *    notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ *    notice, this list of conditions and the following disclaimer in the
+ *    documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY APPLE INC. ``AS IS'' AND ANY
+ * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED.  IN NO EVENT SHALL APPLE INC. OR
+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
+ * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+ * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
+ * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+ * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#pragma once
+
+#include "DOMURL.h"
+#include <wtf/Vector.h>
+#include <wtf/text/WTFString.h>
+
+namespace WebCore {
+
+class URLSearchParams : public RefCounted<URLSearchParams> {
+public:
+    static Ref<URLSearchParams> create(const String& string, DOMURL* associatedURL = nullptr) { return adoptRef(*new URLSearchParams(string, associatedURL)); }
+    static Ref<URLSearchParams> create(const Vector<std::pair<String, String>>& pairs) { return adoptRef(*new URLSearchParams(pairs)); }
+
+    void append(const String& name, const String& value);
+    void remove(const String& name);
+    String get(const String& name) const;
+    Vector<String> getAll(const String& name) const;
+    bool has(const String& name) const;
+    void set(const String& name, const String& value);
+    String toString();
+    operator const Vector<std::pair<String, String>>&() { return m_pairs; }
+
+private:
+    URLSearchParams(const String&, DOMURL*);
+    explicit URLSearchParams(const Vector<std::pair<String, String>>&);
+    void updateURL();
+
+    RefPtr<DOMURL> m_associatedURL;
+    Vector<std::pair<String, String>> m_pairs;
+};
+
+}
diff --git a/Source/WebCore/html/URLSearchParams.idl b/Source/WebCore/html/URLSearchParams.idl
new file mode 100644 (file)
index 0000000..4f1013e
--- /dev/null
@@ -0,0 +1,43 @@
+/*
+ * Copyright (C) 2016 Apple Inc. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ *
+ * 1.  Redistributions of source code must retain the above copyright
+ *     notice, this list of conditions and the following disclaimer.
+ * 2.  Redistributions in binary form must reproduce the above copyright
+ *     notice, this list of conditions and the following disclaimer in the
+ *     documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY APPLE AND ITS CONTRIBUTORS "AS IS" AND ANY
+ * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
+ * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
+ * DISCLAIMED. IN NO EVENT SHALL APPLE OR ITS CONTRIBUTORS BE LIABLE FOR ANY
+ * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
+ * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
+ * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
+ * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
+ * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+[
+    // FIXME: This should use unions once they are supported
+    Constructor(optional USVString arg = ""),
+    Constructor(URLSearchParams init),
+    Exposed=(Window,Worker),
+    ImplementationLacksVTable,
+] interface URLSearchParams {
+    void append(USVString name, USVString value);
+    [ImplementedAs=remove] void delete(USVString name);
+    USVString? get(USVString name);
+    sequence<USVString> getAll(USVString name);
+    boolean has(USVString name);
+    void set(USVString name, USVString value);
+    // FIXME: This should be iterable.
+
+    // FIXME: This should just be stringifier once that is supported in the bindings generator
+    DOMString toString();
+};
index a08c0a31464afc5776200ef14312fbb8751faa90..38f6a28bd1e70bf345dbc98cd0f82de490bdde8e 100644 (file)
@@ -23,8 +23,7 @@
  * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
  */
 
-#ifndef URLUtils_h
-#define URLUtils_h
+#pragma once
 
 #include "SecurityOrigin.h"
 
@@ -293,5 +292,3 @@ void URLUtils<T>::setHash(const String& value)
 }
 
 } // namespace WebCore
-
-#endif // URLUtils_h
index ec858704534c5c0298c25e73a8e0ebc1bfefa6ae..abf6c34fddeacd1c43da4f2bc4b9a855866aaa60 100644 (file)
@@ -39,4 +39,5 @@
     attribute USVString pathname;
     attribute USVString hash;
     attribute USVString search;
+    [CachedAttribute] readonly attribute URLSearchParams searchParams;
 };
index 2195413e54f4e5a3694ab495812ba7f111bb96c4..f9190b782d0f409e8a4a0c98597aa437f7892af1 100644 (file)
@@ -115,7 +115,7 @@ static bool shouldPercentEncodeQueryByte(uint8_t byte)
 static void encodeQuery(const StringBuilder& source, StringBuilder& destination, const TextEncoding& encoding)
 {
     // FIXME: It is unclear in the spec what to do when encoding fails. The behavior should be specified and tested.
-    CString encoded = encoding.encode(StringView(source.toStringPreserveCapacity()), URLEncodedEntitiesForUnencodables);
+    CString encoded = encoding.encode(source.toStringPreserveCapacity(), URLEncodedEntitiesForUnencodables);
     const char* data = encoded.data();
     size_t length = encoded.length();
     for (size_t i = 0; i < length; ++i) {
@@ -1411,20 +1411,18 @@ static Optional<std::array<uint16_t, 8>> parseIPv6Host(StringView::CodePoints::I
     return address;
 }
 
-static String percentDecode(const String& input)
+// FIXME: This should return a CString.
+static String percentDecode(const LChar* input, size_t length)
 {
     StringBuilder output;
-    RELEASE_ASSERT(input.is8Bit());
-    const LChar* inputBytes = input.characters8();
-    size_t length = input.length();
     
     for (size_t i = 0; i < length; ++i) {
-        uint8_t byte = inputBytes[i];
+        uint8_t byte = input[i];
         if (byte != '%')
             output.append(byte);
         else if (i < length - 2) {
-            if (isASCIIHexDigit(inputBytes[i + 1]) && isASCIIHexDigit(inputBytes[i + 2])) {
-                output.append(toASCIIHexValue(inputBytes[i + 1], inputBytes[i + 2]));
+            if (isASCIIHexDigit(input[i + 1]) && isASCIIHexDigit(input[i + 2])) {
+                output.append(toASCIIHexValue(input[i + 1], input[i + 2]));
                 i += 2;
             } else
                 output.append(byte);
@@ -1553,7 +1551,8 @@ bool URLParser::parseHost(StringView::CodePoints::Iterator& iterator, const Stri
         // FIXME: Check error.
         utf8Encoded.append(buffer, offset);
     }
-    String percentDecoded = percentDecode(utf8Encoded.toStringPreserveCapacity());
+    RELEASE_ASSERT(utf8Encoded.is8Bit());
+    String percentDecoded = percentDecode(utf8Encoded.characters8(), utf8Encoded.length());
     RELEASE_ASSERT(percentDecoded.is8Bit());
     String domain = String::fromUTF8(percentDecoded.characters8(), percentDecoded.length());
     auto asciiDomain = domainToASCII(domain);
@@ -1585,6 +1584,70 @@ bool URLParser::parseHost(StringView::CodePoints::Iterator& iterator, const Stri
     return true;
 }
 
+static Optional<String> formURLDecode(StringView input)
+{
+    auto utf8 = input.utf8(StrictConversion);
+    if (utf8.isNull())
+        return Nullopt;
+    auto percentDecoded = percentDecode(reinterpret_cast<const LChar*>(utf8.data()), utf8.length());
+    RELEASE_ASSERT(percentDecoded.is8Bit());
+    return String::fromUTF8(percentDecoded.characters8(), percentDecoded.length());
+}
+
+auto URLParser::parseURLEncodedForm(StringView input) -> URLEncodedForm
+{
+    Vector<StringView> sequences = input.split('&');
+
+    URLEncodedForm output;
+    for (auto& bytes : sequences) {
+        auto valueStart = bytes.find('=');
+        if (valueStart == notFound) {
+            if (auto name = formURLDecode(bytes))
+                output.append({name.value().replace('+', 0x20), emptyString()});
+        } else {
+            auto name = formURLDecode(bytes.substring(0, valueStart));
+            auto value = formURLDecode(bytes.substring(valueStart + 1));
+            if (name && value)
+                output.append(std::make_pair(name.value().replace('+', 0x20), value.value().replace('+', 0x20)));
+        }
+    }
+    return output;
+}
+
+static void serializeURLEncodedForm(const String& input, StringBuilder& output)
+{
+    auto utf8 = input.utf8(StrictConversion);
+    const char* data = utf8.data();
+    for (size_t i = 0; i < utf8.length(); ++i) {
+        const char byte = data[i];
+        if (byte == 0x20)
+            output.append(0x2B);
+        else if (byte == 0x2A
+            || byte == 0x2D
+            || byte == 0x2E
+            || (byte >= 0x30 && byte <= 0x39)
+            || (byte >= 0x41 && byte <= 0x5A)
+            || byte == 0x5F
+            || (byte >= 0x61 && byte <= 0x7A))
+            output.append(byte);
+        else
+            percentEncode(byte, output);
+    }
+}
+    
+String URLParser::serialize(const URLEncodedForm& tuples)
+{
+    StringBuilder output;
+    for (auto& tuple : tuples) {
+        if (!output.isEmpty())
+            output.append('&');
+        serializeURLEncodedForm(tuple.first, output);
+        output.append('=');
+        serializeURLEncodedForm(tuple.second, output);
+    }
+    return output.toString();
+}
+
 bool URLParser::allValuesEqual(const URL& a, const URL& b)
 {
     // FIXME: m_cannotBeABaseURL is not compared because the old URL::parse did not use it,
index 9595eef986fbde3f1e1df9415c999c14889bc309..8d9638b5d95d6df8aa4ebfb3c99525a13237bf92 100644 (file)
@@ -39,6 +39,11 @@ public:
 
     WEBCORE_EXPORT static bool enabled();
     WEBCORE_EXPORT static void setEnabled(bool);
+    
+    typedef Vector<std::pair<String, String>> URLEncodedForm;
+    static URLEncodedForm parseURLEncodedForm(StringView);
+    static String serialize(const URLEncodedForm&);
+
 private:
     URL m_url;
     StringBuilder m_buffer;