opener is undefined in popup

Confirmed Issue #11324352 • Assigned to Travis L.

Details

Author
David G.
Created
Mar 19, 2017
Privacy
This issue is public.
Found in
  • Microsoft Edge
Found in build #
38.14393
Reports
Reported by 2 people

Sign in to watch or report this issue.

Steps to reproduce

From one window, open another window:

$('a#popup').on('click', function(event) {
    event.preventDefault();
    $this = $(this);
    authenticationWindow = window.open($this.href, 'authenticationPopup');
});

In the first window, add an event listener for message event:

window.addEventListener('message', function (evt) {
    // simplified, should check for evt.origin, and check message to decide what to do
    authenticationWindow.close();
});

From the second window, perform a login on a different domain, which redirects back to a dummy page on the opener domain, which only posts a message to the opener window:

opener.postMessage('ok', window.location.protocol+'//'+window.location.host);
// note, document.domain and opener.document.domain are the same, including protocol
// for old IE, after a timeout the window closes automatically

In this case opener was undefined (!). opener stays defined across navigation on every other browser, even IE(!), while in this case in Edge it becomes undefined.

For backwards compatibility with older IE, I made a check like if (window.addEventListener) to attach the message event listener, and added a timeout in case it’s not supported. I tried using this technique with Edge too: every second it check if (authenticationWindow.closed), but Edge always returns true even if the popup is still open!! So I found no workaround for this. Also, the popupWindow.closed always equals true sounds like another bug!!

Attachments

0 attachments

    Comments and activity

    • Changed Title from “opener.postMessage does not work” to “opener is undefined in popup”

    • I just found out that it behaves correctly if the popup window always stays on the same protocol, if it switches from https to http, then opener gets unset.

      Is this a documented behaviour?

    • Microsoft Edge Team

      Changed Assigned To to “Steven K.”

    • Are you also planning to support rel="noopener" while fixing this bug ?

    • Microsoft Edge Team

      Changed Status to “Confirmed”

      Changed Assigned To to “Travis L.”

    You need to sign in to your Microsoft account to add a comment.

    Sign in