-
Notifications
You must be signed in to change notification settings - Fork 142
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* detectInIframe fn fix * detectInIframe renamed to the more accurate (if lengthy!) detectInIframeInAccessibleDomain * adding changeset file * changed import in unit test * Changed check for reading window.parent.location * Clarified function name and purpose (via comments) * update comment in changeset file
- Loading branch information
Showing
5 changed files
with
24 additions
and
6 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
--- | ||
'@adyen/adyen-web': patch | ||
--- | ||
|
||
Renaming detectInIframe to the more accurate, but lengthy, detectInIframeInSameOrigin. | ||
Now the functionality only considers itself to be running in an iframe _if_ it is possible to access the parent domain and thus be able to redirect the top, parent, window |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
/** | ||
* Returns true if the page is being run in an iframe with the same origin as the parent. | ||
* In this scenario, if the merchant has set redirectFromTopWhenInIframe: true, then we can perform the redirect on the top level, parent, window; | ||
* rather than on the iframe's window | ||
*/ | ||
export default () => { | ||
try { | ||
if (window.parent.location.href) { | ||
return window.location !== window.parent.location; // iframe check: locations will differ if we're in an iframe | ||
} | ||
} catch (e) { | ||
return false; // we cannot access window.parent.location.href - so consider us "not to be in an iframe" for the purpose of Redirects | ||
} | ||
}; |