@@ -78,6 +78,7 @@ jasmine.HtmlReporter = function(_doc) {
78
78
79
79
createReporterDom ( runner . env . versionString ( ) ) ;
80
80
doc . body . appendChild ( dom . reporter ) ;
81
+ setExceptionHandling ( ) ;
81
82
82
83
reporterView = new jasmine . HtmlReporter . ReporterView ( dom ) ;
83
84
reporterView . addSpecs ( specs , self . specFilter ) ;
@@ -131,7 +132,7 @@ jasmine.HtmlReporter = function(_doc) {
131
132
}
132
133
133
134
var paramMap = [ ] ;
134
- var params = doc . location . search . substring ( 1 ) . split ( '&' ) ;
135
+ var params = jasmine . HtmlReporter . parameters ( doc ) ;
135
136
136
137
for ( var i = 0 ; i < params . length ; i ++ ) {
137
138
var p = params [ i ] . split ( '=' ) ;
@@ -151,14 +152,78 @@ jasmine.HtmlReporter = function(_doc) {
151
152
self . createDom ( 'span' , { className : 'version' } , version ) ) ,
152
153
153
154
dom . symbolSummary = self . createDom ( 'ul' , { className : 'symbolSummary' } ) ,
154
- dom . alert = self . createDom ( 'div' , { className : 'alert' } ) ,
155
+ dom . alert = self . createDom ( 'div' , { className : 'alert' } ,
156
+ self . createDom ( 'span' , { className : 'exceptions' } ,
157
+ self . createDom ( 'label' , { className : 'label' , 'for' : 'no_try_catch' } , 'No try/catch' ) ,
158
+ self . createDom ( 'input' , { id : 'no_try_catch' , type : 'checkbox' } ) ) ) ,
155
159
dom . results = self . createDom ( 'div' , { className : 'results' } ,
156
160
dom . summary = self . createDom ( 'div' , { className : 'summary' } ) ,
157
161
dom . details = self . createDom ( 'div' , { id : 'details' } ) )
158
162
) ;
159
163
}
164
+
165
+ function noTryCatch ( ) {
166
+ return window . location . search . match ( / c a t c h = f a l s e / ) ;
167
+ }
168
+
169
+ function searchWithCatch ( ) {
170
+ var params = jasmine . HtmlReporter . parameters ( window . document ) ;
171
+ var removed = false ;
172
+ var i = 0 ;
173
+
174
+ while ( ! removed && i < params . length ) {
175
+ if ( params [ i ] . match ( / c a t c h = / ) ) {
176
+ params . splice ( i , 1 ) ;
177
+ removed = true ;
178
+ }
179
+ i ++ ;
180
+ }
181
+ if ( jasmine . CATCH_EXCEPTIONS ) {
182
+ params . push ( "catch=false" ) ;
183
+ }
184
+
185
+ return params . join ( "&" ) ;
186
+ }
187
+
188
+ function setExceptionHandling ( ) {
189
+ var chxCatch = document . getElementById ( 'no_try_catch' ) ;
190
+
191
+ if ( noTryCatch ( ) ) {
192
+ chxCatch . setAttribute ( 'checked' , true ) ;
193
+ jasmine . CATCH_EXCEPTIONS = false ;
194
+ }
195
+ chxCatch . onclick = function ( ) {
196
+ window . location . search = searchWithCatch ( ) ;
197
+ } ;
198
+ }
199
+ } ;
200
+ jasmine . HtmlReporter . parameters = function ( doc ) {
201
+ var paramStr = doc . location . search . substring ( 1 ) ;
202
+ var params = [ ] ;
203
+
204
+ if ( paramStr . length > 0 ) {
205
+ params = paramStr . split ( '&' ) ;
206
+ }
207
+ return params ;
208
+ }
209
+ jasmine . HtmlReporter . sectionLink = function ( sectionName ) {
210
+ var link = '?' ;
211
+ var params = [ ] ;
212
+
213
+ if ( sectionName ) {
214
+ params . push ( 'spec=' + encodeURIComponent ( sectionName ) ) ;
215
+ }
216
+ if ( ! jasmine . CATCH_EXCEPTIONS ) {
217
+ params . push ( "catch=false" ) ;
218
+ }
219
+ if ( params . length > 0 ) {
220
+ link += params . join ( "&" ) ;
221
+ }
222
+
223
+ return link ;
160
224
} ;
161
- jasmine . HtmlReporterHelpers . addHelpers ( jasmine . HtmlReporter ) ; jasmine . HtmlReporter . ReporterView = function ( dom ) {
225
+ jasmine . HtmlReporterHelpers . addHelpers ( jasmine . HtmlReporter ) ;
226
+ jasmine . HtmlReporter . ReporterView = function ( dom ) {
162
227
this . startedAt = new Date ( ) ;
163
228
this . runningSpecCount = 0 ;
164
229
this . completeSpecCount = 0 ;
@@ -241,14 +306,14 @@ jasmine.HtmlReporterHelpers.addHelpers(jasmine.HtmlReporter);jasmine.HtmlReporte
241
306
242
307
// currently running UI
243
308
if ( isUndefined ( this . runningAlert ) ) {
244
- this . runningAlert = this . createDom ( 'a' , { href : "?" , className : "runningAlert bar" } ) ;
309
+ this . runningAlert = this . createDom ( 'a' , { href : jasmine . HtmlReporter . sectionLink ( ) , className : "runningAlert bar" } ) ;
245
310
dom . alert . appendChild ( this . runningAlert ) ;
246
311
}
247
312
this . runningAlert . innerHTML = "Running " + this . completeSpecCount + " of " + specPluralizedFor ( this . totalSpecCount ) ;
248
313
249
314
// skipped specs UI
250
315
if ( isUndefined ( this . skippedAlert ) ) {
251
- this . skippedAlert = this . createDom ( 'a' , { href : "?" , className : "skippedAlert bar" } ) ;
316
+ this . skippedAlert = this . createDom ( 'a' , { href : jasmine . HtmlReporter . sectionLink ( ) , className : "skippedAlert bar" } ) ;
252
317
}
253
318
254
319
this . skippedAlert . innerHTML = "Skipping " + this . skippedCount + " of " + specPluralizedFor ( this . totalSpecCount ) + " - run all" ;
@@ -259,7 +324,7 @@ jasmine.HtmlReporterHelpers.addHelpers(jasmine.HtmlReporter);jasmine.HtmlReporte
259
324
260
325
// passing specs UI
261
326
if ( isUndefined ( this . passedAlert ) ) {
262
- this . passedAlert = this . createDom ( 'span' , { href : "?" , className : "passingAlert bar" } ) ;
327
+ this . passedAlert = this . createDom ( 'span' , { href : jasmine . HtmlReporter . sectionLink ( ) , className : "passingAlert bar" } ) ;
263
328
}
264
329
this . passedAlert . innerHTML = "Passing " + specPluralizedFor ( this . passedCount ) ;
265
330
@@ -331,11 +396,11 @@ jasmine.HtmlReporter.SpecView = function(spec, dom, views) {
331
396
this . dom . symbolSummary . appendChild ( this . symbol ) ;
332
397
333
398
this . summary = this . createDom ( 'div' , { className : 'specSummary' } ,
334
- this . createDom ( 'a' , {
335
- className : 'description' ,
336
- href : '?spec=' + encodeURIComponent ( this . spec . getFullName ( ) ) ,
337
- title : this . spec . getFullName ( )
338
- } , this . spec . description )
399
+ this . createDom ( 'a' , {
400
+ className : 'description' ,
401
+ href : jasmine . HtmlReporter . sectionLink ( this . spec . getFullName ( ) ) ,
402
+ title : this . spec . getFullName ( )
403
+ } , this . spec . description )
339
404
) ;
340
405
341
406
this . detail = this . createDom ( 'div' , { className : 'specDetail' } ,
@@ -406,7 +471,7 @@ jasmine.HtmlReporterHelpers.addHelpers(jasmine.HtmlReporter.SpecView);jasmine.Ht
406
471
this . views = views ;
407
472
408
473
this . element = this . createDom ( 'div' , { className : 'suite' } ,
409
- this . createDom ( 'a' , { className : 'description' , href : '?spec=' + encodeURIComponent ( this . suite . getFullName ( ) ) } , this . suite . description )
474
+ this . createDom ( 'a' , { className : 'description' , href : jasmine . HtmlReporter . sectionLink ( this . suite . getFullName ( ) ) } , this . suite . description )
410
475
) ;
411
476
412
477
this . appendToSummary ( this . suite , this . element ) ;
0 commit comments