mirror of
https://gitlab.winehq.org/wine/wine-gecko.git
synced 2024-09-13 09:24:08 -07:00
Bug 1165395 Test Cache API after QuotaManager reset. r=janv
This commit is contained in:
parent
af6d99e3ee
commit
6a28455b8e
1
dom/cache/test/mochitest/mochitest.ini
vendored
1
dom/cache/test/mochitest/mochitest.ini
vendored
@ -33,3 +33,4 @@ support-files =
|
||||
[test_cache_requestCache.html]
|
||||
[test_cache_delete.html]
|
||||
[test_cache_put_reorder.html]
|
||||
[test_cache_restart.html]
|
||||
|
61
dom/cache/test/mochitest/test_cache_restart.html
vendored
Normal file
61
dom/cache/test/mochitest/test_cache_restart.html
vendored
Normal file
@ -0,0 +1,61 @@
|
||||
<!-- 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 resetStorage() {
|
||||
return new Promise(function(resolve, reject) {
|
||||
var principal = SpecialPowers.wrap(document).nodePrincipal;
|
||||
var appId, inBrowser;
|
||||
var nsIPrincipal = SpecialPowers.Components.interfaces.nsIPrincipal;
|
||||
if (principal.appId != nsIPrincipal.UNKNOWN_APP_ID &&
|
||||
principal.appId != nsIPrincipal.NO_APP_ID) {
|
||||
appId = principal.appId;
|
||||
inBrowser = principal.isInBrowserElement;
|
||||
}
|
||||
SpecialPowers.resetStorageForURI(document.documentURI, resolve, appId,
|
||||
inBrowser);
|
||||
});
|
||||
}
|
||||
|
||||
SimpleTest.waitForExplicitFinish();
|
||||
SpecialPowers.pushPrefEnv({
|
||||
"set": [["dom.caches.enabled", true],
|
||||
["dom.quotaManager.testing", true]],
|
||||
}, function() {
|
||||
var name = 'foo';
|
||||
var url = './test_cache_add.js';
|
||||
var cache;
|
||||
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>
|
@ -497,7 +497,7 @@ SpecialPowersObserverAPI.prototype = {
|
||||
let msg = aMessage.data;
|
||||
let op = msg.op;
|
||||
|
||||
if (op != 'clear' && op != 'getUsage') {
|
||||
if (op != 'clear' && op != 'getUsage' && op != 'reset') {
|
||||
throw new SpecialPowersError('Invalid operation for SPQuotaManager');
|
||||
}
|
||||
|
||||
@ -511,6 +511,8 @@ SpecialPowersObserverAPI.prototype = {
|
||||
} else {
|
||||
qm.clearStoragesForURI(uri);
|
||||
}
|
||||
} else if (op == 'reset') {
|
||||
qm.reset();
|
||||
}
|
||||
|
||||
// We always use the getUsageForURI callback even if we're clearing
|
||||
|
@ -1889,6 +1889,13 @@ SpecialPowersAPI.prototype = {
|
||||
this._quotaManagerRequest('getUsage', uri, appId, inBrowser, callback);
|
||||
},
|
||||
|
||||
// Technically this restarts the QuotaManager for all URIs, but we need
|
||||
// a specific one to perform the synchronized callback when the reset is
|
||||
// complete.
|
||||
resetStorageForURI: function(uri, callback, appId, inBrowser) {
|
||||
this._quotaManagerRequest('reset', uri, appId, inBrowser, callback);
|
||||
},
|
||||
|
||||
_quotaManagerRequest: function(op, uri, appId, inBrowser, callback) {
|
||||
const messageTopic = "SPQuotaManager";
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user