File tree Expand file tree Collapse file tree 2 files changed +28
-0
lines changed
javascript/node/selenium-webdriver Expand file tree Collapse file tree 2 files changed +28
-0
lines changed Original file line number Diff line number Diff line change @@ -39,6 +39,10 @@ class NetworkInspector {
39
39
await this . subscribeAndHandleEvent ( 'network.responseCompleted' , callback )
40
40
}
41
41
42
+ async authRequired ( callback ) {
43
+ await this . subscribeAndHandleEvent ( 'network.authRequired' , callback )
44
+ }
45
+
42
46
async subscribeAndHandleEvent ( eventType , callback ) {
43
47
if ( this . _browsingContextIds != null ) {
44
48
await this . bidi . subscribe ( eventType , this . _browsingContextIds )
Original file line number Diff line number Diff line change @@ -2359,6 +2359,30 @@ suite(
2359
2359
)
2360
2360
assert ( onResponseCompleted [ 0 ] . response . mimeType . includes ( 'text/plain' ) )
2361
2361
} )
2362
+ // Implemented in Firefox Nightly 123
2363
+ xit ( 'can subscribe to auth required' , async function ( ) {
2364
+ let onAuthRequired = [ ]
2365
+ const inspector = await NetworkInspector ( driver )
2366
+ await inspector . authRequired ( function ( event ) {
2367
+ onAuthRequired . push ( event )
2368
+ } )
2369
+
2370
+ await driver . get ( Pages . basicAuth )
2371
+
2372
+ assert . equal ( onAuthRequired [ 0 ] . request . method , 'GET' )
2373
+ assert . equal (
2374
+ onAuthRequired [ 0 ] . request . url ,
2375
+ await driver . getCurrentUrl ( )
2376
+ )
2377
+ assert . equal (
2378
+ onAuthRequired [ 0 ] . response . url ,
2379
+ await driver . getCurrentUrl ( )
2380
+ )
2381
+ assert . equal ( onAuthRequired [ 0 ] . response . fromCache , false )
2382
+ assert ( onAuthRequired [ 0 ] . response . mimeType . includes ( 'text/plain' ) )
2383
+ assert . equal ( onAuthRequired [ 0 ] . response . status , 401 )
2384
+ assert . equal ( onAuthRequired [ 0 ] . response . statusText , 'unauthorized' )
2385
+ } )
2362
2386
} )
2363
2387
2364
2388
describe ( 'Integration Tests' , function ( ) {
You can’t perform that action at this time.
0 commit comments