Skip to content

Instantly share code, notes, and snippets.

@sammacbeth
Created January 10, 2019 18:34
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save sammacbeth/96b938d94d49451020fdfba7e80c57d8 to your computer and use it in GitHub Desktop.
Save sammacbeth/96b938d94d49451020fdfba7e80c57d8 to your computer and use it in GitHub Desktop.
Minimal Webextension to reproduce chrome messaging issue on Chrome 71. Test site: http://jsfiddle.net/jqwidgets/6q7h9xcj/
chrome.runtime.onMessage.addListener((message, sender, respond) => {
console.log('got message', message);
respond({ action: 'reply' });
});
window.addEventListener('mousedown', () => {
chrome.runtime.sendMessage({ action: 'test' }, reply => {
console.log('got a reply');
});
});
{
"manifest_version": 2,
"name": "Chrome message test",
"version": "0.1",
"content_scripts": [
{
"all_frames": true,
"js": [
"content-script.js"
],
"matches": [
"http://*/*",
"https://*/*"
],
"exclude_matches": [
"*://*/_/chrome/newtab*"
],
"run_at": "document_start"
}
],
"permissions": [
"http://*/*",
"https://*/*"
],
"background": {
"scripts": [
"background.js"
]
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment