@@ -431,7 +431,7 @@ function objectPruneFn(
431
431
? safe . String_split . call ( rawNeedlePaths , / + / )
432
432
: [ ] ;
433
433
if ( stackNeedleDetails . matchAll !== true ) {
434
- if ( matchesStackTrace ( stackNeedleDetails , extraArgs . logstack ) === false ) {
434
+ if ( matchesStackTraceFn ( stackNeedleDetails , extraArgs . logstack ) === false ) {
435
435
return ;
436
436
}
437
437
}
@@ -531,13 +531,13 @@ function objectFindOwnerFn(
531
531
532
532
builtinScriptlets . push ( {
533
533
name : 'matches-stack-trace.fn' ,
534
- fn : matchesStackTrace ,
534
+ fn : matchesStackTraceFn ,
535
535
dependencies : [
536
536
'get-exception-token.fn' ,
537
537
'safe-self.fn' ,
538
538
] ,
539
539
} ) ;
540
- function matchesStackTrace (
540
+ function matchesStackTraceFn (
541
541
needleDetails ,
542
542
logLevel = ''
543
543
) {
@@ -1169,13 +1169,13 @@ function abortOnStackTrace(
1169
1169
let v = owner [ chain ] ;
1170
1170
Object . defineProperty ( owner , chain , {
1171
1171
get : function ( ) {
1172
- if ( matchesStackTrace ( needleDetails , extraArgs . log ) ) {
1172
+ if ( matchesStackTraceFn ( needleDetails , extraArgs . log ) ) {
1173
1173
throw new ReferenceError ( getExceptionToken ( ) ) ;
1174
1174
}
1175
1175
return v ;
1176
1176
} ,
1177
1177
set : function ( a ) {
1178
- if ( matchesStackTrace ( needleDetails , extraArgs . log ) ) {
1178
+ if ( matchesStackTraceFn ( needleDetails , extraArgs . log ) ) {
1179
1179
throw new ReferenceError ( getExceptionToken ( ) ) ;
1180
1180
}
1181
1181
v = a ;
@@ -3447,6 +3447,7 @@ builtinScriptlets.push({
3447
3447
requiresTrust : true ,
3448
3448
fn : trustedSuppressNativeMethod ,
3449
3449
dependencies : [
3450
+ 'matches-stack-trace.fn' ,
3450
3451
'proxy-apply.fn' ,
3451
3452
'safe-self.fn' ,
3452
3453
] ,
@@ -3458,9 +3459,8 @@ function trustedSuppressNativeMethod(
3458
3459
stack = ''
3459
3460
) {
3460
3461
if ( methodPath === '' ) { return ; }
3461
- if ( stack !== '' ) { return ; }
3462
3462
const safe = safeSelf ( ) ;
3463
- const logPrefix = safe . makeLogPrefix ( 'trusted-suppress-native-method' , methodPath , signature , how ) ;
3463
+ const logPrefix = safe . makeLogPrefix ( 'trusted-suppress-native-method' , methodPath , signature , how , stack ) ;
3464
3464
const signatureArgs = safe . String_split . call ( signature , / \s * \| \s * / ) . map ( v => {
3465
3465
if ( / ^ " .* " $ / . test ( v ) ) {
3466
3466
return { type : 'pattern' , re : safe . patternToRegex ( v . slice ( 1 , - 1 ) ) } ;
@@ -3478,6 +3478,7 @@ function trustedSuppressNativeMethod(
3478
3478
return { type : 'exact' , value : undefined } ;
3479
3479
}
3480
3480
} ) ;
3481
+ const stackNeedle = safe . initPattern ( stack , { canNegate : true } ) ;
3481
3482
proxyApplyFn ( methodPath , function ( context ) {
3482
3483
const { callArgs } = context ;
3483
3484
if ( signature === '' ) {
@@ -3499,6 +3500,11 @@ function trustedSuppressNativeMethod(
3499
3500
}
3500
3501
}
3501
3502
}
3503
+ if ( stackNeedle . matchAll !== true ) {
3504
+ if ( matchesStackTraceFn ( stackNeedle ) === false ) {
3505
+ return context . reflect ( ) ;
3506
+ }
3507
+ }
3502
3508
if ( how === 'debug' ) {
3503
3509
debugger ; // eslint-disable-line no-debugger
3504
3510
return context . reflect ( ) ;
0 commit comments