blob: b6f5058ed2a5b3d135b94e9a4b04133b65fe8cfc [file] [log] [blame]
importScripts("resource-utilities.js");
const functions = {
triggerListener() {
dispatchEvent(new Event("custom"));
},
triggerTimeout() {
setTimeout(function timeout() {
console.log("timeout fired");
});
},
triggerInterval() {
let intervalId = setInterval(function interval() {
console.log("interval fired");
clearInterval(intervalId);
});
},
triggerXHR() {
loadResourceXHR("dataXHR.json");
},
triggerFetch() {
loadResourceFetch("dataFetch.json");
},
};
addEventListener("custom", function handler(event) {
console.log("listener fired");
});
addEventListener("message", function handleMessage(event) {
functions[event.data]();
});