Aaronius / penpal

A promise-based library for securely communicating with iframes via postMessage.
MIT License
381 stars 56 forks source link

Remove check that determines if `connectToParent` is running inside iframe #61

Closed Aaronius closed 3 years ago

Aaronius commented 3 years ago

When calling connectToParent, Penpal checks to see if it is running inside an iframe and, if not, throws a NotInIframe error to make you aware of the problem. While this can be helpful, it causes problems when Penpal is running within a Cypress test. While there's a workaround available by disabling modifyObstructiveCode in Cypress, that can potentially cause other issues if some other JavaScript is attempting to framebust and Cypress actually needs to modify that obstructive code.

While the check Penpal provides can be helpful, developers are probably unlikely to call connectToParent outside of an iframe and they would probably notice the problem pretty easily without the check in place.

To avoid this problems with Cypress entirely and to avoid yet another configuration option, I propose removing the check from Penpal entirely. This will require a major version, however.

Aaronius commented 3 years ago

This was released in v6.