|
2 | 2 | import sinon from 'sinon';
|
3 | 3 | import {silencePromise} from '../../src/js/utils/promise';
|
4 | 4 | import TestHelpers from './test-helpers';
|
| 5 | +import * as browser from '../../src/js/utils/browser.js'; |
5 | 6 |
|
6 | 7 | QUnit.module('Player#play', {
|
7 | 8 |
|
@@ -104,3 +105,35 @@ QUnit.test('tech ready + has source + changing source = wait for loadstart', fun
|
104 | 105 | this.player.trigger('loadstart');
|
105 | 106 | assert.strictEqual(this.techPlayCallCount, 1, 'tech_.play was called');
|
106 | 107 | });
|
| 108 | + |
| 109 | +QUnit.test('play call from native replay calls resetProgressBar_', function(assert) { |
| 110 | + const origSafari = browser.IS_ANY_SAFARI; |
| 111 | + const origIOS = browser.IS_IOS; |
| 112 | + |
| 113 | + browser.stub_IS_ANY_SAFARI(true); |
| 114 | + |
| 115 | + // Mock the player having a source. |
| 116 | + this.player.src('xyz.mp4'); |
| 117 | + this.clock.tick(100); |
| 118 | + |
| 119 | + // Attempt to play, but silence the promise that might be returned. |
| 120 | + silencePromise(this.player.play()); |
| 121 | + assert.strictEqual(this.techPlayCallCount, 1, 'tech_.play was called'); |
| 122 | + |
| 123 | + // add vjs-ended for replay logic and play again. |
| 124 | + this.player.addClass('vjs-ended'); |
| 125 | + |
| 126 | + silencePromise(this.player.play()); |
| 127 | + assert.strictEqual(this.techPlayCallCount, 2, 'tech_.play was called'); |
| 128 | + assert.strictEqual(this.techCurrentTimeCallCount, 1, 'tech_.currentTime was called'); |
| 129 | + |
| 130 | + // Reset safari stub and try replay in iOS. |
| 131 | + browser.stub_IS_ANY_SAFARI(origSafari); |
| 132 | + browser.stub_IS_IOS(true); |
| 133 | + |
| 134 | + silencePromise(this.player.play()); |
| 135 | + assert.strictEqual(this.techPlayCallCount, 3, 'tech_.play was called'); |
| 136 | + assert.strictEqual(this.techCurrentTimeCallCount, 2, 'tech_.currentTime was called'); |
| 137 | + |
| 138 | + browser.stub_IS_IOS(origIOS); |
| 139 | +}); |
0 commit comments