@@ -46,19 +46,23 @@ describe("wrapped built-ins", function() {
46
46
describe ( "unhandledrejection" , function ( ) {
47
47
it ( "should capture unhandledrejection with error" , function ( ) {
48
48
return runInSandbox ( sandbox , function ( ) {
49
- if ( isChrome ( ) ) {
49
+ if ( supportsOnunhandledRejection ( ) ) {
50
50
Promise . reject ( new Error ( "test2" ) ) ;
51
51
} else {
52
52
window . resolveTest ( { window : window } ) ;
53
53
}
54
54
} ) . then ( function ( summary ) {
55
- if ( summary . window . isChrome ( ) ) {
55
+ if ( summary . window . supportsOnunhandledRejection ( ) ) {
56
56
assert . equal ( summary . events [ 0 ] . exception . values [ 0 ] . value , "test2" ) ;
57
57
assert . equal ( summary . events [ 0 ] . exception . values [ 0 ] . type , "Error" ) ;
58
- assert . isAtLeast (
59
- summary . events [ 0 ] . exception . values [ 0 ] . stacktrace . frames . length ,
60
- 1
61
- ) ;
58
+
59
+ // Of course Safari had to screw up here...
60
+ if ( ! / V e r s i o n \/ \d .+ S a f a r i \/ \d / . test ( window . navigator . userAgent ) ) {
61
+ assert . isAtLeast (
62
+ summary . events [ 0 ] . exception . values [ 0 ] . stacktrace . frames . length ,
63
+ 1
64
+ ) ;
65
+ }
62
66
assert . equal (
63
67
summary . events [ 0 ] . exception . values [ 0 ] . mechanism . handled ,
64
68
false
@@ -73,13 +77,13 @@ describe("wrapped built-ins", function() {
73
77
74
78
it ( "should capture unhandledrejection with a string" , function ( ) {
75
79
return runInSandbox ( sandbox , function ( ) {
76
- if ( isChrome ( ) ) {
80
+ if ( supportsOnunhandledRejection ( ) ) {
77
81
Promise . reject ( "test" ) ;
78
82
} else {
79
83
window . resolveTest ( { window : window } ) ;
80
84
}
81
85
} ) . then ( function ( summary ) {
82
- if ( summary . window . isChrome ( ) ) {
86
+ if ( summary . window . supportsOnunhandledRejection ( ) ) {
83
87
// non-error rejections doesnt provide stacktraces so we can skip the assertion
84
88
assert . equal (
85
89
summary . events [ 0 ] . exception . values [ 0 ] . value ,
@@ -103,13 +107,13 @@ describe("wrapped built-ins", function() {
103
107
104
108
it ( "should capture unhandledrejection with a monster string" , function ( ) {
105
109
return runInSandbox ( sandbox , function ( ) {
106
- if ( isChrome ( ) ) {
110
+ if ( supportsOnunhandledRejection ( ) ) {
107
111
Promise . reject ( "test" . repeat ( 100 ) ) ;
108
112
} else {
109
113
window . resolveTest ( { window : window } ) ;
110
114
}
111
115
} ) . then ( function ( summary ) {
112
- if ( summary . window . isChrome ( ) ) {
116
+ if ( summary . window . supportsOnunhandledRejection ( ) ) {
113
117
// non-error rejections doesnt provide stacktraces so we can skip the assertion
114
118
assert . equal ( summary . events [ 0 ] . exception . values [ 0 ] . value . length , 253 ) ;
115
119
assert . include (
@@ -134,13 +138,13 @@ describe("wrapped built-ins", function() {
134
138
135
139
it ( "should capture unhandledrejection with an object" , function ( ) {
136
140
return runInSandbox ( sandbox , function ( ) {
137
- if ( isChrome ( ) ) {
141
+ if ( supportsOnunhandledRejection ( ) ) {
138
142
Promise . reject ( { a : "b" , b : "c" , c : "d" } ) ;
139
143
} else {
140
144
window . resolveTest ( { window : window } ) ;
141
145
}
142
146
} ) . then ( function ( summary ) {
143
- if ( summary . window . isChrome ( ) ) {
147
+ if ( summary . window . supportsOnunhandledRejection ( ) ) {
144
148
// non-error rejections doesnt provide stacktraces so we can skip the assertion
145
149
assert . equal (
146
150
summary . events [ 0 ] . exception . values [ 0 ] . value ,
@@ -164,7 +168,7 @@ describe("wrapped built-ins", function() {
164
168
165
169
it ( "should capture unhandledrejection with an monster object" , function ( ) {
166
170
return runInSandbox ( sandbox , function ( ) {
167
- if ( isChrome ( ) ) {
171
+ if ( supportsOnunhandledRejection ( ) ) {
168
172
var a = {
169
173
a : "1" . repeat ( "100" ) ,
170
174
b : "2" . repeat ( "100" ) ,
@@ -177,7 +181,7 @@ describe("wrapped built-ins", function() {
177
181
window . resolveTest ( { window : window } ) ;
178
182
}
179
183
} ) . then ( function ( summary ) {
180
- if ( summary . window . isChrome ( ) ) {
184
+ if ( summary . window . supportsOnunhandledRejection ( ) ) {
181
185
// non-error rejections doesnt provide stacktraces so we can skip the assertion
182
186
assert . equal (
183
187
summary . events [ 0 ] . exception . values [ 0 ] . value ,
@@ -201,13 +205,13 @@ describe("wrapped built-ins", function() {
201
205
202
206
it ( "should capture unhandledrejection with a number" , function ( ) {
203
207
return runInSandbox ( sandbox , function ( ) {
204
- if ( isChrome ( ) ) {
208
+ if ( supportsOnunhandledRejection ( ) ) {
205
209
Promise . reject ( 1337 ) ;
206
210
} else {
207
211
window . resolveTest ( { window : window } ) ;
208
212
}
209
213
} ) . then ( function ( summary ) {
210
- if ( summary . window . isChrome ( ) ) {
214
+ if ( summary . window . supportsOnunhandledRejection ( ) ) {
211
215
// non-error rejections doesnt provide stacktraces so we can skip the assertion
212
216
assert . equal (
213
217
summary . events [ 0 ] . exception . values [ 0 ] . value ,
@@ -231,13 +235,13 @@ describe("wrapped built-ins", function() {
231
235
232
236
it ( "should capture unhandledrejection with null" , function ( ) {
233
237
return runInSandbox ( sandbox , function ( ) {
234
- if ( isChrome ( ) ) {
238
+ if ( supportsOnunhandledRejection ( ) ) {
235
239
Promise . reject ( null ) ;
236
240
} else {
237
241
window . resolveTest ( { window : window } ) ;
238
242
}
239
243
} ) . then ( function ( summary ) {
240
- if ( summary . window . isChrome ( ) ) {
244
+ if ( summary . window . supportsOnunhandledRejection ( ) ) {
241
245
// non-error rejections doesnt provide stacktraces so we can skip the assertion
242
246
assert . equal (
243
247
summary . events [ 0 ] . exception . values [ 0 ] . value ,
@@ -261,13 +265,13 @@ describe("wrapped built-ins", function() {
261
265
262
266
it ( "should capture unhandledrejection with an undefined" , function ( ) {
263
267
return runInSandbox ( sandbox , function ( ) {
264
- if ( isChrome ( ) ) {
268
+ if ( supportsOnunhandledRejection ( ) ) {
265
269
Promise . reject ( undefined ) ;
266
270
} else {
267
271
window . resolveTest ( { window : window } ) ;
268
272
}
269
273
} ) . then ( function ( summary ) {
270
- if ( summary . window . isChrome ( ) ) {
274
+ if ( summary . window . supportsOnunhandledRejection ( ) ) {
271
275
// non-error rejections doesnt provide stacktraces so we can skip the assertion
272
276
assert . equal (
273
277
summary . events [ 0 ] . exception . values [ 0 ] . value ,
@@ -291,7 +295,7 @@ describe("wrapped built-ins", function() {
291
295
292
296
it ( "should skip our own failed requests that somehow bubbled-up to unhandledrejection handler" , function ( ) {
293
297
return runInSandbox ( sandbox , function ( ) {
294
- if ( isChrome ( ) ) {
298
+ if ( supportsOnunhandledRejection ( ) ) {
295
299
Promise . reject ( {
296
300
__sentry_own_request__ : true ,
297
301
} ) ;
@@ -303,7 +307,7 @@ describe("wrapped built-ins", function() {
303
307
window . resolveTest ( { window : window } ) ;
304
308
}
305
309
} ) . then ( function ( summary ) {
306
- if ( summary . window . isChrome ( ) ) {
310
+ if ( summary . window . supportsOnunhandledRejection ( ) ) {
307
311
assert . equal ( summary . events . length , 2 ) ;
308
312
}
309
313
} ) ;
0 commit comments