mirror of
https://github.com/servo/servo.git
synced 2025-09-11 23:48:21 +01:00
parent
a6e4b5bb86
commit
980c644a83
4 changed files with 67 additions and 4 deletions
|
@ -30387,6 +30387,10 @@
|
|||
"path": "url/urlsearchparams-delete.html",
|
||||
"url": "/url/urlsearchparams-delete.html"
|
||||
},
|
||||
{
|
||||
"path": "url/urlsearchparams-foreach.html",
|
||||
"url": "/url/urlsearchparams-foreach.html"
|
||||
},
|
||||
{
|
||||
"path": "url/urlsearchparams-get.html",
|
||||
"url": "/url/urlsearchparams-get.html"
|
||||
|
|
|
@ -0,0 +1,39 @@
|
|||
<!doctype html>
|
||||
<meta charset="utf-8">
|
||||
<link rel="help" href="https://url.spec.whatwg.org/#dom-urlsearchparams-has">
|
||||
<script src="/resources/testharness.js"></script>
|
||||
<script src="/resources/testharnessreport.js"></script>
|
||||
<script>
|
||||
test(function() {
|
||||
var params = new URLSearchParams('a=1&b=2&c=3');
|
||||
var keys = [];
|
||||
var values = [];
|
||||
params.forEach(function(value, key) {
|
||||
keys.push(key);
|
||||
values.push(value);
|
||||
});
|
||||
assert_array_equals(keys, ['a', 'b', 'c']);
|
||||
assert_array_equals(values, ['1', '2', '3']);
|
||||
}, "ForEach Check");
|
||||
|
||||
test(function() {
|
||||
let a = new URL("http://a.b/c?a=1&b=2&c=3&d=4");
|
||||
let b = a.searchParams;
|
||||
var c = [];
|
||||
for (i of b) {
|
||||
a.search = "x=1&y=2&z=3";
|
||||
c.push(i);
|
||||
}
|
||||
assert_array_equals(c[0], ["a","1"]);
|
||||
assert_array_equals(c[1], ["y","2"]);
|
||||
assert_array_equals(c[2], ["z","3"]);
|
||||
}, "For-of Check");
|
||||
|
||||
test(function() {
|
||||
let a = new URL("http://a.b/c");
|
||||
let b = a.searchParams;
|
||||
for (i of b) {
|
||||
assert_unreached(i);
|
||||
}
|
||||
}, "empty");
|
||||
</script>
|
Loading…
Add table
Add a link
Reference in a new issue