Consider this testcase:
<script>
onmessage = function() {
window.open(...)
}
</script>
<iframe src="some-url"></iframe>
where some-url looks like this
<button onclick="parent.postMessage(..., '*')">Open Popup</button>
As I understand, if one clicks the button of the iframe, the event handler of the parent frame will be able to open a popup, because the algorithm is triggered by user activation:
https://html.spec.whatwg.org/multipage/interaction.html#triggered-by-user-activation
https://html.spec.whatwg.org/multipage/browsers.html#popup-blocker
That seems to be how it is implemented in browsers. However browsers behave differently when the message is instead passed by MessagePort (or BroadcastChannel): http://output.jsbin.com/cidetu
I wonder if the spec should be more explicit about how to handle these cases. I see there are similar discussions elsewhere in e.g. #4730
Tentative WPT test (manual because limitation with wpt infra): web-platform-tests/wpt#11668
WebKit bug: https://bugs.webkit.org/show_bug.cgi?id=186593#c3
Chromium bug: https://bugs.chromium.org/p/chromium/issues/detail?id=851493
Gecko bug: https://bugzilla.mozilla.org/show_bug.cgi?id=1469422
Consider this testcase:
where some-url looks like this
As I understand, if one clicks the button of the iframe, the event handler of the parent frame will be able to open a popup, because the algorithm is triggered by user activation:
https://html.spec.whatwg.org/multipage/interaction.html#triggered-by-user-activation
https://html.spec.whatwg.org/multipage/browsers.html#popup-blocker
That seems to be how it is implemented in browsers. However browsers behave differently when the message is instead passed by MessagePort (or BroadcastChannel): http://output.jsbin.com/cidetu
I wonder if the spec should be more explicit about how to handle these cases. I see there are similar discussions elsewhere in e.g. #4730
Tentative WPT test (manual because limitation with wpt infra): web-platform-tests/wpt#11668
WebKit bug: https://bugs.webkit.org/show_bug.cgi?id=186593#c3
Chromium bug: https://bugs.chromium.org/p/chromium/issues/detail?id=851493
Gecko bug: https://bugzilla.mozilla.org/show_bug.cgi?id=1469422