Page 1 of 1

Patch window.opener if present

Posted: Mon Mar 15, 2021 8:25 am
by skriptimaahinen
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.

Re: Patch window.opener if present

Posted: Mon Mar 15, 2021 7:12 pm
by Giorgio Maone
Everything very reasonable. Probably unneeded under most circumstances, rolling back.

Re: Patch window.opener if present

Posted: Tue Mar 16, 2021 8:49 am
by Giorgio Maone
Done, with an unfortunate attribution mistake which I've tried to correct as much as I could.
Sorry for the confusion and thanks again.