Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(2276)

Unified Diff: third_party/WebKit/LayoutTests/fast/domurl/urlsearchparams-iterable.html

Issue 1442643008: Implement 'URLSearchParams' (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Test. Created 5 years, 1 month ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
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>

Powered by Google App Engine
This is Rietveld 408576698