FWIW, this was the code used to compare htmlunit vs Chrome behaviour of URLSeachParams's splitting. This PR fixes all the differences and I've rolled the important bits into the URLSeachParamsTest.appendSpecialChars() test.
<!DOCTYPE html> <html> <head> <script> var param = new URLSearchParams(); param.append("?x=1&", "foo"); param.append("bar", "http://foo.com/?x=1&y=2&z=3") param.append("foobar", "baz") // chrome: %3Fx%3D1%26=foo&bar=http%3A%2F%2Ffoo.com%2F%3Fx%3D1%26y%3D2%26z%3D3&foobar=baz // htmlunit: x=1&=foo&bar=http%3A%2F%2Ffoo.com%2F%3Fx%3D1&y=2&z=3&foobar=baz console.log(param.toString()); // chrome: true // htmlunit: false console.log(param.has("?x=1&")); // chrome: http://foo.com/?x=1&y=2&z=3 // htmlunit: http://foo.com/?x=1 console.log(param.get("bar")); param.set("foobar", "foo?bar&"); // chrome: foo?bar& // htmlunit: foo?bar console.log(param.get("foobar")); param.delete("?x=1&"); // chrome: bar=http%3A%2F%2Ffoo.com%2F%3Fx%3D1%26y%3D2%26z%3D3&foobar=foo%3Fbar%26 // htmlunit: x=1&=foo&bar=http%3A%2F%2Ffoo.com%2F%3Fx%3D1&y=2&z=3&foobar=foo%3Fbar console.log(param.toString()); </script> </head> <body> </body> </html>