|
1 | 1 | /* eslint-env qunit */ |
2 | 2 | import PosterImage from '../../src/js/poster-image.js'; |
3 | 3 | import TestHelpers from './test-helpers.js'; |
| 4 | +import * as browser from '../../src/js/utils/browser.js'; |
4 | 5 | import document from 'global/document'; |
5 | 6 |
|
6 | 7 | QUnit.module('PosterImage', { |
@@ -76,6 +77,41 @@ QUnit.test('should remove itself from the document flow when there is no poster' |
76 | 77 | posterImage.dispose(); |
77 | 78 | }); |
78 | 79 |
|
| 80 | +// Regression guard for videojs/video.js#6270: on Edge, focusing the <video> |
| 81 | +// element when the poster is clicked leaves protected (DRM/EME) video black. |
| 82 | +QUnit.test('handleClick focuses the play toggle, not the tech, on Edge', function(assert) { |
| 83 | + const player = this.mockPlayer; |
| 84 | + |
| 85 | + player.controls(true); |
| 86 | + player.play = () => {}; |
| 87 | + |
| 88 | + const tech = player.tech(true); |
| 89 | + const playToggle = player.getChild('ControlBar').getChild('PlayToggle'); |
| 90 | + let techFocus = 0; |
| 91 | + let toggleFocus = 0; |
| 92 | + |
| 93 | + tech.focus = () => { |
| 94 | + techFocus++; |
| 95 | + }; |
| 96 | + playToggle.focus = () => { |
| 97 | + toggleFocus++; |
| 98 | + }; |
| 99 | + |
| 100 | + const origEdge = browser.IS_EDGE; |
| 101 | + |
| 102 | + browser.stub_IS_EDGE(true); |
| 103 | + player.posterImage.handleClick({type: 'tap'}); |
| 104 | + assert.strictEqual(toggleFocus, 1, 'play toggle focused on Edge'); |
| 105 | + assert.strictEqual(techFocus, 0, 'tech not focused on Edge'); |
| 106 | + |
| 107 | + browser.stub_IS_EDGE(false); |
| 108 | + player.posterImage.handleClick({type: 'tap'}); |
| 109 | + assert.strictEqual(techFocus, 1, 'tech focused on non-Edge'); |
| 110 | + assert.strictEqual(toggleFocus, 1, 'play toggle not focused again on non-Edge'); |
| 111 | + |
| 112 | + browser.stub_IS_EDGE(origEdge); |
| 113 | +}); |
| 114 | + |
79 | 115 | QUnit.test('should hide the poster in the appropriate player states', function(assert) { |
80 | 116 | const posterImage = new PosterImage(this.mockPlayer); |
81 | 117 | const playerDiv = document.createElement('div'); |
|
0 commit comments