Bug 1162487 - Enable the dom.caches.enabled pref in test_chrome_constructor.html; r=baku

This commit is contained in:
Ehsan Akhgari 2015-05-07 23:04:00 -04:00
parent 42f15a9b3f
commit 977149ac89

View File

@ -13,30 +13,34 @@
Cu.import('resource://gre/modules/Services.jsm'); Cu.import('resource://gre/modules/Services.jsm');
SimpleTest.waitForExplicitFinish(); SimpleTest.waitForExplicitFinish();
// attach to a different origin's CacheStorage SpecialPowers.pushPrefEnv({
var url = 'http://example.com/'; "set": [["dom.caches.enabled", true]],
var uri = Services.io.newURI(url, null, null); }, function() {
var principal = Services.scriptSecurityManager.getNoAppCodebasePrincipal(uri); // attach to a different origin's CacheStorage
var storage = new CacheStorage('content', principal); var url = 'http://example.com/';
var uri = Services.io.newURI(url, null, null);
var principal = Services.scriptSecurityManager.getNoAppCodebasePrincipal(uri);
var storage = new CacheStorage('content', principal);
// verify we can use the other origin's CacheStorage as normal // verify we can use the other origin's CacheStorage as normal
var req = new Request('http://example.com/index.html'); var req = new Request('http://example.com/index.html');
var res = new Response('hello world'); var res = new Response('hello world');
var cache; var cache;
storage.open('foo').then(function(c) { storage.open('foo').then(function(c) {
cache = c; cache = c;
ok(cache, 'storage should create cache'); ok(cache, 'storage should create cache');
return cache.put(req, res.clone()); return cache.put(req, res.clone());
}).then(function() { }).then(function() {
return cache.match(req); return cache.match(req);
}).then(function(foundResponse) { }).then(function(foundResponse) {
return Promise.all([res.text(), foundResponse.text()]); return Promise.all([res.text(), foundResponse.text()]);
}).then(function(results) { }).then(function(results) {
is(results[0], results[1], 'cache should contain response'); is(results[0], results[1], 'cache should contain response');
return storage.delete('foo'); return storage.delete('foo');
}).then(function(deleted) { }).then(function(deleted) {
ok(deleted, 'storage should delete cache'); ok(deleted, 'storage should delete cache');
SimpleTest.finish(); SimpleTest.finish();
});
}); });
</script> </script>
</body> </body>