@@ -615,37 +615,40 @@ TraceKit.computeStackTrace = (function computeStackTraceWrapper() {
615
615
function computeStackTraceFromStackProp ( ex ) {
616
616
if ( isUndefined ( ex . stack ) || ! ex . stack ) return ;
617
617
618
- var chrome = / ^ \s * a t ( .* ?) ? \( ? ( (?: (?: f i l e | h t t p s ? | c h r o m e - e x t e n s i o n ) : .* ?) | < a n o n y m o u s > ) : ( \d + ) (?: : ( \d + ) ) ? \) ? \s * $ / i,
619
- gecko = / ^ \s * ( .* ?) (?: \( ( .* ?) \) ) ? @ ( (?: f i l e | h t t p s ? | c h r o m e ) .* ?) : ( \d + ) (?: : ( \d + ) ) ? \s * $ / i,
620
- winjs = / ^ \s * a t (?: ( (?: \[ o b j e c t o b j e c t \] ) ? .+ ) ) ? \( ? ( (?: m s - a p p x | h t t p | h t t p s ) : .* ?) : ( \d + ) (?: : ( \d + ) ) ? \) ? \s * $ / i,
618
+ var chrome = / ^ \s * a t ( .* ?) ? \( ( ( (?: f i l e | h t t p s ? | b l o b | c h r o m e - e x t e n s i o n | n a t i v e | e v a l ) .* ?) | < a n o n y m o u s > ) (?: : ( \d + ) ) ? (?: : ( \d + ) ) ? \) ? \s * $ / i,
619
+ gecko = / ^ \s * ( .* ?) (?: \( ( .* ?) \) ) ? (?: ^ | @ ) ( (?: f i l e | h t t p s ? | b l o b | c h r o m e | \[ ) .* ?) (?: : ( \d + ) ) ? (?: : ( \d + ) ) ? \s * $ / i,
620
+ winjs = / ^ \s * a t (?: ( (?: \[ o b j e c t o b j e c t \] ) ? .+ ) ) ? \( ? ( (?: m s - a p p x | h t t p s ? | b l o b ) : .* ?) : ( \d + ) (?: : ( \d + ) ) ? \) ? \s * $ / i,
621
621
lines = ex . stack . split ( '\n' ) ,
622
622
stack = [ ] ,
623
623
parts ,
624
624
element ,
625
625
reference = / ^ ( .* ) i s u n d e f i n e d $ / . exec ( ex . message ) ;
626
626
627
627
for ( var i = 0 , j = lines . length ; i < j ; ++ i ) {
628
- if ( ( parts = gecko . exec ( lines [ i ] ) ) ) {
628
+ if ( ( parts = chrome . exec ( lines [ i ] ) ) ) {
629
+ var isNative = parts [ 2 ] && parts [ 2 ] . indexOf ( 'native' ) !== - 1 ;
629
630
element = {
630
- 'url' : parts [ 3 ] ,
631
+ 'url' : ! isNative ? parts [ 2 ] : null ,
631
632
'func' : parts [ 1 ] || UNKNOWN_FUNCTION ,
632
- 'args' : parts [ 2 ] ? parts [ 2 ] . split ( ',' ) : '' ,
633
- 'line' : + parts [ 4 ] ,
634
- 'column' : parts [ 5 ] ? + parts [ 5 ] : null
633
+ 'args' : isNative ? [ parts [ 2 ] ] : [ ] ,
634
+ 'line' : parts [ 3 ] ? + parts [ 3 ] : null ,
635
+ 'column' : parts [ 4 ] ? + parts [ 4 ] : null
635
636
} ;
636
- } else if ( ( parts = chrome . exec ( lines [ i ] ) ) ) {
637
+ } else if ( parts = winjs . exec ( lines [ i ] ) ) {
637
638
element = {
638
639
'url' : parts [ 2 ] ,
639
640
'func' : parts [ 1 ] || UNKNOWN_FUNCTION ,
641
+ 'args' : [ ] ,
640
642
'line' : + parts [ 3 ] ,
641
643
'column' : parts [ 4 ] ? + parts [ 4 ] : null
642
644
} ;
643
- } else if ( ( parts = winjs . exec ( lines [ i ] ) ) ) {
645
+ } else if ( ( parts = gecko . exec ( lines [ i ] ) ) ) {
644
646
element = {
645
- 'url' : parts [ 2 ] ,
647
+ 'url' : parts [ 3 ] ,
646
648
'func' : parts [ 1 ] || UNKNOWN_FUNCTION ,
647
- 'line' : + parts [ 3 ] ,
648
- 'column' : parts [ 4 ] ? + parts [ 4 ] : null
649
+ 'args' : parts [ 2 ] ? parts [ 2 ] . split ( ',' ) : [ ] ,
650
+ 'line' : parts [ 4 ] ? + parts [ 4 ] : null ,
651
+ 'column' : parts [ 5 ] ? + parts [ 5 ] : null
649
652
} ;
650
653
} else {
651
654
continue ;
@@ -696,21 +699,33 @@ TraceKit.computeStackTrace = (function computeStackTraceWrapper() {
696
699
var stacktrace = ex . stacktrace ;
697
700
if ( isUndefined ( ex . stacktrace ) || ! ex . stacktrace ) return ;
698
701
699
- var testRE = / l i n e ( \d + ) , c o l u m n ( \d + ) i n (?: < a n o n y m o u s f u n c t i o n : ( [ ^ > ] + ) > | ( [ ^ \) ] + ) ) \( ( .* ) \) i n ( .* ) : \s * $ / i,
700
- lines = stacktrace . split ( '\n' ) ,
701
- stack = [ ] ,
702
- parts ;
702
+ var opera10Regex = / l i n e ( \d + ) .* s c r i p t (?: i n ) ? ( \S + ) (?: : i n f u n c t i o n ( \S + ) ) ? $ / i,
703
+ opera11Regex = / l i n e ( \d + ) , c o l u m n ( \d + ) \s * (?: i n (?: < a n o n y m o u s f u n c t i o n : ( [ ^ > ] + ) > | ( [ ^ \) ] + ) ) \( ( .* ) \) ) ? i n ( .* ) : \s * $ / i,
704
+ lines = stacktrace . split ( '\n' ) ,
705
+ stack = [ ] ,
706
+ parts ;
703
707
704
- for ( var i = 0 , j = lines . length ; i < j ; i += 2 ) {
705
- if ( ( parts = testRE . exec ( lines [ i ] ) ) ) {
706
- var element = {
708
+ for ( var line = 0 ; line < lines . length ; line += 2 ) {
709
+ var element = null ;
710
+ if ( ( parts = opera10Regex . exec ( lines [ line ] ) ) ) {
711
+ element = {
712
+ 'url' : parts [ 2 ] ,
713
+ 'line' : + parts [ 1 ] ,
714
+ 'column' : null ,
715
+ 'func' : parts [ 3 ] ,
716
+ 'args' :[ ]
717
+ } ;
718
+ } else if ( ( parts = opera11Regex . exec ( lines [ line ] ) ) ) {
719
+ element = {
720
+ 'url' : parts [ 6 ] ,
707
721
'line' : + parts [ 1 ] ,
708
722
'column' : + parts [ 2 ] ,
709
723
'func' : parts [ 3 ] || parts [ 4 ] ,
710
- 'args' : parts [ 5 ] ? parts [ 5 ] . split ( ',' ) : [ ] ,
711
- 'url' : parts [ 6 ]
724
+ 'args' : parts [ 5 ] ? parts [ 5 ] . split ( ',' ) : [ ]
712
725
} ;
726
+ }
713
727
728
+ if ( element ) {
714
729
if ( ! element . func && element . line ) {
715
730
element . func = guessFunctionName ( element . url , element . line ) ;
716
731
}
@@ -721,7 +736,7 @@ TraceKit.computeStackTrace = (function computeStackTraceWrapper() {
721
736
}
722
737
723
738
if ( ! element . context ) {
724
- element . context = [ lines [ i + 1 ] ] ;
739
+ element . context = [ lines [ line + 1 ] ] ;
725
740
}
726
741
727
742
stack . push ( element ) ;
@@ -769,40 +784,42 @@ TraceKit.computeStackTrace = (function computeStackTraceWrapper() {
769
784
return null ;
770
785
}
771
786
772
- var lineRE1 = / ^ \s * L i n e ( \d + ) o f l i n k e d s c r i p t ( (?: f i l e | h t t p s ? ) \S + ) (?: : i n f u n c t i o n ( \S + ) ) ? \s * $ / i,
773
- lineRE2 = / ^ \s * L i n e ( \d + ) o f i n l i n e # ( \d + ) s c r i p t i n ( (?: f i l e | h t t p s ? ) \S + ) (?: : i n f u n c t i o n ( \S + ) ) ? \s * $ / i,
787
+ var lineRE1 = / ^ \s * L i n e ( \d + ) o f l i n k e d s c r i p t ( (?: f i l e | h t t p s ? | b l o b ) \S + ) (?: : i n f u n c t i o n ( \S + ) ) ? \s * $ / i,
788
+ lineRE2 = / ^ \s * L i n e ( \d + ) o f i n l i n e # ( \d + ) s c r i p t i n ( (?: f i l e | h t t p s ? | b l o b ) \S + ) (?: : i n f u n c t i o n ( \S + ) ) ? \s * $ / i,
774
789
lineRE3 = / ^ \s * L i n e ( \d + ) o f f u n c t i o n s c r i p t \s * $ / i,
775
790
stack = [ ] ,
776
791
scripts = document . getElementsByTagName ( 'script' ) ,
777
792
inlineScriptBlocks = [ ] ,
778
- parts ,
779
- i ,
780
- len ,
781
- source ;
793
+ parts ;
782
794
783
- for ( i in scripts ) {
784
- if ( hasKey ( scripts , i ) && ! scripts [ i ] . src ) {
785
- inlineScriptBlocks . push ( scripts [ i ] ) ;
795
+ for ( var s in scripts ) {
796
+ if ( hasKey ( scripts , s ) && ! scripts [ s ] . src ) {
797
+ inlineScriptBlocks . push ( scripts [ s ] ) ;
786
798
}
787
799
}
788
800
789
- for ( i = 2 , len = lines . length ; i < len ; i += 2 ) {
801
+ for ( var line = 2 ; line < lines . length ; line += 2 ) {
790
802
var item = null ;
791
- if ( ( parts = lineRE1 . exec ( lines [ i ] ) ) ) {
803
+ if ( ( parts = lineRE1 . exec ( lines [ line ] ) ) ) {
792
804
item = {
793
805
'url' : parts [ 2 ] ,
794
806
'func' : parts [ 3 ] ,
795
- 'line' : + parts [ 1 ]
807
+ 'args' : [ ] ,
808
+ 'line' : + parts [ 1 ] ,
809
+ 'column' : null
796
810
} ;
797
- } else if ( ( parts = lineRE2 . exec ( lines [ i ] ) ) ) {
811
+ } else if ( ( parts = lineRE2 . exec ( lines [ line ] ) ) ) {
798
812
item = {
799
813
'url' : parts [ 3 ] ,
800
- 'func' : parts [ 4 ]
814
+ 'func' : parts [ 4 ] ,
815
+ 'args' : [ ] ,
816
+ 'line' : + parts [ 1 ] ,
817
+ 'column' : null // TODO: Check to see if inline#1 (+parts[2]) points to the script number or column number.
801
818
} ;
802
819
var relativeLine = ( + parts [ 1 ] ) ; // relative to the start of the <SCRIPT> block
803
820
var script = inlineScriptBlocks [ parts [ 2 ] - 1 ] ;
804
821
if ( script ) {
805
- source = getSource ( item . url ) ;
822
+ var source = getSource ( item . url ) ;
806
823
if ( source ) {
807
824
source = source . join ( '\n' ) ;
808
825
var pos = source . indexOf ( script . innerText ) ;
@@ -811,15 +828,16 @@ TraceKit.computeStackTrace = (function computeStackTraceWrapper() {
811
828
}
812
829
}
813
830
}
814
- } else if ( ( parts = lineRE3 . exec ( lines [ i ] ) ) ) {
815
- var url = window . location . href . replace ( / # .* $ / , '' ) ,
816
- line = parts [ 1 ] ;
817
- var re = new RegExp ( escapeCodeAsRegExpForMatchingInsideHTML ( lines [ i + 1 ] ) ) ;
818
- source = findSourceInUrls ( re , [ url ] ) ;
831
+ } else if ( ( parts = lineRE3 . exec ( lines [ line ] ) ) ) {
832
+ var url = window . location . href . replace ( / # .* $ / , '' ) ;
833
+ var re = new RegExp ( escapeCodeAsRegExpForMatchingInsideHTML ( lines [ line + 1 ] ) ) ;
834
+ var src = findSourceInUrls ( re , [ url ] ) ;
819
835
item = {
820
836
'url' : url ,
821
- 'line' : source ? source . line : line ,
822
- 'func' : ''
837
+ 'func' : '' ,
838
+ 'args' : [ ] ,
839
+ 'line' : src ? src . line : parts [ 1 ] ,
840
+ 'column' : null
823
841
} ;
824
842
}
825
843
@@ -829,15 +847,16 @@ TraceKit.computeStackTrace = (function computeStackTraceWrapper() {
829
847
}
830
848
var context = gatherContext ( item . url , item . line ) ;
831
849
var midline = ( context ? context [ Math . floor ( context . length / 2 ) ] : null ) ;
832
- if ( context && midline . replace ( / ^ \s * / , '' ) === lines [ i + 1 ] . replace ( / ^ \s * / , '' ) ) {
850
+ if ( context && midline . replace ( / ^ \s * / , '' ) === lines [ line + 1 ] . replace ( / ^ \s * / , '' ) ) {
833
851
item . context = context ;
834
852
} else {
835
853
// if (context) alert("Context mismatch. Correct midline:\n" + lines[i+1] + "\n\nMidline:\n" + midline + "\n\nContext:\n" + context.join("\n") + "\n\nURL:\n" + item.url);
836
- item . context = [ lines [ i + 1 ] ] ;
854
+ item . context = [ lines [ line + 1 ] ] ;
837
855
}
838
856
stack . push ( item ) ;
839
857
}
840
858
}
859
+
841
860
if ( ! stack . length ) {
842
861
return null ; // could not parse multiline exception message as Opera stack trace
843
862
}
0 commit comments