fix(tracker): prevent raising security error accessing window.top (#2818)
* fix(tracker): prevent raising security error accessing window.top * fix(canAccessTop): check window document access
This commit is contained in:
parent
27e94fed35
commit
844b9d80c3
1 changed files with 2 additions and 2 deletions
|
|
@ -97,7 +97,7 @@ function processOptions(obj: any): obj is Options {
|
|||
|
||||
const canAccessTop = () => {
|
||||
try {
|
||||
return Boolean(window.top)
|
||||
return Boolean(window.top?.document)
|
||||
} catch {
|
||||
return false
|
||||
}
|
||||
|
|
@ -116,7 +116,7 @@ export default class API {
|
|||
}
|
||||
if (
|
||||
(window as any).__OPENREPLAY__ ||
|
||||
(!this.crossdomainMode && inIframe() && canAccessTop() && (window.top as any)?.__OPENREPLAY__)
|
||||
(!this.crossdomainMode && inIframe() && canAccessTop() && (window.top as any).__OPENREPLAY__)
|
||||
) {
|
||||
console.error('OpenReplay: one tracker instance has been initialised already')
|
||||
return
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue