window.postMessage event can be cancelled in listener
Reported by
drol...@yahoo.com,
Jul 4 2016
|
||||
Issue description
Chrome Version : 51.0.2704.106
OS Version:
URLs (if applicable) :
Other browsers tested:
Add OK or FAIL after other browsers where you have tested this issue:
Safari 5:
Firefox 4.x:
IE 7/8/9:
What steps will reproduce the problem?
1. Add two message event listeners to an iframeWindow
2. In the first listener attached, call event.stopImmediatePropagation
3. call iframe.contentWindow.postMessage()
What is the expected result?
Both listeners should be called with the postMessage event.
What happens instead of that?
Only the first listener is called. It seems the event was cancelled by the first listener. I thought that message events were not cancelable (https://developer.mozilla.org/en-US/docs/Web/Events/message)
Please provide any additional information below. Attach a screenshot if
possible.
Here is a related question that I started at stackoverflow to figure this out.
http://stackoverflow.com/questions/38103534/in-chrome-extension-how-to-send-a-cross-origin-message-from-a-parent-content-sc
I ran this test using the developer's console command line.
UserAgentString: Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/51.0.2704.106 Safari/537.36
,
Jul 5 2016
,
Jul 12 2016
Cancellable means that the default action is prevented. For example, the default action of click events on anchors is to navigate to a URL. stopImmediatePropogation is an internal event concept where the propagation of the event itself stops, unrelated to the default action. Say, <a href="/" onclick="event.stopImmediatePropagation()">a</a> would still navigate, but the event will not fire on document (or even on that anchor, for the rest of the listeners, after that listener is called). Does Firefox ignore stopImmediatePropagation?
,
Jul 13 2016
I tested it on Firefox and it works the same as Chrome. From your explanation, it sounds like that is the expected behavior. To deal with this (other scripts calling stop propagation on my messages and my listener never receiving them), I've injected my script at document_start (scripts are part of a chrome extension) and attached my listener before they can.
,
Jan 10 2017
Yep, seems like it's working as intended. |
||||
►
Sign in to add a comment |
||||
Comment 1 by drol...@yahoo.com
, Jul 4 2016