javascript - chrome.runtime.sendMessage error in Chrome version 57.0.2987 -


i've updated google chrome browser version: 56.0.2924 57.0.2987.

i have extension, , can not work in new version. debuged, , find reason chrome.runtime.sendmessage not work. send message in background page:

chrome.runtime.sendmessage({"name": event_enum.job_init, "data": job}); 

and have listener (the same background page):

chrome.runtime.onmessage.addlistener(    function (request, sender, sendresponse) {      if (request.name == event_enum.job_init) {               //do      }    }); 

my manifiest has surely injected these codes.

but after run chrome.runtime.sendmessage nothing happened. searched got no issue that. has same issue me? thank you

i don't know why works in 56.0.2924 because behavior changed intentionally long time ago in 49.0.2622.0, see crbug.com/479425 commit r369379:

never connect port same frame. connecting same frame not make sense because onmessage should not triggered same frame.

the fact worked after chrome 49 bug, fixed now.
same issue reported in crbug.com/704108 may star follow progress.


the solution, obviously, extract listener separate function:

function onmessage(message, sender, sendresponse) {     ......... }  chrome.runtime.onmessage.addlistener(onmessage); 

then call directly:

onmessage(.......); 

Comments

Popular posts from this blog

javascript - Clear button on addentry page doesn't work -

c# - Selenium Authentication Popup preventing driver close or quit -

tensorflow when input_data MNIST_data , zlib.error: Error -3 while decompressing: invalid block type -