File tree 3 files changed +28
-3
lines changed
3 files changed +28
-3
lines changed Original file line number Diff line number Diff line change @@ -21,7 +21,7 @@ export class FunctionToString implements Integration {
21
21
originalFunctionToString = Function . prototype . toString ;
22
22
23
23
Function . prototype . toString = function ( this : WrappedFunction , ...args : any [ ] ) : string {
24
- const context = this . __sentry__ ? this . __sentry_original__ : this ;
24
+ const context = this . __sentry_original__ || this ;
25
25
// tslint:disable-next-line:no-unsafe-any
26
26
return originalFunctionToString . apply ( context , args ) ;
27
27
} ;
Original file line number Diff line number Diff line change
1
+ import { fill } from '../../../../utils/src/object' ;
2
+ import { FunctionToString } from '../../../src/integrations/functiontostring' ;
3
+
4
+ describe ( 'FunctionToString' , ( ) => {
5
+ it ( 'it works as expected' , ( ) => {
6
+ const foo = {
7
+ bar ( wat : boolean ) : boolean {
8
+ return wat ;
9
+ } ,
10
+ } ;
11
+ const originalFunction = foo . bar . toString ( ) ;
12
+ fill ( foo , 'bar' , function wat ( whatever : boolean ) : ( ) => void {
13
+ return function watwat ( ) : boolean {
14
+ return whatever ;
15
+ } ;
16
+ } ) ;
17
+
18
+ expect ( foo . bar . toString ( ) ) . not . toBe ( originalFunction ) ;
19
+
20
+ const fts = new FunctionToString ( ) ;
21
+ fts . setupOnce ( ) ;
22
+
23
+ expect ( foo . bar . toString ( ) ) . toBe ( originalFunction ) ;
24
+ } ) ;
25
+ } ) ;
Original file line number Diff line number Diff line change @@ -181,8 +181,8 @@ export function consoleSandbox(callback: () => any): any {
181
181
182
182
// Restore all wrapped console methods
183
183
levels . forEach ( level => {
184
- if ( level in global . console && ( originalConsole [ level ] as WrappedFunction ) . __sentry__ ) {
185
- wrappedLevels [ level ] = ( originalConsole [ level ] as WrappedFunction ) . __sentry_wrapped__ ;
184
+ if ( level in global . console && ( originalConsole [ level ] as WrappedFunction ) . __sentry_original__ ) {
185
+ wrappedLevels [ level ] = originalConsole [ level ] as WrappedFunction ;
186
186
originalConsole [ level ] = ( originalConsole [ level ] as WrappedFunction ) . __sentry_original__ ;
187
187
}
188
188
} ) ;
You can’t perform that action at this time.
0 commit comments