2015-12-20 20:02:08 +00:00
|
|
|
<script>
|
|
|
|
const ipcRenderer = require('electron').ipcRenderer;
|
|
|
|
navigator.serviceWorker.register('service-worker.js', {scope: './'}).then(function() {
|
|
|
|
if (navigator.serviceWorker.controller) {
|
|
|
|
var xhr = new XMLHttpRequest();
|
|
|
|
xhr.open('GET', 'http://dummy/echo');
|
|
|
|
xhr.setRequestHeader('X-Mock-Response', 'yes');
|
|
|
|
xhr.addEventListener('load', function() {
|
|
|
|
ipcRenderer.send('response', xhr.responseText);
|
|
|
|
});
|
|
|
|
xhr.send();
|
|
|
|
} else {
|
|
|
|
ipcRenderer.send('reload');
|
|
|
|
}
|
|
|
|
}).catch(function(error) {
|
2018-03-09 02:06:29 +00:00
|
|
|
ipcRenderer.send('error', `${error.message}\n${error.stack}`);
|
2015-12-20 20:02:08 +00:00
|
|
|
})
|
|
|
|
</script>
|