From 5dd91211aec019875b7672f4a862b7df18b01ab8 Mon Sep 17 00:00:00 2001 From: Raymond Hill Date: Wed, 1 Sep 2021 18:25:20 -0400 Subject: [PATCH] Catch exceptions thrown Object.defineProperty Related issue: - https://github.com/uBlockOrigin/uAssets/issues/9883 Related commit: - https://github.com/gorhill/uBlock/commit/a9e6f9c72c920d68a6e5b01b844ad39e6f2e02b0 --- assets/resources/scriptlets.js | 31 +++++++++++++++++-------------- 1 file changed, 17 insertions(+), 14 deletions(-) diff --git a/assets/resources/scriptlets.js b/assets/resources/scriptlets.js index 06f6d3913..f1e3a8aa1 100644 --- a/assets/resources/scriptlets.js +++ b/assets/resources/scriptlets.js @@ -932,21 +932,24 @@ prevSetter = odesc.set; } } - Object.defineProperty(owner, prop, { - configurable, - get() { - if ( prevGetter !== undefined ) { - prevGetter(); + try { + Object.defineProperty(owner, prop, { + configurable, + get() { + if ( prevGetter !== undefined ) { + prevGetter(); + } + return handler.getter(); // cValue + }, + set(a) { + if ( prevSetter !== undefined ) { + prevSetter(a); + } + handler.setter(a); } - return handler.getter(); // cValue - }, - set(a) { - if ( prevSetter !== undefined ) { - prevSetter(a); - } - handler.setter(a); - } - }); + }); + } catch(ex) { + } }; const trapChain = function(owner, chain) { const pos = chain.indexOf('.');