browser.runtime.connect api not working as expected with Firefox for android? -


i developing extension firefox android, since tabs apis not supported on firefox(android), using following code. working fine on firefox when porting firefox android(52 version), background script messages not being passed content script listener.

//content script code

var myport = browser.runtime.connect({name:"port-from-cs"}); myport.postmessage({greeting: "hello content script"});  myport.onmessage.addlistener(function(m) {   console.log("in content script, received message background script: ");   console.log(m.greeting); }); 

// background script

var portfromcs;  function connected(p) {   portfromcs = p;   portfromcs.postmessage({greeting: "hi there content script!"});   portfromcs.onmessage.addlistener(function(m) {     console.log("in background script, received message content script")     console.log(m.greeting);     portfromcs.postmessage({greeting: "hi there content script!"});   }); }  browser.runtime.onconnect.addlistener(connected); 

//manifest

{   "version": "0.1.5",   "content_scripts": [     {       "js": [         "js/mycontentscript.js",         "js/lib/jquery-1.9.1.min.js"       ],       "matches": [         "<all_urls>"       ],       "run_at": "document_start"     }   ],   "description": "xxx",   "manifest_version": 2,   "name": "xx",   "applications": {       "gecko": {           "id": "vpt@mozilla.org"        }   },   "permissions": [     "webrequest",     "notifications",     "http://*/",     "https://*/",     "storage",     "webrequestblocking"   ],   "background": {     "scripts": [       "js/background.js"     ]   },   "web_accessible_resources": [     "xxx.js"   ] } 

content script passing message background script, background script messages caught portfromcs.onmessage listener. approach correct?


Comments

Popular posts from this blog

python - PyInstaller UAC not working in onefile mode -

ios - Pass NSDictionary from Javascript to Objective-c in JavascriptCore -

wso2is - WSO2 IS 5.0.0 SP1 After restart there is authentication error -