gecko/dom/cache/test/mochitest/app/sw.js

19 lines
458 B
JavaScript

self.addEventListener('message', (message) => {
caches.open('acache').then((cache) => {
if(message.data == 'write') {
cache.add('aurl').then(() => {
message.source.postMessage({
type: 'written'
});
});
} else if (message.data == 'read') {
cache.match('aurl').then((result) => {
message.source.postMessage({
type: 'done',
cached: !!result
});
});
}
});
});