File tree 5 files changed +62
-7
lines changed
5 files changed +62
-7
lines changed Original file line number Diff line number Diff line change
1
+ ## v2.43.0-dev
2
+
3
+ * FIXED: 7156: ` Promise#thenFinally ` should not suppress original error
4
+
1
5
## v2.42.0
2
6
3
7
* Removed deprecated functions ` Promise#addCallback() ` ,
Original file line number Diff line number Diff line change 1
1
{
2
2
"name" : " selenium-webdriver" ,
3
- "version" : " 2.42.0 " ,
3
+ "version" : " 2.43.0-dev " ,
4
4
"description" : " The official WebDriver JavaScript bindings from the Selenium project" ,
5
5
"keywords" : [
6
6
" automation" ,
Original file line number Diff line number Diff line change @@ -184,7 +184,15 @@ webdriver.promise.Promise.prototype.thenCatch = function(errback) {
184
184
* @template R
185
185
*/
186
186
webdriver . promise . Promise . prototype . thenFinally = function ( callback ) {
187
- return this . then ( callback , callback ) ;
187
+ return this . then ( callback , function ( err ) {
188
+ var value = callback ( ) ;
189
+ if ( webdriver . promise . isPromise ( value ) ) {
190
+ return value . then ( function ( ) {
191
+ throw err ;
192
+ } ) ;
193
+ }
194
+ throw err ;
195
+ } ) ;
188
196
} ;
189
197
190
198
Original file line number Diff line number Diff line change 1175
1175
1176
1176
scheduleAction ( 'doFoo and throw' , function ( ) {
1177
1177
webdriver . test . testutil . messages . push ( 'foo' ) ;
1178
- throw new Error ( 'ouch' ) ;
1178
+ throw STUB_ERROR ;
1179
1179
} ) . then ( goog . partial ( schedulePush , 'bar' ) ) .
1180
1180
thenFinally ( goog . partial ( schedulePush , 'baz' ) ) ;
1181
- runAndExpectSuccess ( assertingMessages ( 'foo' , 'baz' ) ) ;
1181
+ runAndExpectFailure ( function ( e ) {
1182
+ assertIsStubError ( e ) ;
1183
+ webdriver . test . testutil . assertMessages ( 'foo' , 'baz' ) ;
1184
+ } ) ;
1182
1185
}
1183
1186
1184
1187
1199
1202
throw STUB_ERROR ;
1200
1203
} ) ;
1201
1204
} ) .
1202
- thenFinally ( function ( e ) {
1203
- assertIsStubError ( e ) ;
1205
+ thenFinally ( function ( ) {
1204
1206
return schedulePush ( 'baz' ) ;
1205
1207
} ) ;
1206
- runAndExpectSuccess ( assertingMessages ( 'foo' , 'bar' , 'baz' ) ) ;
1208
+ runAndExpectFailure ( function ( e ) {
1209
+ assertIsStubError ( e ) ;
1210
+ webdriver . test . testutil . assertMessages ( 'foo' , 'bar' , 'baz' ) ;
1211
+ } ) ;
1207
1212
}
1208
1213
1209
1214
Original file line number Diff line number Diff line change 248
248
}
249
249
250
250
251
+ function testThenFinally_nonFailingCallbackDoesNotSuppressOriginalError ( ) {
252
+ var done = callbackHelper ( assertIsStubError ) ;
253
+ webdriver . promise . rejected ( STUB_ERROR ) .
254
+ thenFinally ( goog . nullFunction ) .
255
+ thenCatch ( done ) ;
256
+ done . assertCalled ( ) ;
257
+ }
258
+
259
+
260
+ function testThenFinally_failingCallbackSuppressesOriginalError ( ) {
261
+ var done = callbackHelper ( assertIsStubError ) ;
262
+ webdriver . promise . rejected ( new Error ( 'original' ) ) .
263
+ thenFinally ( throwStubError ) .
264
+ thenCatch ( done ) ;
265
+ done . assertCalled ( ) ;
266
+ }
267
+
268
+
269
+ function testThenFinally_callbackThrowsAfterFulfilledPromise ( ) {
270
+ var done = callbackHelper ( assertIsStubError ) ;
271
+ webdriver . promise . fulfilled ( ) .
272
+ thenFinally ( throwStubError ) .
273
+ thenCatch ( done ) ;
274
+ done . assertCalled ( ) ;
275
+ }
276
+
277
+
278
+ function testThenFinally_callbackReturnsRejectedPromise ( ) {
279
+ var done = callbackHelper ( assertIsStubError ) ;
280
+ webdriver . promise . fulfilled ( ) .
281
+ thenFinally ( function ( ) {
282
+ return webdriver . promise . rejected ( STUB_ERROR ) ;
283
+ } ) .
284
+ thenCatch ( done ) ;
285
+ done . assertCalled ( ) ;
286
+ }
287
+
288
+
251
289
function testChainingThen_AllResolved ( ) {
252
290
var callbacks = [
253
291
callbackHelper ( function ( value ) {
You can’t perform that action at this time.
0 commit comments