From afe6fc847155294d1a8dc1bef98857e9cc96a94c Mon Sep 17 00:00:00 2001 From: Bob Fanger Date: Sun, 12 Mar 2023 15:15:24 +0100 Subject: [PATCH] fix: Ignore iframes where access is blocked by CORS Related #105 Prevents `Blocked a frame with origin ... from accessing a cross-origin frame.` errors --- packages/pixi-panel/src/connect.ts | 8 ++++++-- packages/pixi-panel/src/pixi-devtools/pixiDevtools.ts | 8 ++++++-- 2 files changed, 12 insertions(+), 4 deletions(-) diff --git a/packages/pixi-panel/src/connect.ts b/packages/pixi-panel/src/connect.ts index 4628d9f..0cf3f98 100644 --- a/packages/pixi-panel/src/connect.ts +++ b/packages/pixi-panel/src/connect.ts @@ -18,8 +18,12 @@ function detect() { } if (win.frames) { for (let i = 0; i < win.frames.length; i += 1) { - if (win.frames[i][varname]) { - return true; + try { + if (win.frames[i][varname]) { + return true; + } + } catch (_) { + // access to iframe was denied } } } diff --git a/packages/pixi-panel/src/pixi-devtools/pixiDevtools.ts b/packages/pixi-panel/src/pixi-devtools/pixiDevtools.ts index 6a59e04..d265f30 100644 --- a/packages/pixi-panel/src/pixi-devtools/pixiDevtools.ts +++ b/packages/pixi-panel/src/pixi-devtools/pixiDevtools.ts @@ -16,8 +16,12 @@ export default function pixiDevtools() { } if (win.frames) { for (let i = 0; i < win.frames.length; i += 1) { - if (win.frames[i][varname]) { - return win.frames[i][varname]; + try { + if (win.frames[i][varname]) { + return win.frames[i][varname]; + } + } catch (_) { + // access to iframe was denied } } }