summaryrefslogtreecommitdiffstats
path: root/dom/cache/test/mochitest/test_cache_restart.html
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_restart.html
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_restart.html')
-rw-r--r--dom/cache/test/mochitest/test_cache_restart.html70
1 files changed, 70 insertions, 0 deletions
diff --git a/dom/cache/test/mochitest/test_cache_restart.html b/dom/cache/test/mochitest/test_cache_restart.html
new file mode 100644
index 000000000..68649bf61
--- /dev/null
+++ b/dom/cache/test/mochitest/test_cache_restart.html
@@ -0,0 +1,70 @@
+<!-- Any copyright is dedicated to the Public Domain.
+ - http://creativecommons.org/publicdomain/zero/1.0/ -->
+<!DOCTYPE HTML>
+<html>
+<head>
+ <title>Test Cache with QuotaManager Restart</title>
+ <script type="text/javascript" src="/tests/SimpleTest/SimpleTest.js"></script>
+ <link rel="stylesheet" type="text/css" href="/tests/SimpleTest/test.css" />
+</head>
+<body>
+<script class="testbody" type="text/javascript">
+function setupTestIframe() {
+ return new Promise(function(resolve) {
+ var iframe = document.createElement("iframe");
+ iframe.src = "empty.html";
+ iframe.onload = function() {
+ window.caches = iframe.contentWindow.caches;
+ resolve();
+ };
+ document.body.appendChild(iframe);
+ });
+}
+
+function resetStorage() {
+ return new Promise(function(resolve, reject) {
+ var qms = SpecialPowers.Services.qms;
+ var request = qms.reset();
+ var cb = SpecialPowers.wrapCallback(resolve);
+ request.callback = cb;
+ });
+}
+
+SimpleTest.waitForExplicitFinish();
+SpecialPowers.pushPrefEnv({
+ "set": [["dom.caches.enabled", true],
+ ["dom.caches.testing.enabled", true],
+ ["dom.quotaManager.testing", true]],
+}, function() {
+ var name = 'foo';
+ var url = './test_cache_add.js';
+ var cache;
+ setupTestIframe().then(function() {
+ return caches.open(name);
+ }).then(function(c) {
+ cache = c;
+ return cache.add(url);
+ }).then(function() {
+ return resetStorage();
+ }).then(function() {
+ return cache.match(url).then(function(resp) {
+ ok(false, 'old cache reference should not work after reset');
+ }).catch(function(err) {
+ ok(true, 'old cache reference should not work after reset');
+ });
+ }).then(function() {
+ return caches.open(name);
+ }).then(function(c) {
+ cache = c;
+ return cache.match(url);
+ }).then(function(resp) {
+ ok(!!resp, 'cache should work after QM reset');
+ return caches.delete(name);
+ }).then(function(success) {
+ ok(success, 'cache should be deleted');
+ SimpleTest.finish();
+ });
+});
+</script>
+</body>
+</html>