Skip to content

Commit 9bb9c66

Browse files
committed
rebased
1 parent 7ddd73d commit 9bb9c66

File tree

1 file changed

+8
-5
lines changed

1 file changed

+8
-5
lines changed

src/lib/core/style/focus-classes.spec.ts

Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -160,8 +160,6 @@ describe('FocusOriginMonitor', () => {
160160
}));
161161

162162
it('should remove focus classes on blur', async(() => {
163-
if (platform.FIREFOX) { return; }
164-
165163
buttonElement.focus();
166164
fixture.detectChanges();
167165

@@ -272,8 +270,6 @@ describe('cdkFocusClasses', () => {
272270
}));
273271

274272
it('should remove focus classes on blur', async(() => {
275-
if (platform.FIREFOX) { return; }
276-
277273
buttonElement.focus();
278274
fixture.detectChanges();
279275

@@ -335,14 +331,21 @@ function dispatchFocusEvent(element: Node, type = 'focus') {
335331
element.dispatchEvent(event);
336332
}
337333

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+
*/
339338
function patchElementFocus(element: HTMLElement) {
340339
// On Saucelabs, browsers will run simultaneously and therefore can't focus all browser windows
341340
// at the same time. This is problematic when testing focus states. Chrome and Firefox
342341
// only fire FocusEvents when the window is focused. This issue also appears locally.
343342
let _nativeButtonFocus = element.focus.bind(element);
343+
let _nativeButtonBlur = element.blur.bind(element);
344344

345345
element.focus = () => {
346346
document.hasFocus() ? _nativeButtonFocus() : dispatchFocusEvent(element);
347347
};
348+
element.blur = () => {
349+
document.hasFocus() ? _nativeButtonBlur() : dispatchFocusEvent(element, 'blur');
350+
};
348351
}

0 commit comments

Comments
 (0)