Bug 1645866 [wpt PR 24152] - Add test cases for URLSearchParams parsing %, a=testonly
authorJJ Kasper <jj@jjsweb.site>
Mon, 22 Jun 2020 10:40:06 +0000
changeset 536814 c3ddafc46ffdc6f61da034a59ec6d44a3e09bff7
parent 536813 d4ada8e0d394333369769f9534b1f6906768ad4f
child 536815 e46c93a0cb4415dc214034a5aedc336b37fb7e54
push id119680
push userwptsync@mozilla.com
push dateTue, 23 Jun 2020 11:08:22 +0000
treeherderautoland@7ca3d4bada73 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewerstestonly
bugs1645866, 24152
milestone79.0a1
first release with
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
last release without
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
Bug 1645866 [wpt PR 24152] - Add test cases for URLSearchParams parsing %, a=testonly Automatic update from web-platform-tests Add test cases for URLSearchParams parsing % -- wpt-commits: c79fe5612ae8730bcc8e732801c0d1ec6a371243 wpt-pr: 24152
testing/web-platform/tests/url/urlencoded-parser.any.js
testing/web-platform/tests/url/urlsearchparams-constructor.any.js
testing/web-platform/tests/url/urlsearchparams-stringifier.any.js
--- a/testing/web-platform/tests/url/urlencoded-parser.any.js
+++ b/testing/web-platform/tests/url/urlencoded-parser.any.js
@@ -23,17 +23,21 @@
   { "input": '&&&a=b&&&&c=d&', "output": [['a', 'b'], ['c', 'd']] },
   { "input": 'a=a&a=b&a=c', "output": [['a', 'a'], ['a', 'b'], ['a', 'c']] },
   { "input": 'a==a', "output": [['a', '=a']] },
   { "input": 'a=a+b+c+d', "output": [['a', 'a b c d']] },
   { "input": '%=a', "output": [['%', 'a']] },
   { "input": '%a=a', "output": [['%a', 'a']] },
   { "input": '%a_=a', "output": [['%a_', 'a']] },
   { "input": '%61=a', "output": [['a', 'a']] },
-  { "input": '%61+%4d%4D=', "output": [['a MM', '']] }
+  { "input": '%61+%4d%4D=', "output": [['a MM', '']] },
+  { "input": "id=0&value=%", "output": [['id', '0'], ['value', '%']] },
+  { "input": "b=%2sf%2a", "output": [['b', '%2sf*']]},
+  { "input": "b=%2%2af%2a", "output": [['b', '%2*f*']]},
+  { "input": "b=%%2a", "output": [['b', '%*']]}
 ].forEach((val) => {
   test(() => {
     let sp = new URLSearchParams(val.input),
         i = 0
     for (let item of sp) {
        assert_array_equals(item, val.output[i])
        i++
     }
--- a/testing/web-platform/tests/url/urlsearchparams-constructor.any.js
+++ b/testing/web-platform/tests/url/urlsearchparams-constructor.any.js
@@ -51,16 +51,38 @@ test(function() {
     params = new URLSearchParams('&a&&& &&&&&a+b=& c&m%c3%b8%c3%b8');
     assert_true(params != null, 'constructor returned non-null value.');
     assert_true(params.has('a'), 'Search params object has name "a"');
     assert_true(params.has('a b'), 'Search params object has name "a b"');
     assert_true(params.has(' '), 'Search params object has name " "');
     assert_false(params.has('c'), 'Search params object did not have the name "c"');
     assert_true(params.has(' c'), 'Search params object has name " c"');
     assert_true(params.has('møø'), 'Search params object has name "møø"');
+
+    params = new URLSearchParams('id=0&value=%');
+    assert_true(params != null, 'constructor returned non-null value.');
+    assert_true(params.has('id'), 'Search params object has name "id"');
+    assert_true(params.has('value'), 'Search params object has name "value"');
+    assert_equals(params.get('id'), '0');
+    assert_equals(params.get('value'), '%');
+
+    params = new URLSearchParams('b=%2sf%2a');
+    assert_true(params != null, 'constructor returned non-null value.');
+    assert_true(params.has('b'), 'Search params object has name "b"');
+    assert_equals(params.get('b'), '%2sf*');
+
+    params = new URLSearchParams('b=%2%2af%2a');
+    assert_true(params != null, 'constructor returned non-null value.');
+    assert_true(params.has('b'), 'Search params object has name "b"');
+    assert_equals(params.get('b'), '%2*f*');
+
+    params = new URLSearchParams('b=%%2a');
+    assert_true(params != null, 'constructor returned non-null value.');
+    assert_true(params.has('b'), 'Search params object has name "b"');
+    assert_equals(params.get('b'), '%*');
 }, 'URLSearchParams constructor, string.');
 
 test(function() {
     var seed = new URLSearchParams('a=b&c=d');
     var params = new URLSearchParams(seed);
     assert_true(params != null, 'constructor returned non-null value.');
     assert_equals(params.get('a'), 'b');
     assert_equals(params.get('c'), 'd');
--- a/testing/web-platform/tests/url/urlsearchparams-stringifier.any.js
+++ b/testing/web-platform/tests/url/urlsearchparams-stringifier.any.js
@@ -73,16 +73,19 @@ test(function() {
 
 test(function() {
     var params = new URLSearchParams();
     params.append('a', 'b%c');
     assert_equals(params + '', 'a=b%25c');
     params.delete('a');
     params.append('a%b', 'c');
     assert_equals(params + '', 'a%25b=c');
+
+    params = new URLSearchParams('id=0&value=%')
+    assert_equals(params + '', 'id=0&value=%25')
 }, 'Serialize %');
 
 test(function() {
     var params = new URLSearchParams();
     params.append('a', 'b\0c');
     assert_equals(params + '', 'a=b%00c');
     params.delete('a');
     params.append('a\0b', 'c');
@@ -102,16 +105,25 @@ test(function() {
     var params;
     params = new URLSearchParams('a=b&c=d&&e&&');
     assert_equals(params.toString(), 'a=b&c=d&e=');
     params = new URLSearchParams('a = b &a=b&c=d%20');
     assert_equals(params.toString(), 'a+=+b+&a=b&c=d+');
     // The lone '=' _does_ survive the roundtrip.
     params = new URLSearchParams('a=&a=b');
     assert_equals(params.toString(), 'a=&a=b');
+
+    params = new URLSearchParams('b=%2sf%2a');
+    assert_equals(params.toString(), 'b=%252sf*');
+
+    params = new URLSearchParams('b=%2%2af%2a');
+    assert_equals(params.toString(), 'b=%252*f*');
+
+    params = new URLSearchParams('b=%%2a');
+    assert_equals(params.toString(), 'b=%25*');
 }, 'URLSearchParams.toString');
 
 test(() => {
     const url = new URL('http://www.example.com/?a=b,c');
     const params = url.searchParams;
 
     assert_equals(url.toString(), 'http://www.example.com/?a=b,c');
     assert_equals(params.toString(), 'a=b%2Cc');