From f11b1a141e6d33d1034a74d533417d79db3980e5 Mon Sep 17 00:00:00 2001 From: Kevin Schaaf Date: Mon, 9 Jul 2018 21:33:59 -0700 Subject: [PATCH] Catch errors on top window using on error Works around safari quirk when running in iframe --- test/unit/strict-template-policy.html | 45 ++++++++++++++++++++------- 1 file changed, 34 insertions(+), 11 deletions(-) diff --git a/test/unit/strict-template-policy.html b/test/unit/strict-template-policy.html index 4c5d64335b..bfb697dc32 100644 --- a/test/unit/strict-template-policy.html +++ b/test/unit/strict-template-policy.html @@ -18,10 +18,11 @@ // Errors thrown in custom element reactions are not thrown up // the call stack to the dom methods that provoked them, so need // to catch them here and prevent mocha from complaining about them - window.addEventListener('error', function(event) { + window.addEventListener('error', event => { + event.preventDefault(); event.stopImmediatePropagation(); - if (!window.globalError) { - window.globalError = event; + if (!window.uncaughtError) { + window.uncaughtError = event; } }); @@ -38,7 +39,7 @@ try { callback(); } catch(error) { - window.globalError = error; + window.onerror(error); } }); }; @@ -72,24 +73,46 @@