@@ -52,6 +52,24 @@ test('AG prevent-eval-if works', (assert) => {
52
52
assert . strictEqual ( secondActual , undefined , 'result of eval evaluation should be undefined' ) ;
53
53
} ) ;
54
54
55
+ test ( 'AG prevent-eval-if works, check toString' , ( assert ) => {
56
+ const originalEvalString = window . eval . toString ( ) ;
57
+
58
+ runScriptlet ( name , [ '/adblock/' ] ) ;
59
+
60
+ const agPreventEvalIf = 'agPreventEvalIf' ;
61
+
62
+ const evalWrapper = eval ;
63
+ const firstActual = evalWrapper ( `(function () {return '${ agPreventEvalIf } '})()` ) ;
64
+ assert . strictEqual ( window . hit , undefined , 'hit function should not fire for not matched function' ) ;
65
+ assert . strictEqual ( firstActual , agPreventEvalIf , 'result of eval evaluation should exist' ) ;
66
+
67
+ const secondActual = evalWrapper ( `(function () {const adblock = true; return '${ agPreventEvalIf } '})()` ) ;
68
+ assert . strictEqual ( window . hit , 'FIRED' , 'hit function should fire' ) ;
69
+ assert . strictEqual ( secondActual , undefined , 'result of eval evaluation should be undefined' ) ;
70
+ assert . strictEqual ( window . eval . toString ( ) , originalEvalString , 'toString should not be changed' ) ;
71
+ } ) ;
72
+
55
73
test ( 'does not work -- invalid regexp pattern' , ( assert ) => {
56
74
runScriptlet ( name , [ '/\\/' ] ) ;
57
75
0 commit comments