mirror of
https://github.com/mozilla/gecko-dev.git
synced 2025-11-13 06:38:48 +02:00
Automatic update from web-platform-testsGeneralize test -- updated urlencoded-parser to use .any.js -- issue 11277: convert url html test to any.js -- Convert URL tests to .any.js format - Convert url/urlsearchparams-append.html to .any.js - Convert url/urlsearchparams-constructor.html to .any.js - Convert url/urlsearchparams-foreach.html to .any.js - Convert url/urlsearchparams-set.html to .any.js - Convert url/urlsearchparams-getall.html to .any.js -- Separate url-searchparams.any.js from url/url-constructor.html -- converted additional urlsearchparams tests to use any.js -- Generalize test. -- Generalized Test -- Relocate specification reference -- wpt-commits: a1c591bbb2c67f708609608d82caf5e9970431f0, 5efc5e92401e8edc5b1cfbdc8679c9817af30413, 1f3019b4ae77f4b98de5d3affc162d0889f645d0, c6dd3dce89c8d1475b1354a03447750c14cd8804, 87dc680b64f89ec6e91fb8763d7b2da9677110c4, a734002040383222111fce80e50e7dc013a5812d, 39c743e4f7877abf16db6ace465089f6c61b2b60, 693caf30f6cf9f8bffbac2f06fbb538989663ab8, e6422d28a641dcb82a419c1f63efb975588960cf wpt-pr: 11492
76 lines
2.3 KiB
JavaScript
76 lines
2.3 KiB
JavaScript
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");
|
|
|
|
test(function() {
|
|
const url = new URL("http://localhost/query?param0=0¶m1=1¶m2=2");
|
|
const searchParams = url.searchParams;
|
|
const seen = [];
|
|
for (param of searchParams) {
|
|
if (param[0] === 'param0') {
|
|
searchParams.delete('param1');
|
|
}
|
|
seen.push(param);
|
|
}
|
|
|
|
assert_array_equals(seen[0], ["param0", "0"]);
|
|
assert_array_equals(seen[1], ["param2", "2"]);
|
|
}, "delete next param during iteration");
|
|
|
|
test(function() {
|
|
const url = new URL("http://localhost/query?param0=0¶m1=1¶m2=2");
|
|
const searchParams = url.searchParams;
|
|
const seen = [];
|
|
for (param of searchParams) {
|
|
if (param[0] === 'param0') {
|
|
searchParams.delete('param0');
|
|
// 'param1=1' is now in the first slot, so the next iteration will see 'param2=2'.
|
|
} else {
|
|
seen.push(param);
|
|
}
|
|
}
|
|
|
|
assert_array_equals(seen[0], ["param2", "2"]);
|
|
}, "delete current param during iteration");
|
|
|
|
test(function() {
|
|
const url = new URL("http://localhost/query?param0=0¶m1=1¶m2=2");
|
|
const searchParams = url.searchParams;
|
|
const seen = [];
|
|
for (param of searchParams) {
|
|
seen.push(param[0]);
|
|
searchParams.delete(param[0]);
|
|
}
|
|
|
|
assert_array_equals(seen, ["param0", "param2"], "param1 should not have been seen by the loop");
|
|
assert_equals(String(searchParams), "param1=1", "param1 should remain");
|
|
}, "delete every param seen during iteration");
|