Index: LayoutTests/http/tests/serviceworker/resources/headermap-worker.js |
diff --git a/LayoutTests/http/tests/serviceworker/resources/headermap-worker.js b/LayoutTests/http/tests/serviceworker/resources/headermap-worker.js |
deleted file mode 100644 |
index c6c746cc410cf7f9f0b176219fc61487e4bd9e11..0000000000000000000000000000000000000000 |
--- a/LayoutTests/http/tests/serviceworker/resources/headermap-worker.js |
+++ /dev/null |
@@ -1,98 +0,0 @@ |
-importScripts('worker-test-helpers.js'); |
- |
-test(function() { |
- var expectedMap = { |
- 'Content-Language': 'ja', |
- 'Content-Type': 'text/html; charset=UTF-8', |
- 'X-ServiceWorker-Test': 'response test field' |
- }; |
- |
- var headers = new HeaderMap; |
- Object.keys(expectedMap).forEach(function(key) { |
- headers.set(key, expectedMap[key]); |
- }); |
- |
- // 'size' |
- assert_equals(headers.size, 3, 'headers.size should match'); |
- |
- // 'has()', 'get()' |
- var key = 'Content-Type'; |
- assert_true(headers.has(key)); |
- assert_equals(headers.get(key), expectedMap[key]); |
- |
- // 'delete()' |
- var deleteKey = 'Content-Type'; |
- headers.delete(deleteKey); |
- assert_equals(headers.size, 2, 'headers.size should have -1 size'); |
- Object.keys(expectedMap).forEach(function(key) { |
- if (key == deleteKey) |
- assert_false(headers.has(key)); |
- else |
- assert_true(headers.has(key)); |
- }); |
- |
- // 'set()' |
- var testCasesForSet = [ |
- // For a new key/value pair. |
- { key: 'Cache-Control', |
- value: 'max-age=3600', |
- isNewEntry: true }, |
- |
- // For an existing key. |
- { key: 'X-ServiceWorker-Test', |
- value: 'response test field - updated', |
- isUpdate: true }, |
- |
- // For setting a numeric value, expecting to see DOMString on getting. |
- { key: 'X-Numeric-Value', |
- value: 12345, |
- expectedValue: '12345', |
- isNewEntry: true }, |
- |
- // For case-sensitivity test. (FIXME: if we want HeaderMap to |
- // work in an case-insensitive way (as we do for headers in XHR) |
- // update the test and code) |
- { key: 'content-language', |
- value: 'fi', |
- isNewEntry: true } |
- ]; |
- |
- var expectedHeaderSize = headers.size; |
- testCasesForSet.forEach(function(testCase) { |
- var key = testCase.key; |
- var value = testCase.value; |
- var expectedValue = ('expectedValue' in testCase) ? testCase.expectedValue : testCase.value; |
- expectedHeaderSize = testCase.isNewEntry ? (expectedHeaderSize + 1) : expectedHeaderSize; |
- |
- headers.set(key, value); |
- assert_true(headers.has(key)); |
- assert_equals(headers.get(key), expectedValue); |
- if (testCase.isUpdate) |
- assert_true(headers.get(key) != expectedMap[key]); |
- assert_equals(headers.size, expectedHeaderSize); |
- |
- // Update expectedMap too for forEach() test below. |
- expectedMap[key] = expectedValue; |
- }); |
- |
- // 'forEach()' |
- headers.forEach(function(value, key) { |
- assert_true(key != deleteKey); |
- assert_true(key in expectedMap); |
- assert_equals(headers.get(key), expectedMap[key]); |
- }); |
- |
- // 'forEach()' with thisArg |
- var that = {}, saw_that; |
- headers = new HeaderMap; |
- headers.set('a', 'b'); |
- headers.forEach(function() { saw_that = this; }, that); |
- assert_equals(saw_that, that, 'Passed thisArg should match'); |
- |
- headers.forEach(function() { 'use strict'; saw_that = this; }, 'abc'); |
- assert_equals(saw_that, 'abc', 'Passed non-object thisArg should match'); |
- |
- headers.forEach(function() { saw_that = this; }, null); |
- assert_equals(saw_that, self, 'Passed null thisArg should be replaced with global object'); |
- |
-}, 'HeaderMap in ServiceWorkerGlobalScope'); |