From 5f8de423f190bbb79a62f804151bc24824fa32d8 Mon Sep 17 00:00:00 2001 From: "Matt A. Tobin" Date: Fri, 2 Feb 2018 04:16:08 -0500 Subject: Add m-esr52 at 52.6.0 --- dom/cache/test/mochitest/test_cache_overwrite.js | 47 ++++++++++++++++++++++++ 1 file changed, 47 insertions(+) create mode 100644 dom/cache/test/mochitest/test_cache_overwrite.js (limited to 'dom/cache/test/mochitest/test_cache_overwrite.js') diff --git a/dom/cache/test/mochitest/test_cache_overwrite.js b/dom/cache/test/mochitest/test_cache_overwrite.js new file mode 100644 index 000000000..5b1c0142b --- /dev/null +++ b/dom/cache/test/mochitest/test_cache_overwrite.js @@ -0,0 +1,47 @@ +var requestURL = "//mochi.test:8888/tests/dom/cache/test/mochitest/mirror.sjs?" + context; +var response; +var c; +var responseText; +var name = "match-mirror" + context; + +function checkResponse(r) { + ok(r !== response, "The objects should not be the same"); + is(r.url, response.url.replace("#fragment", ""), + "The URLs should be the same"); + is(r.status, response.status, "The status codes should be the same"); + is(r.type, response.type, "The response types should be the same"); + is(r.ok, response.ok, "Both responses should have succeeded"); + is(r.statusText, response.statusText, + "Both responses should have the same status text"); + is(r.headers.get("Mirrored"), response.headers.get("Mirrored"), + "Both responses should have the same Mirrored header"); + return r.text().then(function(text) { + is(text, responseText, "The response body should be correct"); + }); +} + +fetch(new Request(requestURL, {headers: {"Mirror": "bar"}})).then(function(r) { + is(r.headers.get("Mirrored"), "bar", "The server should give back the correct header"); + response = r; + return response.text(); +}).then(function(text) { + responseText = text; + return caches.open(name); +}).then(function(cache) { + c = cache; + return c.add(new Request(requestURL, {headers: {"Mirror": "foo"}})); +}).then(function() { + // Overwrite the request, to replace the entry stored in response_headers + // with a different value. + return c.add(new Request(requestURL, {headers: {"Mirror": "bar"}})); +}).then(function() { + return c.matchAll(); +}).then(function(r) { + is(r.length, 1, "Only one request should be in the cache"); + return checkResponse(r[0]); +}).then(function() { + return caches.delete(name); +}).then(function(deleted) { + ok(deleted, "The cache should be deleted successfully"); + testDone(); +}); -- cgit v1.2.3