Closed
Bug 1364336
Opened 9 years ago
Closed 8 years ago
Can't send Msg from Background to Content script using web-ext
Categories
(WebExtensions :: General, defect)
Tracking
(Not tracked)
RESOLVED
INVALID
People
(Reporter: rappazf, Unassigned)
Details
(Whiteboard: investigating)
Attachments
(1 file)
|
4.61 KB,
application/x-zip-compressed
|
Details |
User Agent: Mozilla/5.0 (Windows NT 10.0; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/57.0.2987.133 Safari/537.36 OPR/44.0.2510.1449
Steps to reproduce:
I made a test extension that use a browser_action button to send a msg from background.js to content.js
I load the extension with web-ext --verbose --firefox="C:\Program Files\Nightly\firefox.exe" run
I navigate to a web page
I click on the button test of the extension (no icone ... don't know why)
The console gives the error
Unchecked lastError value: Error: Could not establish connection. Receiving end does not exist.
if I load the addon via the temporary addon function in the about:debugging page in Nightly, and navigate to a new web page, the console gives the same error
If I pack the test extension with web-ext build, and I drag the zip archive on the add_on page, the message is sent correctly in the content script.
See also https://github.com/mozilla/web-ext/issues/938
I thought it was a web-ext bug, but the since loading the addon via the about:debugging page also fails they redirect me here. Strangely, the msg is correctly passed when the packed addon is dragged on the addon page
Actual results:
The console gives the error
Unchecked lastError value: Error: Could not establish connection. Receiving end does not exist.
Expected results:
The message "HHHHello from bkg" is displayed by content.js
Updated•9 years ago
|
Component: Untriaged → WebExtensions: General
Product: Firefox → Toolkit
Comment 1•9 years ago
|
||
You can only attach content scripts to regular http:// or https:// pages. Navigate to http://example.com before clicking the button, and it should work.
Status: UNCONFIRMED → RESOLVED
Closed: 9 years ago
Resolution: --- → INVALID
No it does not work
1) unzip the test addon
1) open about:debugging and load the addon as a temporary one, choosing the manifest.json
2) open example.com
3) open the console window of the browser
4) click on the button on the far right (no icon, but tooltip displaying test)
5) you see a) sending HHHHello from bkg background.js:21:8
b) Unchecked lastError value: Error: Could not establish connection. Receiving end does not exist.
Updated•8 years ago
|
Flags: needinfo?(lgreco)
Whiteboard: investigating
Comment 3•8 years ago
|
||
Hi rappazf,
The icon is missing because the 16px icon has been specified with the from path name (the actual file has a space in its name, "16 .png" but it is as "16.png" in the manifest.
I just tried the STR (using web-ext run, but it will not be different if I would load it from the about:debugging page) on both Firefox 53 and on a recent nightly and it is working as expected:
- as mentioned by :zombie in Comment 1, you can only attach content script to regular web pages (and so the "Error: Could not establish connection..." is going to be raised when the current tab is not a regulat webpage)
- with a regular webpage selected as the **current tab** (it is important that is the current tab, because the attached test extension is querying all the existent tabs and choosing the active one to attach a content script to it), when the browser_action is clicked, the expected log messages are logged in the console (both the one logged by the background page and the one logged by the content script).
Status: UNCONFIRMED → RESOLVED
Closed: 9 years ago → 8 years ago
Flags: needinfo?(lgreco)
Resolution: --- → INVALID
Hi Luca
Thanks for the comment and the correction. I agree the test works with FF53, but I can't still get it working when I load it in Nightly (FF55) if I load it directly, via load temporary add on. It works if I drag the zip file on the add on page. So if it's not something I'm doing wrong, it would be a difference between both versions.
Could you detail the steps you go through to see it working with FF55 when load it as a temporary add on ?
Cheers
François
Comment 5•8 years ago
|
||
(In reply to rappazf from comment #4)
> Hi Luca
> Thanks for the comment and the correction. I agree the test works with FF53,
> but I can't still get it working when I load it in Nightly (FF55) if I load
> it directly, via load temporary add on. It works if I drag the zip file on
> the add on page. So if it's not something I'm doing wrong, it would be a
> difference between both versions.
>
> Could you detail the steps you go through to see it working with FF55 when
> load it as a temporary add on ?
Yes, absolutely.
Here are the steps that I've executed to test this locally:
- downloaded and unpacked a recent Firefox Nightly build from https://www.mozilla.org/en-US/firefox/channel/desktop/
- downloaded and unpacked the attached test extension
- install and run the test extension as a temporarily installed addon:
web-ext run -s /path/to/unpacked/test-extension -f /path/to/nightly/firefox
- wait the Firefox Nightly to be started and open the browser console
- press the button while the current tab is not a regular webpage (e.g. a blank tab)
=> "sending HHHHello from bkg" console message logged from the background page
=> "Unchecked lastError value: Error: Could not establish connection. Receiving end does not exist." error logged
- load a regular webpage in the tab (e.g. example.com)
- press the button while the current tab is on a regular webpage
=> "sending HHHHello from bkg" console message logged from the background page
=> "Received form background in CS: HHHHello from bkg" console message logged from the content script
Thanks
This is what I would have do... and I still got the same error when the example page is loaded. I even uninstall and reinstall Nightly without any difference. With verbose, the output of web-ext is below, if there is any clue in it
François
U:\docs\xprog\mozff_we>web-ext run -s .\test -f "C:\Program Files\Nightly\firefox.exe" --verbose
[program.js][debug] Getting the version from package.json
[program.js][info] Version: 1.9.1
[program.js][debug] Getting the version from package.json
[cmd/run.js][info] Running web extension from U:\docs\xprog\mozff_we\test
[util/manifest.js][debug] Validating manifest at U:\docs\xprog\mozff_we\test\manifest.json
[cmd/run.js][debug] Creating new Firefox profile
[cmd/run.js][debug] Deferring extension installation until after connecting to the remote debugger
[firefox/index.js][debug] Running Firefox with profile at C:\Users\rappazf\AppData\Local\Temp\daa92369-ee46-4439-b937-07b05ed5bbea
[firefox/index.js][debug] Checking if remote Firefox port 6005 is available
[firefox/remote.js][debug] Connecting to Firefox on port 6005
[firefox/index.js][debug] Executing Firefox binary: C:\Program Files\Nightly\firefox.exe
[firefox/index.js][debug] Firefox args: -start-debugger-server 6005 -foreground -no-remote -profile C:\Users\rappazf\AppData\Local\Temp\daa92369-ee46-4439-b937-07b05ed5bbea
[firefox/index.js][info] Use --verbose or open Tools > Web Developer > Browser Console to see logging
[cmd/run.js][debug] Connecting to the remote Firefox debugger
[firefox/remote.js][debug] Connecting to Firefox on port 6005
[firefox/index.js][debug] Firefox stderr: JavaScript strict warning: resource://gre/modules/addons/XPIProvider.jsm, line 2696: ReferenceError: reference to undefined property "app-temporary"
[firefox/index.js][debug] Firefox stderr: JavaScript strict warning: resource://gre/modules/addons/XPIProvider.jsm, line 3783: ReferenceError: reference to undefined property "version"
[firefox/index.js][debug] Firefox stdout: Started debugger server on 6005
[firefox/remote.js][debug] Connected to the remote Firefox debugger on port 6005
[firefox/index.js][debug] Firefox stderr: Unable to read VR Path Registry from C:\Users\rappazf\AppData\Local\openvr\openvrpaths.vrpath
JavaScript strict warning: resource://gre/modules/commonjs/toolkit/loader.js -> resource://devtools/shared/security/socket.js, line 781: ReferenceError: reference to undefined property "_handshakeTimeout"
[firefox/remote.js][debug] installTemporaryAddon: {"addon":{"id":"test@rappazf.ch","actor":false},"from":"server1.conn0.addonsActor3"}
[firefox/remote.js][info] Installed U:\docs\xprog\mozff_we\test as a temporary add-on
[cmd/run.js][info] The extension will reload if any source file changes
[util/file-filter.js][debug] Resolved path **/*.xpi with sourceDir U:\docs\xprog\mozff_we\test to U:\docs\xprog\mozff_we\test\**\*.xpi
[util/file-filter.js][debug] Resolved path **/*.zip with sourceDir U:\docs\xprog\mozff_we\test to U:\docs\xprog\mozff_we\test\**\*.zip
[util/file-filter.js][debug] Resolved path **/.* with sourceDir U:\docs\xprog\mozff_we\test to U:\docs\xprog\mozff_we\test\**\.*
[util/file-filter.js][debug] Resolved path **/.*/**/* with sourceDir U:\docs\xprog\mozff_we\test to U:\docs\xprog\mozff_we\test\**\.*\**\*
[util/file-filter.js][debug] Resolved path **/node_modules with sourceDir U:\docs\xprog\mozff_we\test to U:\docs\xprog\mozff_we\test\**\node_modules
[util/file-filter.js][debug] Resolved path **/node_modules/**/* with sourceDir U:\docs\xprog\mozff_we\test to U:\docs\xprog\mozff_we\test\**\node_modules\**\*
[watcher.js][debug] Watching for file changes in U:\docs\xprog\mozff_we\test
[cmd/run.js][info] Press R to reload (and Ctrl-C to quit)
[firefox/index.js][debug] Firefox stderr: Unable to read VR Path Registry from C:\Users\rappazf\AppData\Local\openvr\openvrpaths.vrpath
[GPU 3508] WARNING: pipe error: 109: file c:/builds/moz2_slave/m-cen-w64-ntly-000000000000000/build/src/ipc/chromium/src/chrome/common/ipc_channel_win.cc, line 346
Unable to read VR Path Registry from C:\Users\rappazf\AppData\Local\openvr\openvrpaths.vrpath
[Child 9652] WARNING: pipe error: 109: file c:/builds/moz2_slave/m-cen-w64-ntly-000000000000000/build/src/ipc/chromium/src/chrome/common/ipc_channel_win.cc, line 346
[firefox/index.js][debug] Firefox stderr: JavaScript strict warning: resource://gre/modules/LightweightThemeConsumer.jsm, line 137: ReferenceError: reference to undefined property "additionalBackgrounds"
[firefox/index.js][debug] Firefox stderr: JavaScript strict warning: chrome://browser/content/tabbrowser.xml, line 672: ReferenceError: reference to undefined property "initialPageLoadedFromURLBar"
[firefox/index.js][debug] Firefox stderr: JavaScript strict warning: resource://gre/modules/commonjs/toolkit/loader.js -> resource://devtools/shared/node-properties/node-properties.js, line 134: ReferenceError: reference to undefined property "resume"
JavaScript strict warning: resource://gre/modules/commonjs/toolkit/loader.js -> resource://devtools/shared/node-properties/node-properties.js, line 124: ReferenceError: reference to undefined property "o"
JavaScript strict warning: resource://gre/modules/commonjs/toolkit/loader.js -> resource://devtools/shared/node-properties/node-properties.js, line 130: ReferenceError: reference to undefined property "o"
[firefox/index.js][debug] Firefox stderr: JavaScript strict warning: resource://gre/modules/ProfileAge.jsm, line 204: ReferenceError: reference to undefined property "reset"
[firefox/index.js][debug] Firefox stderr: JavaScript strict warning: resource://gre/modules/addons/XPIProvider.jsm, line 8120: ReferenceError: reference to undefined property "isSystem"
[firefox/index.js][debug] Firefox stderr: JavaScript strict warning: resource://gre/modules/commonjs/toolkit/loader.js -> resource://devtools/shared/client/main.js, line 981: ReferenceError: reference to undefined property "type"
[firefox/index.js][debug] Firefox stderr: JavaScript strict warning: resource://gre/modules/commonjs/toolkit/loader.js -> resource://devtools/client/shared/vendor/react.js, line 8370: SyntaxError: test for equality (==) mistyped as assignment (=)?
[firefox/index.js][debug] Firefox stderr: JavaScript strict warning: resource://gre/modules/commonjs/toolkit/loader.js -> resource://devtools/client/shared/vendor/react.js, line 12913: SyntaxError: test for equality (==) mistyped as assignment (=)?
[firefox/index.js][debug] Firefox stderr: JavaScript strict warning: resource://gre/modules/commonjs/toolkit/loader.js -> resource://devtools/client/shared/vendor/react.js, line 21443: SyntaxError: test for equality (==) mistyped as assignment (=)?
[firefox/index.js][debug] Firefox stderr: JavaScript strict warning: resource://gre/modules/commonjs/toolkit/loader.js -> resource://devtools/client/shared/vendor/react.js, line 11094: ReferenceError: reference to undefined property "$$typeof"
[firefox/index.js][debug] Firefox stderr: JavaScript strict warning: resource://gre/modules/commonjs/toolkit/loader.js -> resource://devtools/client/shared/vendor/react.js, line 5268: ReferenceError: reference to undefined property "propTypes"
JavaScript strict warning: resource://gre/modules/commonjs/toolkit/loader.js -> resource://devtools/client/shared/vendor/react.js, line 5351: ReferenceError: reference to undefined property "autobind"
[firefox/index.js][debug] Firefox stderr: JavaScript strict warning: resource://gre/modules/commonjs/toolkit/loader.js -> resource://devtools/client/shared/vendor/react.js, line 11094: ReferenceError: reference to undefined property "$$typeof"
[firefox/index.js][debug] Firefox stderr: JavaScript strict warning: resource://gre/modules/commonjs/toolkit/loader.js -> resource://devtools/client/shared/vendor/react.js, line 5268: ReferenceError: reference to undefined property "propTypes"
JavaScript strict warning: resource://gre/modules/commonjs/toolkit/loader.js -> resource://devtools/client/shared/vendor/react.js, line 5351: ReferenceError: reference to undefined property "autobind"
[firefox/index.js][debug] Firefox stderr: JavaScript strict warning: resource://gre/modules/commonjs/toolkit/loader.js -> resource://devtools/client/shared/vendor/react.js, line 11094: ReferenceError: reference to undefined property "$$typeof"
[firefox/index.js][debug] Firefox stderr: JavaScript strict warning: resource://gre/modules/commonjs/toolkit/loader.js -> resource://devtools/client/shared/vendor/react.js, line 5268: ReferenceError: reference to undefined property "propTypes"
JavaScript strict warning: resource://gre/modules/commonjs/toolkit/loader.js -> resource://devtools/client/shared/vendor/react.js, line 5351: ReferenceError: reference to undefined property "autobind"
[firefox/index.js][debug] Firefox stderr: JavaScript strict warning: resource://gre/modules/commonjs/toolkit/loader.js -> resource://devtools/client/shared/widgets/tooltip/HTMLTooltip.js, line 225: ReferenceError: reference to undefined property "type"
[firefox/index.js][debug] Firefox stderr: JavaScript strict warning: resource://gre/modules/commonjs/toolkit/loader.js -> resource://devtools/client/shared/widgets/tooltip/HTMLTooltip.js, line 311: ReferenceError: reference to undefined property "width"
[firefox/index.js][debug] Firefox stderr: JavaScript strict warning: resource://gre/modules/commonjs/toolkit/loader.js -> resource://devtools/client/webconsole/webconsole.js, line 2214: ReferenceError: reference to undefined property "level"
[firefox/index.js][debug] Firefox stderr: JavaScript strict warning: resource:///modules/PlacesUIUtils.jsm, line 159: ReferenceError: reference to undefined property "request"
Updated•7 years ago
|
Product: Toolkit → WebExtensions
You need to log in
before you can comment on or make changes to this bug.
Description
•