Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Make URLSearchParams iterable #13022 #13077

Closed
wants to merge 8 commits into from
Next

add test for URLSearthParams

  • Loading branch information
yoyo930021 committed Aug 27, 2016
commit 66c8496490519409cd6638e17fc23e88c0781b69
"path": "url/urlsearchparams-stringifier.html",
"url": "/url/urlsearchparams-stringifier.html"
},
{
"path": "url/urlsearchparams-foreach.html",
"url": "/url/urlsearchparams-foreach.html"
},
{
"path": "user-timing/idlharness.html",
"url": "/user-timing/idlharness.html"
@@ -0,0 +1,44 @@
<!doctype html>
<html>
<head>
<meta charset="utf-8">
<link rel="help" href="http://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');
for(var URLSearchParam in params){

This comment has been minimized.

@jdm

jdm Aug 27, 2016

Member

This test doesn't actually verify that the keys are present. I don't think for in works on iterators this way, either, since Firefox didn't show me any of those keys when I tried it.

This comment has been minimized.

@yoyo930021

yoyo930021 Aug 27, 2016

Author Contributor

Yes, I test.
for-in isn't used iterators.

switch (URLSearchParam) {
case 'a':
assert_equals('1', params[URLSearchParam]);
break;
case 'b':
assert_equals('2', params[URLSearchParam]);
break;
case 'c':
assert_equals('3', params[URLSearchParam]);
break;
}
}
}, "For-in Check");

test(function() {
var params = new URLSearchParams('a=1&b=2&c=3');
params.forEach(function(value,index){

This comment has been minimized.

@Ms2ger

Ms2ger Aug 31, 2016

Contributor

I think the suggestion was to make this test more like

var found = [];
params.forEach(function(value, index) {
  found.push(value);
});
assert_array_equals(['1', '2', '3']);

This comment has been minimized.

@emilio

emilio Sep 21, 2016

Member

nit: space after comma here.

switch (index) {
case 'a':
assert_equals('1', value);
break;
case 'b':
assert_equals('2', value);
break;
case 'c':
assert_equals('3', value);
break;
}
});
}, "ForEach Check");
</script>
</head>
</html>
ProTip! Use n and p to navigate between commits in a pull request.
You can’t perform that action at this time.