File tree Expand file tree Collapse file tree 1 file changed +8
-5
lines changed Expand file tree Collapse file tree 1 file changed +8
-5
lines changed Original file line number Diff line number Diff line change @@ -160,8 +160,6 @@ describe('FocusOriginMonitor', () => {
160
160
} ) ) ;
161
161
162
162
it ( 'should remove focus classes on blur' , async ( ( ) => {
163
- if ( platform . FIREFOX ) { return ; }
164
-
165
163
buttonElement . focus ( ) ;
166
164
fixture . detectChanges ( ) ;
167
165
@@ -272,8 +270,6 @@ describe('cdkFocusClasses', () => {
272
270
} ) ) ;
273
271
274
272
it ( 'should remove focus classes on blur' , async ( ( ) => {
275
- if ( platform . FIREFOX ) { return ; }
276
-
277
273
buttonElement . focus ( ) ;
278
274
fixture . detectChanges ( ) ;
279
275
@@ -335,14 +331,21 @@ function dispatchFocusEvent(element: Node, type = 'focus') {
335
331
element . dispatchEvent ( event ) ;
336
332
}
337
333
338
- /** Patches an elements focus method to properly emit focus events when the browser is blurred. */
334
+ /**
335
+ * Patches an elements focus and blur methods to properly emit focus events when the browser is
336
+ * blurred.
337
+ */
339
338
function patchElementFocus ( element : HTMLElement ) {
340
339
// On Saucelabs, browsers will run simultaneously and therefore can't focus all browser windows
341
340
// at the same time. This is problematic when testing focus states. Chrome and Firefox
342
341
// only fire FocusEvents when the window is focused. This issue also appears locally.
343
342
let _nativeButtonFocus = element . focus . bind ( element ) ;
343
+ let _nativeButtonBlur = element . blur . bind ( element ) ;
344
344
345
345
element . focus = ( ) => {
346
346
document . hasFocus ( ) ? _nativeButtonFocus ( ) : dispatchFocusEvent ( element ) ;
347
347
} ;
348
+ element . blur = ( ) => {
349
+ document . hasFocus ( ) ? _nativeButtonBlur ( ) : dispatchFocusEvent ( element , 'blur' ) ;
350
+ } ;
348
351
}
You can’t perform that action at this time.
0 commit comments