1
0
mirror of https://github.com/videojs/video.js.git synced 2025-07-15 01:34:23 +02:00

feat: Use userAgentData in favour of userAgent (#7979)

This commit is contained in:
mister-ben
2022-11-22 23:16:32 +01:00
committed by Pat O'Neill
parent db4201a800
commit 2d96c9d780
3 changed files with 150 additions and 271 deletions

View File

@ -218,141 +218,6 @@ QUnit.test('should remove the controls attribute when recreating the element', f
assert.ok(player.tagAttributes.controls, 'tag attribute is still present');
});
QUnit.test('patchCanPlayType patches canplaytype with our function, conditionally', function(assert) {
// the patch runs automatically so we need to first unpatch
Html5.unpatchCanPlayType();
const oldAV = browser.ANDROID_VERSION;
const oldIsFirefox = browser.IS_FIREFOX;
const oldIsChrome = browser.IS_CHROME;
const video = document.createElement('video');
const canPlayType = Html5.TEST_VID.constructor.prototype.canPlayType;
browser.stub_ANDROID_VERSION(4.0);
browser.stub_IS_FIREFOX(false);
browser.stub_IS_CHROME(false);
Html5.patchCanPlayType();
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'
);
browser.stub_ANDROID_VERSION(oldAV);
browser.stub_IS_FIREFOX(oldIsFirefox);
browser.stub_IS_CHROME(oldIsChrome);
Html5.unpatchCanPlayType();
});
QUnit.test('patchCanPlayType doesn\'t patch canplaytype with our function in Chrome for Android', function(assert) {
// the patch runs automatically so we need to first unpatch
Html5.unpatchCanPlayType();
const oldAV = browser.ANDROID_VERSION;
const oldIsChrome = browser.IS_CHROME;
const oldIsFirefox = browser.IS_FIREFOX;
const video = document.createElement('video');
const canPlayType = Html5.TEST_VID.constructor.prototype.canPlayType;
browser.stub_ANDROID_VERSION(4.0);
browser.stub_IS_CHROME(true);
browser.stub_IS_FIREFOX(false);
Html5.patchCanPlayType();
assert.strictEqual(
video.canPlayType,
canPlayType,
'original canPlayType and patched canPlayType should be equal'
);
browser.stub_ANDROID_VERSION(oldAV);
browser.stub_IS_CHROME(oldIsChrome);
browser.stub_IS_FIREFOX(oldIsFirefox);
Html5.unpatchCanPlayType();
});
QUnit.test('patchCanPlayType doesn\'t patch canplaytype with our function in Firefox for Android', function(assert) {
// the patch runs automatically so we need to first unpatch
Html5.unpatchCanPlayType();
const oldAV = browser.ANDROID_VERSION;
const oldIsFirefox = browser.IS_FIREFOX;
const oldIsChrome = browser.IS_CHROME;
const video = document.createElement('video');
const canPlayType = Html5.TEST_VID.constructor.prototype.canPlayType;
browser.stub_ANDROID_VERSION(4.0);
browser.stub_IS_FIREFOX(true);
browser.stub_IS_CHROME(false);
Html5.patchCanPlayType();
assert.strictEqual(
video.canPlayType,
canPlayType,
'original canPlayType and patched canPlayType should be equal'
);
browser.stub_ANDROID_VERSION(oldAV);
browser.stub_IS_FIREFOX(oldIsFirefox);
browser.stub_IS_CHROME(oldIsChrome);
Html5.unpatchCanPlayType();
});
QUnit.test('should return maybe for HLS urls on Android 4.0 or above when not Chrome or Firefox', function(assert) {
const oldAV = browser.ANDROID_VERSION;
const oldIsFirefox = browser.IS_FIREFOX;
const oldIsChrome = browser.IS_CHROME;
const video = document.createElement('video');
browser.stub_ANDROID_VERSION(4.0);
browser.stub_IS_FIREFOX(false);
browser.stub_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'
);
browser.stub_ANDROID_VERSION(oldAV);
browser.stub_IS_FIREFOX(oldIsFirefox);
browser.stub_IS_CHROME(oldIsChrome);
Html5.unpatchCanPlayType();
});
QUnit.test('error events may not set the errors property', function(assert) {
assert.equal(tech.error(), undefined, 'no tech-level error');
tech.trigger('error');