Patch window.opener if present
Posted: Mon Mar 15, 2021 8:25 am
This flew under my radar.
Few notes:
1. window.opener is not a fresh window and _should_ always be patched before a new window can be opened (AFAIK).
2. If the opener and opened windows are not same-origin, trying to get canvas context will result in cross-origin block, whether opener is patched or not.
3. On same-origin cases this does indeed prevent getting the context, but there is a side-effect.
Assume user has allowed webgl on example.com/subpage but not on example.com. If the user now navigates from the subpage to example.com (e.g. window.open("example.com")), the window patcher will also patch the window.opener (that is the window of example.com/subpage) with the rules of example.com. This will prevent the scripts in example.com/subpage from getting any new canvas contexts, possibly breaking the pages functionality.
Also note that if the example.com/subpage is reloaded to restore the functionality, window.opener in example.com will now point to a non-patched window.
Few notes:
1. window.opener is not a fresh window and _should_ always be patched before a new window can be opened (AFAIK).
2. If the opener and opened windows are not same-origin, trying to get canvas context will result in cross-origin block, whether opener is patched or not.
3. On same-origin cases this does indeed prevent getting the context, but there is a side-effect.
Assume user has allowed webgl on example.com/subpage but not on example.com. If the user now navigates from the subpage to example.com (e.g. window.open("example.com")), the window patcher will also patch the window.opener (that is the window of example.com/subpage) with the rules of example.com. This will prevent the scripts in example.com/subpage from getting any new canvas contexts, possibly breaking the pages functionality.
Also note that if the example.com/subpage is reloaded to restore the functionality, window.opener in example.com will now point to a non-patched window.