'window.opener reference lost in Firefox
Consider the following case:
- Step 1: Website A opens Website B in a new tab (At this point Website B has its opener window reference i.e Website A window object in window.opener).
- Step 2: Website B redirects to Website C (We have window.opener referencing Website A window here too).
- Step 3: Then Website C performs some authentication and redirects back to Website B. At this step 3 the window.opener has the reference of the current window object i.e window object of Website B itself (window.opener === window) and we’ve lost reference to the original opener (i.e Website A window object). We need the window.opener object for communicating with Website A using postMessage.
Visual reperesentation of steps
Note: We don’t have control over Website C and can’t control how they’re redirecting back to Website B. Also this is happening only on Firefox/Safari. On Chrome we're able to get the original opener reference after redirections.
In case Website C is redirecting with rel=noopener the window.opener should be null (Reference from MDN). I’m not able to understand in which case the window.opener can be the current window object and why it is happening on Firefox/Safari but not on Chrome? And is there anything we can do anywhere except Website C to prevent this?
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|
