Skip to content

Instantly share code, notes, and snippets.

@twolfson
Created December 16, 2017 11:52
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 twolfson/c47ab162b73fd86a59e05ac91b455108 to your computer and use it in GitHub Desktop.
Save twolfson/c47ab162b73fd86a59e05ac91b455108 to your computer and use it in GitHub Desktop.
Proof of concept to demonstrate how `tabs.sendMessage` refuses to send in Firefox's responive design mode

gist-web-extension-onMessage2

Proof of concept to demonstrate how tabs.sendMessage refuses to send in Firefox's responive design mode

Related to: twolfson/livereload-extensions#5

Getting started

Run the following steps to get this proof of concept running:

  • Clone the repository
    git clone <repo_url> gist-web-extension-onMessage2
    cd gist-web-extension-onMessage2
  • Open Firefox and navigate to about:debugging
  • Add our extension as a temporary add-on
  • Open its "Debug" console
  • Navigate to a normal website (e.g. https://mozilla.org/)
  • Open our in-page Developer console
  • Click our icon, look at "Debug" console, and verify message sending
  • Look at our in-page Developer console and verify message logged
  • Enter Responsive Design Mode
  • Click our icon, look at "Debug" console, and verify message failing to send
  • Look at our in-page Developer console and verify no message logged
browser.browserAction.onClicked.addListener(function handleAddListener(tab) {
console.log('Sending message to...', tab.id);
browser.tabs.sendMessage(tab.id, 'Hello World!');
});
browser.runtime.onMessage.addListener(function handleMessage (message, sender, sendResponse) {
console.log('Received message: ', message);
});
{
"manifest_version": 2,
"name": "gist-web-extension-onMessage2",
"version": "1.0.0",
"background": {
"scripts": [
"global.js"
]
},
"content_scripts": [
{
"matches": ["<all_urls>"],
"js": ["injected.js"]
}
],
"web_accessible_resources": [],
"permissions": [
"tabs",
"<all_urls>"
],
"browser_action": {
"default_title": "Enable extension",
"default_icon": "IconDisabled.png"
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment