summaryrefslogtreecommitdiffstats
path: root/dom/cache/test/mochitest/test_cache_put_reorder.js
diff options
context:
space:
mode:
authorMatt A. Tobin <mattatobin@localhost.localdomain>2018-02-02 04:16:08 -0500
committerMatt A. Tobin <mattatobin@localhost.localdomain>2018-02-02 04:16:08 -0500
commit5f8de423f190bbb79a62f804151bc24824fa32d8 (patch)
tree10027f336435511475e392454359edea8e25895d /dom/cache/test/mochitest/test_cache_put_reorder.js
parent49ee0794b5d912db1f95dce6eb52d781dc210db5 (diff)
downloadUXP-5f8de423f190bbb79a62f804151bc24824fa32d8.tar
UXP-5f8de423f190bbb79a62f804151bc24824fa32d8.tar.gz
UXP-5f8de423f190bbb79a62f804151bc24824fa32d8.tar.lz
UXP-5f8de423f190bbb79a62f804151bc24824fa32d8.tar.xz
UXP-5f8de423f190bbb79a62f804151bc24824fa32d8.zip
Add m-esr52 at 52.6.0
Diffstat (limited to 'dom/cache/test/mochitest/test_cache_put_reorder.js')
-rw-r--r--dom/cache/test/mochitest/test_cache_put_reorder.js31
1 files changed, 31 insertions, 0 deletions
diff --git a/dom/cache/test/mochitest/test_cache_put_reorder.js b/dom/cache/test/mochitest/test_cache_put_reorder.js
new file mode 100644
index 000000000..df8beecf9
--- /dev/null
+++ b/dom/cache/test/mochitest/test_cache_put_reorder.js
@@ -0,0 +1,31 @@
+var name = "putreorder" + context;
+var c;
+
+var reqs = [
+ "//mochi.test:8888/?foo" + context,
+ "//mochi.test:8888/?bar" + context,
+ "//mochi.test:8888/?baz" + context,
+];
+
+caches.open(name).then(function(cache) {
+ c = cache;
+ return c.addAll(reqs);
+}).then(function() {
+ return c.put(reqs[1], new Response("overwritten"));
+}).then(function() {
+ return c.keys();
+}).then(function(keys) {
+ is(keys.length, 3, "Correct number of entries expected");
+ ok(keys[0].url.indexOf(reqs[0]) >= 0, "The first entry should be untouched");
+ ok(keys[2].url.indexOf(reqs[1]) >= 0, "The second entry should be moved to the end");
+ ok(keys[1].url.indexOf(reqs[2]) >= 0, "The third entry should now be the second one");
+ return c.match(reqs[1]);
+}).then(function(r) {
+ return r.text();
+}).then(function(body) {
+ is(body, "overwritten", "The body should be overwritten");
+ return caches.delete(name);
+}).then(function(deleted) {
+ ok(deleted, "The cache should be deleted successfully");
+ testDone();
+});