From 714a4fbb7349c69e4dbb4521c03e0ab5ccbf0960 Mon Sep 17 00:00:00 2001 From: Krzysztof Grziwok Date: Thu, 10 Dec 2020 15:02:42 +0100 Subject: [PATCH] Catch Security Errors in styleSheet rules (#437) --- .gitignore | 1 + src/replay/index.ts | 21 ++++++++++++++------- 2 files changed, 15 insertions(+), 7 deletions(-) diff --git a/.gitignore b/.gitignore index 72d4650bbc..ceafb63633 100644 --- a/.gitignore +++ b/.gitignore @@ -1,4 +1,5 @@ .vscode +.idea node_modules package-lock.json # yarn.lock diff --git a/src/replay/index.ts b/src/replay/index.ts index 6f2f7a604b..700bef19e5 100644 --- a/src/replay/index.ts +++ b/src/replay/index.ts @@ -849,16 +849,23 @@ export class Replayer { if (d.adds) { d.adds.forEach(({ rule, index }) => { - const _index = - index === undefined - ? undefined - : Math.min(index, styleSheet.rules.length); try { - styleSheet.insertRule(rule, _index); + const _index = + index === undefined + ? undefined + : Math.min(index, styleSheet.rules.length); + try { + styleSheet.insertRule(rule, _index); + } catch (e) { + /** + * sometimes we may capture rules with browser prefix + * insert rule with prefixs in other browsers may cause Error + */ + } } catch (e) { /** - * sometimes we may capture rules with browser prefix - * insert rule with prefixs in other browsers may cause Error + * accessing styleSheet rules may cause SecurityError + * for specific access control settings */ } });