diff options
author | Matt A. Tobin <mattatobin@localhost.localdomain> | 2018-02-02 04:16:08 -0500 |
---|---|---|
committer | Matt A. Tobin <mattatobin@localhost.localdomain> | 2018-02-02 04:16:08 -0500 |
commit | 5f8de423f190bbb79a62f804151bc24824fa32d8 (patch) | |
tree | 10027f336435511475e392454359edea8e25895d /dom/cache/test/mochitest/browser_cache_pb_window.js | |
parent | 49ee0794b5d912db1f95dce6eb52d781dc210db5 (diff) | |
download | UXP-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/browser_cache_pb_window.js')
-rw-r--r-- | dom/cache/test/mochitest/browser_cache_pb_window.js | 81 |
1 files changed, 81 insertions, 0 deletions
diff --git a/dom/cache/test/mochitest/browser_cache_pb_window.js b/dom/cache/test/mochitest/browser_cache_pb_window.js new file mode 100644 index 000000000..05a0aa22b --- /dev/null +++ b/dom/cache/test/mochitest/browser_cache_pb_window.js @@ -0,0 +1,81 @@ +var name = 'pb-window-cache'; + +function testMatch(win) { + return new Promise(function(resolve, reject) { + win.caches.match('http://foo.com').then(function(response) { + ok(false, 'caches.match() should not return success'); + reject(); + }).catch(function(err) { + is('SecurityError', err.name, 'caches.match() should throw SecurityError'); + resolve(); + }); + }); +} + +function testHas(win) { + return new Promise(function(resolve, reject) { + win.caches.has(name).then(function(result) { + ok(false, 'caches.has() should not return success'); + reject(); + }).catch(function(err) { + is('SecurityError', err.name, 'caches.has() should throw SecurityError'); + resolve(); + }); + }); +} + +function testOpen(win) { + return new Promise(function(resolve, reject) { + win.caches.open(name).then(function(c) { + ok(false, 'caches.open() should not return success'); + reject(); + }).catch(function(err) { + is('SecurityError', err.name, 'caches.open() should throw SecurityError'); + resolve(); + }); + }); +} + +function testDelete(win) { + return new Promise(function(resolve, reject) { + win.caches.delete(name).then(function(result) { + ok(false, 'caches.delete() should not return success'); + reject(); + }).catch(function(err) { + is('SecurityError', err.name, 'caches.delete() should throw SecurityError'); + resolve(); + }); + }); +} + +function testKeys(win) { + return new Promise(function(resolve, reject) { + win.caches.keys().then(function(names) { + ok(false, 'caches.keys() should not return success'); + reject(); + }).catch(function(err) { + is('SecurityError', err.name, 'caches.keys() should throw SecurityError'); + resolve(); + }); + }); +} + +function test() { + waitForExplicitFinish(); + SpecialPowers.pushPrefEnv({'set': [['dom.caches.enabled', true], + ['dom.caches.testing.enabled', true]]}, + function() { + var privateWin = OpenBrowserWindow({private: true}); + privateWin.addEventListener('load', function() { + Promise.all([ + testMatch(privateWin), + testHas(privateWin), + testOpen(privateWin), + testDelete(privateWin), + testKeys(privateWin) + ]).then(function() { + BrowserTestUtils.closeWindow(privateWin).then(finish); + }); + }); + }); +} |