mirror of
https://github.com/videojs/video.js.git
synced 2025-07-15 01:34:23 +02:00
fix(vjsstandard): update to 8.0.2 and fixup linting (#5413)
This commit is contained in:
@ -200,19 +200,25 @@ QUnit.test('patchCanPlayType patches canplaytype with our function, conditionall
|
||||
browser.IS_CHROME = false;
|
||||
Html5.patchCanPlayType();
|
||||
|
||||
assert.notStrictEqual(video.canPlayType,
|
||||
canPlayType,
|
||||
'original canPlayType and patched canPlayType should not be equal');
|
||||
assert.notStrictEqual(
|
||||
video.canPlayType,
|
||||
canPlayType,
|
||||
'original canPlayType and patched canPlayType should not be equal'
|
||||
);
|
||||
|
||||
const patchedCanPlayType = video.canPlayType;
|
||||
const unpatchedCanPlayType = Html5.unpatchCanPlayType();
|
||||
|
||||
assert.strictEqual(canPlayType,
|
||||
Html5.TEST_VID.constructor.prototype.canPlayType,
|
||||
'original canPlayType and unpatched canPlayType should be equal');
|
||||
assert.strictEqual(patchedCanPlayType,
|
||||
unpatchedCanPlayType,
|
||||
'patched canPlayType and function returned from unpatch are equal');
|
||||
assert.strictEqual(
|
||||
canPlayType,
|
||||
Html5.TEST_VID.constructor.prototype.canPlayType,
|
||||
'original canPlayType and unpatched canPlayType should be equal'
|
||||
);
|
||||
assert.strictEqual(
|
||||
patchedCanPlayType,
|
||||
unpatchedCanPlayType,
|
||||
'patched canPlayType and function returned from unpatch are equal'
|
||||
);
|
||||
|
||||
browser.ANDROID_VERSION = oldAV;
|
||||
browser.IS_FIREFOX = oldIsFirefox;
|
||||
@ -235,9 +241,11 @@ QUnit.test('patchCanPlayType doesn\'t patch canplaytype with our function in Chr
|
||||
browser.IS_FIREFOX = false;
|
||||
Html5.patchCanPlayType();
|
||||
|
||||
assert.strictEqual(video.canPlayType,
|
||||
canPlayType,
|
||||
'original canPlayType and patched canPlayType should be equal');
|
||||
assert.strictEqual(
|
||||
video.canPlayType,
|
||||
canPlayType,
|
||||
'original canPlayType and patched canPlayType should be equal'
|
||||
);
|
||||
|
||||
browser.ANDROID_VERSION = oldAV;
|
||||
browser.IS_CHROME = oldIsChrome;
|
||||
@ -260,9 +268,11 @@ QUnit.test('patchCanPlayType doesn\'t patch canplaytype with our function in Fir
|
||||
browser.IS_CHROME = false;
|
||||
Html5.patchCanPlayType();
|
||||
|
||||
assert.strictEqual(video.canPlayType,
|
||||
canPlayType,
|
||||
'original canPlayType and patched canPlayType should be equal');
|
||||
assert.strictEqual(
|
||||
video.canPlayType,
|
||||
canPlayType,
|
||||
'original canPlayType and patched canPlayType should be equal'
|
||||
);
|
||||
|
||||
browser.ANDROID_VERSION = oldAV;
|
||||
browser.IS_FIREFOX = oldIsFirefox;
|
||||
@ -281,20 +291,28 @@ QUnit.test('should return maybe for HLS urls on Android 4.0 or above when not Ch
|
||||
browser.IS_CHROME = false;
|
||||
Html5.patchCanPlayType();
|
||||
|
||||
assert.strictEqual(video.canPlayType('application/x-mpegurl'),
|
||||
'maybe',
|
||||
'android version 4.0 or above should be a maybe for x-mpegurl');
|
||||
assert.strictEqual(video.canPlayType('application/x-mpegURL'),
|
||||
'maybe',
|
||||
'android version 4.0 or above should be a maybe for x-mpegURL');
|
||||
assert.strictEqual(video.canPlayType('application/vnd.apple.mpegurl'),
|
||||
'maybe',
|
||||
'android version 4.0 or above should be a ' +
|
||||
'maybe for vnd.apple.mpegurl');
|
||||
assert.strictEqual(video.canPlayType('application/vnd.apple.mpegURL'),
|
||||
'maybe',
|
||||
'android version 4.0 or above should be a ' +
|
||||
'maybe for vnd.apple.mpegurl');
|
||||
assert.strictEqual(
|
||||
video.canPlayType('application/x-mpegurl'),
|
||||
'maybe',
|
||||
'android version 4.0 or above should be a maybe for x-mpegurl'
|
||||
);
|
||||
assert.strictEqual(
|
||||
video.canPlayType('application/x-mpegURL'),
|
||||
'maybe',
|
||||
'android version 4.0 or above should be a maybe for x-mpegURL'
|
||||
);
|
||||
assert.strictEqual(
|
||||
video.canPlayType('application/vnd.apple.mpegurl'),
|
||||
'maybe',
|
||||
'android version 4.0 or above should be a ' +
|
||||
'maybe for vnd.apple.mpegurl'
|
||||
);
|
||||
assert.strictEqual(
|
||||
video.canPlayType('application/vnd.apple.mpegURL'),
|
||||
'maybe',
|
||||
'android version 4.0 or above should be a ' +
|
||||
'maybe for vnd.apple.mpegurl'
|
||||
);
|
||||
|
||||
browser.ANDROID_VERSION = oldAV;
|
||||
browser.IS_FIREFOX = oldIsFirefox;
|
||||
@ -309,9 +327,11 @@ QUnit.test('should return a maybe for mp4 on OLD ANDROID', function(assert) {
|
||||
browser.IS_OLD_ANDROID = true;
|
||||
Html5.patchCanPlayType();
|
||||
|
||||
assert.strictEqual(video.canPlayType('video/mp4'),
|
||||
'maybe',
|
||||
'old android should return a maybe for video/mp4');
|
||||
assert.strictEqual(
|
||||
video.canPlayType('video/mp4'),
|
||||
'maybe',
|
||||
'old android should return a maybe for video/mp4'
|
||||
);
|
||||
|
||||
browser.IS_OLD_ANDROID = isOldAndroid;
|
||||
Html5.unpatchCanPlayType();
|
||||
@ -340,9 +360,11 @@ QUnit.test('native source handler canPlayType', function(assert) {
|
||||
|
||||
const canPlayType = Html5.nativeSourceHandler.canPlayType;
|
||||
|
||||
assert.equal(canPlayType('video/mp4'),
|
||||
'maybe',
|
||||
'Native source handler reported type support');
|
||||
assert.equal(
|
||||
canPlayType('video/mp4'),
|
||||
'maybe',
|
||||
'Native source handler reported type support'
|
||||
);
|
||||
assert.equal(canPlayType('foo'), '', 'Native source handler handled bad type');
|
||||
|
||||
// Reset test video canPlayType
|
||||
@ -362,32 +384,48 @@ QUnit.test('native source handler canHandleSource', function(assert) {
|
||||
|
||||
const canHandleSource = Html5.nativeSourceHandler.canHandleSource;
|
||||
|
||||
assert.equal(canHandleSource({ type: 'video/mp4', src: 'video.flv' }, {}),
|
||||
'maybe',
|
||||
'Native source handler reported type support');
|
||||
assert.equal(canHandleSource({ src: 'http://www.example.com/video.mp4' }, {}),
|
||||
'maybe',
|
||||
'Native source handler reported extension support');
|
||||
assert.equal(canHandleSource({ src: 'https://example.com/video.sd.mp4?s=foo&token=bar' }, {}),
|
||||
'maybe',
|
||||
'Native source handler reported extension support');
|
||||
assert.equal(canHandleSource({ src: 'https://example.com/video.sd.mp4?s=foo' }, {}),
|
||||
'maybe',
|
||||
'Native source handler reported extension support');
|
||||
assert.equal(
|
||||
canHandleSource({ type: 'video/mp4', src: 'video.flv' }, {}),
|
||||
'maybe',
|
||||
'Native source handler reported type support'
|
||||
);
|
||||
assert.equal(
|
||||
canHandleSource({ src: 'http://www.example.com/video.mp4' }, {}),
|
||||
'maybe',
|
||||
'Native source handler reported extension support'
|
||||
);
|
||||
assert.equal(
|
||||
canHandleSource({ src: 'https://example.com/video.sd.mp4?s=foo&token=bar' }, {}),
|
||||
'maybe',
|
||||
'Native source handler reported extension support'
|
||||
);
|
||||
assert.equal(
|
||||
canHandleSource({ src: 'https://example.com/video.sd.mp4?s=foo' }, {}),
|
||||
'maybe',
|
||||
'Native source handler reported extension support'
|
||||
);
|
||||
|
||||
// Test for issue videojs/video.js#1785 and other potential failures
|
||||
assert.equal(canHandleSource({ src: '' }, {}),
|
||||
'',
|
||||
'Native source handler handled empty src');
|
||||
assert.equal(canHandleSource({}, {}),
|
||||
'',
|
||||
'Native source handler handled empty object');
|
||||
assert.equal(canHandleSource({ src: 'foo' }, {}),
|
||||
'',
|
||||
'Native source handler handled bad src');
|
||||
assert.equal(canHandleSource({ type: 'foo' }, {}),
|
||||
'',
|
||||
'Native source handler handled bad type');
|
||||
assert.equal(
|
||||
canHandleSource({ src: '' }, {}),
|
||||
'',
|
||||
'Native source handler handled empty src'
|
||||
);
|
||||
assert.equal(
|
||||
canHandleSource({}, {}),
|
||||
'',
|
||||
'Native source handler handled empty object'
|
||||
);
|
||||
assert.equal(
|
||||
canHandleSource({ src: 'foo' }, {}),
|
||||
'',
|
||||
'Native source handler handled bad src'
|
||||
);
|
||||
assert.equal(
|
||||
canHandleSource({ type: 'foo' }, {}),
|
||||
'',
|
||||
'Native source handler handled bad type'
|
||||
);
|
||||
|
||||
// Reset test video canPlayType
|
||||
Html5.TEST_VID.canPlayType = origCPT;
|
||||
@ -557,31 +595,47 @@ if (Html5.supportsNativeAudioTracks()) {
|
||||
|
||||
const htmlTech = new Html5({el});
|
||||
|
||||
assert.equal(adds.length, 3,
|
||||
'should have added change, remove, add listeners');
|
||||
assert.equal(rems.length, 0,
|
||||
'no listeners should be removed');
|
||||
assert.equal(
|
||||
adds.length, 3,
|
||||
'should have added change, remove, add listeners'
|
||||
);
|
||||
assert.equal(
|
||||
rems.length, 0,
|
||||
'no listeners should be removed'
|
||||
);
|
||||
|
||||
htmlTech.overrideNativeAudioTracks(true);
|
||||
|
||||
assert.equal(adds.length, 3,
|
||||
'should not have added additional listeners');
|
||||
assert.equal(rems.length, 3,
|
||||
'should have removed previous three listeners');
|
||||
assert.equal(
|
||||
adds.length, 3,
|
||||
'should not have added additional listeners'
|
||||
);
|
||||
assert.equal(
|
||||
rems.length, 3,
|
||||
'should have removed previous three listeners'
|
||||
);
|
||||
|
||||
htmlTech.overrideNativeAudioTracks(true);
|
||||
|
||||
assert.equal(adds.length, 3,
|
||||
'no state change so do not add listeners');
|
||||
assert.equal(rems.length, 3,
|
||||
'no state change so do not remove listeners');
|
||||
assert.equal(
|
||||
adds.length, 3,
|
||||
'no state change so do not add listeners'
|
||||
);
|
||||
assert.equal(
|
||||
rems.length, 3,
|
||||
'no state change so do not remove listeners'
|
||||
);
|
||||
|
||||
htmlTech.overrideNativeAudioTracks(false);
|
||||
|
||||
assert.equal(adds.length, 6,
|
||||
'should add listeners because native tracks should be proxied');
|
||||
assert.equal(rems.length, 3,
|
||||
'should not remove listeners because there where none added on previous state');
|
||||
assert.equal(
|
||||
adds.length, 6,
|
||||
'should add listeners because native tracks should be proxied'
|
||||
);
|
||||
assert.equal(
|
||||
rems.length, 3,
|
||||
'should not remove listeners because there where none added on previous state'
|
||||
);
|
||||
|
||||
htmlTech.dispose();
|
||||
});
|
||||
@ -674,31 +728,47 @@ if (Html5.supportsNativeVideoTracks()) {
|
||||
|
||||
const htmlTech = new Html5({el});
|
||||
|
||||
assert.equal(adds.length, 3,
|
||||
'should have added change, remove, add listeners');
|
||||
assert.equal(rems.length, 0,
|
||||
'no listeners should be removed');
|
||||
assert.equal(
|
||||
adds.length, 3,
|
||||
'should have added change, remove, add listeners'
|
||||
);
|
||||
assert.equal(
|
||||
rems.length, 0,
|
||||
'no listeners should be removed'
|
||||
);
|
||||
|
||||
htmlTech.overrideNativeVideoTracks(true);
|
||||
|
||||
assert.equal(adds.length, 3,
|
||||
'should not have added additional listeners');
|
||||
assert.equal(rems.length, 3,
|
||||
'should have removed previous three listeners');
|
||||
assert.equal(
|
||||
adds.length, 3,
|
||||
'should not have added additional listeners'
|
||||
);
|
||||
assert.equal(
|
||||
rems.length, 3,
|
||||
'should have removed previous three listeners'
|
||||
);
|
||||
|
||||
htmlTech.overrideNativeVideoTracks(true);
|
||||
|
||||
assert.equal(adds.length, 3,
|
||||
'no state change so do not add listeners');
|
||||
assert.equal(rems.length, 3,
|
||||
'no state change so do not remove listeners');
|
||||
assert.equal(
|
||||
adds.length, 3,
|
||||
'no state change so do not add listeners'
|
||||
);
|
||||
assert.equal(
|
||||
rems.length, 3,
|
||||
'no state change so do not remove listeners'
|
||||
);
|
||||
|
||||
htmlTech.overrideNativeVideoTracks(false);
|
||||
|
||||
assert.equal(adds.length, 6,
|
||||
'should add listeners because native tracks should be proxied');
|
||||
assert.equal(rems.length, 3,
|
||||
'should not remove listeners because there where none added on previous state');
|
||||
assert.equal(
|
||||
adds.length, 6,
|
||||
'should add listeners because native tracks should be proxied'
|
||||
);
|
||||
assert.equal(
|
||||
rems.length, 3,
|
||||
'should not remove listeners because there where none added on previous state'
|
||||
);
|
||||
|
||||
htmlTech.dispose();
|
||||
});
|
||||
@ -707,16 +777,22 @@ if (Html5.supportsNativeVideoTracks()) {
|
||||
QUnit.test('should always return currentSource_ if set', function(assert) {
|
||||
const currentSrc = Html5.prototype.currentSrc;
|
||||
|
||||
assert.equal(currentSrc.call({el_: {currentSrc: 'test1'}}),
|
||||
'test1',
|
||||
'sould return source from element if nothing else set');
|
||||
assert.equal(currentSrc.call({currentSource_: {src: 'test2'}}),
|
||||
'test2',
|
||||
'sould return source from currentSource_, if nothing else set');
|
||||
assert.equal(currentSrc.call({currentSource_: {src: 'test2'},
|
||||
el_: {currentSrc: 'test1'}}),
|
||||
'test2',
|
||||
'sould return source from source set, not from element');
|
||||
assert.equal(
|
||||
currentSrc.call({el_: {currentSrc: 'test1'}}),
|
||||
'test1',
|
||||
'sould return source from element if nothing else set'
|
||||
);
|
||||
assert.equal(
|
||||
currentSrc.call({currentSource_: {src: 'test2'}}),
|
||||
'test2',
|
||||
'sould return source from currentSource_, if nothing else set'
|
||||
);
|
||||
assert.equal(
|
||||
currentSrc.call({currentSource_: {src: 'test2'},
|
||||
el_: {currentSrc: 'test1'}}),
|
||||
'test2',
|
||||
'sould return source from source set, not from element'
|
||||
);
|
||||
});
|
||||
|
||||
QUnit.test('should fire makeup events when a video tag is initialized late', function(assert) {
|
||||
@ -742,11 +818,13 @@ QUnit.test('should fire makeup events when a video tag is initialized late', fun
|
||||
function testStates(statesObject, expectedEvents) {
|
||||
lateInit.call(mockHtml5, statesObject);
|
||||
mockHtml5.triggerReady();
|
||||
assert.deepEqual(triggeredEvents,
|
||||
expectedEvents,
|
||||
'wrong events triggered for ' +
|
||||
assert.deepEqual(
|
||||
triggeredEvents,
|
||||
expectedEvents,
|
||||
'wrong events triggered for ' +
|
||||
`networkState:${statesObject.networkState} ` +
|
||||
`and readyState:${statesObject.readyState || 'no readyState'}`);
|
||||
`and readyState:${statesObject.readyState || 'no readyState'}`
|
||||
);
|
||||
|
||||
// reset mock
|
||||
triggeredEvents = [];
|
||||
@ -762,12 +840,18 @@ QUnit.test('should fire makeup events when a video tag is initialized late', fun
|
||||
// Ready States
|
||||
testStates({ networkState: 1, readyState: 0 }, ['loadstart']);
|
||||
testStates({ networkState: 1, readyState: 1 }, ['loadstart', 'loadedmetadata']);
|
||||
testStates({ networkState: 1, readyState: 2 },
|
||||
['loadstart', 'loadedmetadata', 'loadeddata']);
|
||||
testStates({ networkState: 1, readyState: 3 },
|
||||
['loadstart', 'loadedmetadata', 'loadeddata', 'canplay']);
|
||||
testStates({ networkState: 1, readyState: 4 },
|
||||
['loadstart', 'loadedmetadata', 'loadeddata', 'canplay', 'canplaythrough']);
|
||||
testStates(
|
||||
{ networkState: 1, readyState: 2 },
|
||||
['loadstart', 'loadedmetadata', 'loadeddata']
|
||||
);
|
||||
testStates(
|
||||
{ networkState: 1, readyState: 3 },
|
||||
['loadstart', 'loadedmetadata', 'loadeddata', 'canplay']
|
||||
);
|
||||
testStates(
|
||||
{ networkState: 1, readyState: 4 },
|
||||
['loadstart', 'loadedmetadata', 'loadeddata', 'canplay', 'canplaythrough']
|
||||
);
|
||||
});
|
||||
|
||||
QUnit.test('Html5.resetMediaElement should remove sources and call load', function(assert) {
|
||||
@ -797,9 +881,11 @@ QUnit.test('Html5.resetMediaElement should remove sources and call load', functi
|
||||
|
||||
Html5.resetMediaElement(testEl);
|
||||
assert.equal(selector, 'source', 'we got the source elements from the test el');
|
||||
assert.deepEqual(removedChildren,
|
||||
children.reverse(),
|
||||
'we removed the children that were present');
|
||||
assert.deepEqual(
|
||||
removedChildren,
|
||||
children.reverse(),
|
||||
'we removed the children that were present'
|
||||
);
|
||||
assert.equal(removedAttribute, 'src', 'we removed the src attribute');
|
||||
assert.ok(loaded, 'we called load on the element');
|
||||
});
|
||||
@ -854,9 +940,11 @@ QUnit.test('supports getting available media playback quality metrics', function
|
||||
tech.el_ = {
|
||||
getVideoPlaybackQuality: () => videoPlaybackQuality
|
||||
};
|
||||
assert.deepEqual(tech.getVideoPlaybackQuality(),
|
||||
videoPlaybackQuality,
|
||||
'uses native implementation when supported');
|
||||
assert.deepEqual(
|
||||
tech.getVideoPlaybackQuality(),
|
||||
videoPlaybackQuality,
|
||||
'uses native implementation when supported'
|
||||
);
|
||||
|
||||
tech.el_ = {
|
||||
webkitDroppedFrameCount: 1,
|
||||
@ -865,9 +953,11 @@ QUnit.test('supports getting available media playback quality metrics', function
|
||||
window.performance = {
|
||||
now: () => 4
|
||||
};
|
||||
assert.deepEqual(tech.getVideoPlaybackQuality(),
|
||||
{ droppedVideoFrames: 1, totalVideoFrames: 2, creationTime: 4 },
|
||||
'uses webkit prefixed metrics and performance.now when supported');
|
||||
assert.deepEqual(
|
||||
tech.getVideoPlaybackQuality(),
|
||||
{ droppedVideoFrames: 1, totalVideoFrames: 2, creationTime: 4 },
|
||||
'uses webkit prefixed metrics and performance.now when supported'
|
||||
);
|
||||
|
||||
tech.el_ = {
|
||||
webkitDroppedFrameCount: 1,
|
||||
@ -881,10 +971,12 @@ QUnit.test('supports getting available media playback quality metrics', function
|
||||
navigationStart: 3
|
||||
}
|
||||
};
|
||||
assert.deepEqual(tech.getVideoPlaybackQuality(),
|
||||
{ droppedVideoFrames: 1, totalVideoFrames: 2, creationTime: 7 },
|
||||
'uses webkit prefixed metrics and Date.now() - navigationStart when ' +
|
||||
'supported');
|
||||
assert.deepEqual(
|
||||
tech.getVideoPlaybackQuality(),
|
||||
{ droppedVideoFrames: 1, totalVideoFrames: 2, creationTime: 7 },
|
||||
'uses webkit prefixed metrics and Date.now() - navigationStart when ' +
|
||||
'supported'
|
||||
);
|
||||
|
||||
tech.el_ = {};
|
||||
window.performance = void 0;
|
||||
@ -893,27 +985,33 @@ QUnit.test('supports getting available media playback quality metrics', function
|
||||
window.performance = {
|
||||
now: () => 5
|
||||
};
|
||||
assert.deepEqual(tech.getVideoPlaybackQuality(),
|
||||
{ creationTime: 5 },
|
||||
'only creation time when it\'s the only piece available');
|
||||
assert.deepEqual(
|
||||
tech.getVideoPlaybackQuality(),
|
||||
{ creationTime: 5 },
|
||||
'only creation time when it\'s the only piece available'
|
||||
);
|
||||
|
||||
window.performance = {
|
||||
timing: {
|
||||
navigationStart: 3
|
||||
}
|
||||
};
|
||||
assert.deepEqual(tech.getVideoPlaybackQuality(),
|
||||
{ creationTime: 7 },
|
||||
'only creation time when it\'s the only piece available');
|
||||
assert.deepEqual(
|
||||
tech.getVideoPlaybackQuality(),
|
||||
{ creationTime: 7 },
|
||||
'only creation time when it\'s the only piece available'
|
||||
);
|
||||
|
||||
tech.el_ = {
|
||||
getVideoPlaybackQuality: () => videoPlaybackQuality,
|
||||
webkitDroppedFrameCount: 1,
|
||||
webkitDecodedFrameCount: 2
|
||||
};
|
||||
assert.deepEqual(tech.getVideoPlaybackQuality(),
|
||||
videoPlaybackQuality,
|
||||
'prefers native implementation when supported');
|
||||
assert.deepEqual(
|
||||
tech.getVideoPlaybackQuality(),
|
||||
videoPlaybackQuality,
|
||||
'prefers native implementation when supported'
|
||||
);
|
||||
|
||||
tech.el_ = oldEl;
|
||||
window.performance = origPerformance;
|
||||
|
Reference in New Issue
Block a user