salesforce/near-membrane

Implement workaround for FF bug 543435: window.document instance replacement for blank pages

Closed this issue · 1 comments

This is the link to the original bug in FF:
https://bugzilla.mozilla.org/show_bug.cgi?id=543435

Since this bug is not going to be fixed, we need a workaround for the cases when keepAlive is set to true. Which causes a problem in the membrane since the identity of the document changes at the macrotask, and it is not the original identity after creation that is mapped to the outer window document.

@jdalton came up with a quick solution to this problem, which is tested here:
https://jsbin.com/segokef/1/edit?html,js,console,output

Basically, after creation and insertion of the iframe, just use document.open().close() in the iframe, that forces FF to never replace the document because it might have been mutated, which means the identity of the document will remain the same forever.

Nice and creative solution @jdalton! 🥇