New issue
Advanced search Search tips
Note: Color blocks (like or ) mean that a user may not be available. Tooltip shows the reason.

Issue 704108 link

Starred by 2 users

Issue metadata

Status: WontFix
Owner:
Closed: Mar 2017
Cc:
Components:
EstimatedDays: ----
NextAction: ----
OS: Linux , Windows , Mac
Pri: 2
Type: Bug-Regression



Sign in to add a comment

Chrome extension API chrome.runtime.sendMessage does not trigger chrome.runtime.onMessage handler when triggered in a background script

Reported by daniel.h...@gmail.com, Mar 22 2017

Issue description

UserAgent: Mozilla/5.0 (Windows NT 10.0; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/57.0.2987.110 Safari/537.36

Steps to reproduce the problem:
1. Unzip the reduced test case file
2. Open Chromium/Chrome and navigate to chrome://extensions
3. Tick Developer mode
4. Click 'Load unpacked extension...'
5. Select the unzipped directory from step 1.
6. Under the 'Bug Test Case' extension, click on 'background page'
7. Open a new tab in chrome/chromium and navigate to 'https://www.google.com'
8. On the background page opened in step 6. view the 'Console' tab.
9. Take note that 'chrome.runtime.sendMessage is being called' is in the console output.
10. Navigate to the 'Sources' tab.
11. Expand the 'top' node in the Sources tab in the left most pane.
12. Expand the node with the extension id as its name, this will look like 'mgjliodkoojfbalbkliihnigmepipnglc'.
13. Click on 'background.js'.
14. Take note that there is a chrome.runtime.onMessage listener listening for incoming messages.
15. Take note that if the processIncomingRequest function is the assigned handler for chrome.runtime.onMessage call at line 23.

What is the expected behavior?
It would be expected that the console would display

'chrome.runtime.sendMessage is being called'

followed by
'Message Received'

What went wrong?
This is unknown.

Did this work before? Yes 56.0.2987.110

Does this work in other browsers? Yes

Chrome version: 57.0.2987.110  Channel: stable
OS Version: 10.0
Flash Version: Shockwave Flash 25.0 r0
 
Chrome Bug.zip
1.3 KB Download

Comment 1 by woxxom@gmail.com, Mar 23 2017

I don't know why it works for you in 56.0.2987.110 because this behavior was changed intentionally long time ago in r369379 (49.0.2622.0,  issue 479425 ):

	Never connect a port to the same frame.
	Connecting to the same frame does not make sense because onMessage
	should not be triggered for the same frame.
Cc: rob@robwu.nl brajkumar@chromium.org
Components: Platform>Extensions
Labels: Needs-Feedback
Tested this issue on Windows-10 using chrome stable #57.0.2987.110 and older version of chrome #56.0.2888.0 by following steps mentioned in the original comment. By opening the background page in console observed there is no message called as mentioned in the step-9 on both the versions.

daniel@ Do you remember exactly on which version it used to work before? Because the provide M56 is a wrong version.

Thanks!
@brajkumar
As it happens I do. The version this definitely worked under is 56.0.2987.110.

Now the very strange thing I've noticed is that it does indeed work under versions lower than 49.0.2622.0 and above it does not, however I have only confirmed this with builds available from https://www.slimjet.com/chrome/google-chrome-old-version.php. 

However it most definitely worked on my work machine version 56.0.2987.110, the difference being that it is not a portable build of chrome, it is installed in the windows environment. This is also true for a number of other machines within my department.

The code in the example is similar to what I'm using on an internally developed extension. I can confirm that the code in question was working prior to 57.0.2987.110 on an installed version of chrome.

If I had to guess at the cause in light of the change to prevent connecting to a port on the same frame, I'd wager that the bug I've submitted is not a bug, it seems to be working as intended according to the chrome change log. Rather perhaps the Chrome update process hasn't been working correctly on multiple windows machines.




Project Member

Comment 4 by sheriffbot@chromium.org, Mar 23 2017

Labels: -Needs-Feedback
Thank you for providing more feedback. Adding requester "brajkumar@chromium.org" to the cc list and removing "Needs-Feedback" label.

For more details visit https://www.chromium.org/issue-tracking/autotriage - Your friendly Sheriffbot
Just to confirm,

I just had a colleague test this on an installed version of Google Chrome on their own machine.

Version 56.0.2924.87 (64-bit) running under Windows 10 x64. That version is sending and receiving messages on the same frame.

Now this is a relatively easy fix in the context of my extension. I can just include my own messaging mechanism using a messaging object. 

That said, this could be a breaking change for people who have relied on this behaviour and the docs should probably be updated to reflect that.
Labels: Needs-Triage-M57
Cc: -rob@robwu.nl
Labels: -Needs-Triage-M57 M-59 OS-Linux OS-Mac
Owner: rob@robwu.nl
Status: Assigned (was: Unconfirmed)
Able to reproduce the issue on Win 10,Mac 10.12.3 and Ubuntu 14.04 using 57.0.2987.110 and canary 59.0.3054.0.
This is regressed in M49 as below.

Bisect info:
===========
good: 49.0.2621.0(369282)
bad : 49.0.2622.0(369639)
You are probably looking for a change made after 369367 (known good), but no later than 369385 (first known bad).
CHANGELOG URL:
  https://chromium.googlesource.com/chromium/src/+log/adb4d725348d5816c78144458d8ce8ca19d3faee..bb42dee07a4a8df5dfa5ad33378b877e7b2944f3
Possible suspect:Review URL: https://codereview.chromium.org/1588533002
rob@robwu.nl : Could you please review the above and update further.
Labels: hasbisect-per-revision

Comment 9 by rob@robwu.nl, Mar 29 2017

Status: WontFix (was: Assigned)
The behavior is intentional and documented (see docs of messaging and chrome.runtime.sendMessage). If you want to notify scripts in the current context, then there are many alternatives that are way more efficient than chrome.runtime.sendMessage.

The intended behavior did not always happen, but this has been fixed a long time ago (see  bug 628083 ,  bug 597698  and the bugs linked by the last bug).
@rob just as an FYI, the fact that this behaviour is exhibited in later versions when it should not is a bug, yes?

Comment 11 by rob@robwu.nl, Mar 29 2017

Contrary to what the report claims, onMessage is not triggered in 56.0.2924.87 (which does not differ that much from 66.0.2924.110).

#10 Can you provide the steps that you have followed to observe the behavior that you're seeing, including a sample extension and the browser version?
@rob My original report, attachment and follow up comments are accurate and I've managed to demonstrate this across multiple machines.

This behaviour is exhibited on multiple machines in my place of work spanning a few versions of Chrome which I've already specified.

I initially thought that as Chrome stop responding to onMessage events sent from the same frame that the bug was that it does not respond to the events.

It turns out that as this is intended behaviour, the bug is the exact opposite. Chrome has been responding to messages from the same frame over many updates since it was changed to not respond.

The problem seems to occur on installed (non portable) versions of Chrome that have self updated. Some versions seem to respond to messages from the same frame, it stopped working for my own machine when chrome updated itself to 57.x.

If you're testing against previous builds of chrome that are portable, the portable editions do not exhibit this behaviour. Only self updating installed versions do. So this bug may be a symptom of a problem with the self update process?

Comment 13 by rob@robwu.nl, Mar 29 2017

Odd. Since you say that it is already fixed in the latest version, I won't investigate it further though.
@rob considering this could be a wider more severe bug affecting millions of chrome installations globally, especially if the issue is update process related I would at least suggest entertaining the prospect of investigation of the cause. 

Bugs do not fix themselves. What if other security enhancements are also not being deployed correctly on chrome client updates? I realise this is speculation but it certainly warrants investigation to rule it out.

Comment 15 by rob@robwu.nl, Mar 29 2017

So are you able to consistently reproduce this issue, even on a completely new Chrome profile? If yes, provide the exact steps (maybe even archive and mail/share the Chrome version that you're using) so I can reproduce it too. Otherwise I don't have enough information to debug the issue.

Sign in to add a comment