Index: third_party/WebKit/LayoutTests/fast/domurl/urlsearchparams-iterable.html |
diff --git a/third_party/WebKit/LayoutTests/fast/domurl/urlsearchparams-iterable.html b/third_party/WebKit/LayoutTests/fast/domurl/urlsearchparams-iterable.html |
new file mode 100644 |
index 0000000000000000000000000000000000000000..3e7b0f0d44de61d6caae900e28af17b4eab13a7d |
--- /dev/null |
+++ b/third_party/WebKit/LayoutTests/fast/domurl/urlsearchparams-iterable.html |
@@ -0,0 +1,66 @@ |
+<!doctype html> |
+<html> |
+<head> |
+<meta charset="utf8"> |
+<link rel="help" href="https://url.spec.whatwg.org/#dom-urlsearchparams"> |
+<script src="../../resources/testharness.js"></script> |
+<script src="../../resources/testharnessreport.js"></script> |
+<script> |
+var expectedValues = { |
+ 'a': '1', |
+ 'b': '2', |
+ 'c': '3' |
+}; |
+ |
+var params = new URLSearchParams(); |
+params.append('a', '1'); |
+params.append('b', '2'); |
+params.append('c', '3'); |
+ |
+test(function() { |
+ for (var param of params) { |
+ var key = param[0]; |
+ var value = param[1]; |
+ assert_true(key in expectedValues); |
+ assert_equals(params.get(key), expectedValues[key]); |
+ assert_equals(value, expectedValues[key]); |
+ } |
+}, 'for...of Iteration'); |
+ |
+test(function() { |
+ for (var key of params.keys()) { |
+ assert_true(key in expectedValues); |
+ assert_equals(params.get(key), expectedValues[key]); |
+ } |
+}, 'keys'); |
+ |
+test(function() { |
+ var expectedKeys = {}; |
+ for (var key in expectedValues) |
+ expectedKeys[expectedValues[key]] = key; |
+ |
+ for (var value of params.values()) |
+ assert_true(value in expectedKeys); |
+}, 'values'); |
+ |
+test(function () { |
+ for (var param of params.entries()) { |
+ var key = param[0]; |
+ var value = param[1]; |
+ assert_true(key in expectedValues); |
+ assert_equals(params.get(key), expectedValues[key]); |
+ assert_equals(value, expectedValues[key]); |
+ } |
+}, 'entries'); |
+ |
+test(function () { |
+ params.forEach(function (value, key, paramsObject) { |
+ assert_true(key in expectedValues); |
+ assert_equals(params.get(key), expectedValues[key]); |
+ assert_equals(value, expectedValues[key]); |
+ assert_equals(paramsObject, params); |
+ }); |
+}, 'forEach'); |
+</script> |
+</head> |
+</html> |