Skip to content

Instantly share code, notes, and snippets.

@groovecoder
Created May 10, 2017 19:42
Show Gist options
  • Select an option

  • Save groovecoder/fc2f54ac64d1a5bcee9c94db68174063 to your computer and use it in GitHub Desktop.

Select an option

Save groovecoder/fc2f54ac64d1a5bcee9c94db68174063 to your computer and use it in GitHub Desktop.
// WebExtension startup
webExtension.startup().then(api => {
api.browser.runtime.onMessage.addListener((message, sender, sendReply) => {
if ("method" in message && methods.indexOf(message.method) !== -1) {
sendReply(this[message.method](message));
}
});
console.log("webExtension.startup.then(), reason: ", reason);
// Send "upgrade" message to WebExtension runtime
if (reason === "upgrade") {
console.log("sending upgrade message");
api.browser.runtime.sendMessage("upgrade").then(reply => {
console.log(reply);
});
}
this.registerBackgroundConnection(api);
}).catch(e => {
throw new Error("WebExtension startup failed. Unable to continue. ", e);
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment