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

Unified Diff: third_party/WebKit/LayoutTests/http/tests/fetch/script-tests/headers.js

Issue 2542073005: Sort headers for iteration (Closed)
Patch Set: Rebased Created 4 years 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/http/tests/fetch/script-tests/headers.js
diff --git a/third_party/WebKit/LayoutTests/http/tests/fetch/script-tests/headers.js b/third_party/WebKit/LayoutTests/http/tests/fetch/script-tests/headers.js
index 4dd6037237a186f84604b764124bd4815f2e63bb..a87a75febb4649089b93afcb12235d1a2b5a4113 100644
--- a/third_party/WebKit/LayoutTests/http/tests/fetch/script-tests/headers.js
+++ b/third_party/WebKit/LayoutTests/http/tests/fetch/script-tests/headers.js
@@ -221,4 +221,36 @@ test(function() {
'should throw');
}, 'Headers');
+test(function(t) {
+ const headers = new Headers;
+ headers.set('b', '1');
+ headers.set('c', '2');
+ headers.set('a', '3');
+
+ const keys = [];
+ for (let [key, value] of headers)
+ keys.push(key);
+ assert_array_equals(keys, ['a', 'b', 'c'],
+ 'The pairs to iterate over should be sorted.');
+}, 'Iteration order');
+
+test(function(t) {
+ const headers = new Headers;
+ headers.set('a', '1');
+ headers.set('b', '2');
+ headers.set('c', '3');
+
+ const iterator = headers.entries();
+
+ headers.delete('a');
+ headers.set('d', '4');
+
+ const keys = [];
+ for (let [key, value] of iterator)
+ keys.push(key);
+ assert_array_equals(keys, ['a', 'b', 'c'],
+ 'The pairs to iterate over should be the return ' +
+ 'value of an algorithm that implicitly makes a copy.');
+}, 'Iteration mutation');
+
done();

Powered by Google App Engine
This is Rietveld 408576698