From 36d22d82aa202bb199967e9512281e9a53db42c9 Mon Sep 17 00:00:00 2001 From: Daniel Baumann Date: Sun, 7 Apr 2024 21:33:14 +0200 Subject: Adding upstream version 115.7.0esr. Signed-off-by: Daniel Baumann --- dom/cache/test/mochitest/test_cache_put_reorder.js | 47 ++++++++++++++++++++++ 1 file changed, 47 insertions(+) create mode 100644 dom/cache/test/mochitest/test_cache_put_reorder.js (limited to 'dom/cache/test/mochitest/test_cache_put_reorder.js') 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 0000000000..c5875c2c9d --- /dev/null +++ b/dom/cache/test/mochitest/test_cache_put_reorder.js @@ -0,0 +1,47 @@ +/* global context testDone:true */ + +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.includes(reqs[0]), "The first entry should be untouched"); + ok( + keys[2].url.includes(reqs[1]), + "The second entry should be moved to the end" + ); + ok( + keys[1].url.includes(reqs[2]), + "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(); + }); -- cgit v1.2.3