Skip to content

Commit

Permalink
Do not allow object-shorthand and remove destructuring in functional …
Browse files Browse the repository at this point in the history
…test scripts (not supported by IE11)
  • Loading branch information
Rob Walch committed Apr 1, 2021
1 parent 22d983a commit d642557
Show file tree
Hide file tree
Showing 4 changed files with 80 additions and 42 deletions.
1 change: 1 addition & 0 deletions package.json
Expand Up @@ -49,6 +49,7 @@
"test:func": "BABEL_ENV=development mocha --require @babel/register tests/functional/auto/setup.js --timeout 40000 --exit",
"test:func:light": "BABEL_ENV=development HLSJS_LIGHT=1 mocha --require @babel/register tests/functional/auto/setup.js --timeout 40000 --exit",
"test:func:sauce": "SAUCE=1 UA=safari OS='OS X 10.15' BABEL_ENV=development mocha --require @babel/register tests/functional/auto/setup.js --timeout 40000 --exit",
"test:func:sauce-ie": "SAUCE=1 UA='internet explorer' OS='Windows 10' BABEL_ENV=development mocha --require @babel/register tests/functional/auto/setup.js --timeout 40000 --exit",
"type-check": "tsc --noEmit",
"type-check:watch": "npm run type-check -- --watch"
},
Expand Down
38 changes: 38 additions & 0 deletions tests/functional/auto/.eslintrc.js
@@ -0,0 +1,38 @@
module.exports = {
env: {
node: true,
commonjs: true,
es6: false,
mocha: true,
},
plugins: ['mocha', 'node'],
globals: {
// Test globals
after: false,
afterEach: false,
assert: false,
before: false,
beforeEach: false,
describe: false,
expect: true,
sinon: false,
xit: false,
},
rules: {
'object-shorthand': ['error', 'never'], // Object-shorthand not supported in IE11
// destructuring is not supported in IE11. This does not prevent it.
// ES6 env settings in parent files cannot be overwritten.
'prefer-destructuring': ['error', { object: false, array: false }],
'one-var': 0,
'no-undefined': 0,
'no-unused-expressions': 0,
'no-restricted-properties': [
2,
{ property: 'findIndex' }, // Intended to block usage of Array.prototype.findIndex
{ property: 'find' }, // Intended to block usage of Array.prototype.find
{ property: 'only' }, // Intended to block usage of it.only in commits
],
'node/no-restricted-require': ['error', ['assert']],
'mocha/no-mocha-arrows': 2,
},
};
47 changes: 23 additions & 24 deletions tests/functional/auto/setup.js
Expand Up @@ -151,13 +151,10 @@ async function testSmoothSwitch(url, config) {
const result = await browser.executeAsyncScript(
function (url, config) {
const callback = arguments[arguments.length - 1];
self.startStream(
url,
self.objectAssign(config, {
startLevel: 0,
}),
callback
);
const startConfig = self.objectAssign(config, {
startLevel: 0,
});
self.startStream(url, startConfig, callback);
self.hls.manualLevel = 0;
const video = self.video;
self.hls.once(self.Hls.Events.FRAG_CHANGED, function (eventName, data) {
Expand All @@ -167,7 +164,7 @@ async function testSmoothSwitch(url, config) {
const highestLevel = self.hls.levels.length - 1;
if (highestLevel === 0) {
callback({
highestLevel,
highestLevel: highestLevel,
currentTimeDelta: 0,
message: 'No adaptive variants',
logs: self.logString,
Expand All @@ -188,9 +185,9 @@ async function testSmoothSwitch(url, config) {
'[test] > currentTime delta: ' + (newCurrentTime - currentTime)
);
callback({
highestLevel,
highestLevel: highestLevel,
currentTimeDelta: newCurrentTime - currentTime,
paused,
paused: paused,
logs: self.logString,
});
}, 2000);
Expand Down Expand Up @@ -249,21 +246,22 @@ async function testSeekOnVOD(url, config) {
if (!isFinite(duration)) {
callback({
code: 'non-finite-duration',
duration,
duration: duration,
logs: self.logString,
});
}
// After seeking timeout if paused after 5 seconds
video.onseeked = function () {
console.log('[test] > video "onseeked"');
self.setTimeout(function () {
const { currentTime, paused } = video;
if (currentTime === 0 || paused) {
const currentTime = video.currentTime;
const paused = video.paused;
if (video.currentTime === 0 || paused) {
callback({
code: 'paused',
currentTime,
duration,
paused,
currentTime: currentTime,
duration: duration,
paused: paused,
logs: self.logString,
});
}
Expand All @@ -278,12 +276,13 @@ async function testSeekOnVOD(url, config) {
);
video.currentTime = seekToTime;
self.setTimeout(function () {
const { currentTime, paused } = video;
const currentTime = video.currentTime;
const paused = video.paused;
callback({
code: 'timeout-waiting-for-ended-event',
currentTime,
duration,
paused,
currentTime: currentTime,
duration: duration,
paused: paused,
logs: self.logString,
});
}, 12000);
Expand All @@ -297,7 +296,7 @@ async function testSeekOnVOD(url, config) {
callback({
code: 'buffer-gaps',
bufferedRanges: video.buffered.length,
duration,
duration: duration,
logs: self.logString,
});
}
Expand Down Expand Up @@ -420,7 +419,7 @@ async function sauceConnect(tunnelIdentifier) {
);
sauceConnectLauncher(
{
tunnelIdentifier,
tunnelIdentifier: tunnelIdentifier,
},
(err, sauceConnectProcess) => {
if (err) {
Expand Down Expand Up @@ -590,8 +589,8 @@ describe(`testing hls.js playback in the browser on "${browserDescription}"`, fu
const url = stream.url;
const config = stream.config || {};
if (
stream.blacklist_ua &&
stream.blacklist_ua.some((browserInfo) => {
stream.skip_ua &&
stream.skip_ua.some((browserInfo) => {
if (typeof browserInfo === 'string') {
return browserInfo === browserConfig.name;
}
Expand Down
36 changes: 18 additions & 18 deletions tests/test-streams.js
Expand Up @@ -4,29 +4,29 @@
* @param {string} description
* @param {boolean} [live]
* @param {boolean} [abr]
* @param {string[]} [blacklist_ua]
* @returns {{url: string, description: string, live: boolean, abr: boolean, blacklist_ua: string[]}}
* @param {string[]} [skip_ua]
* @returns {{url: string, description: string, live: boolean, abr: boolean, skip_ua: string[]}}
*/
function createTestStream(
url,
description,
live = false,
abr = true,
blacklist_ua = []
skip_ua = []
) {
return {
url,
description,
live,
abr,
blacklist_ua,
url: url,
description: description,
live: live,
abr: abr,
skip_ua: skip_ua,
};
}

/**
* @param {Object} target
* @param {Object} [config]
* @returns {{url: string, description: string, live: boolean, abr: boolean, blacklist_ua: string[]}}
* @returns {{url: string, description: string, live: boolean, abr: boolean, skip_ua: string[]}}
*/
function createTestStreamWithConfig(target, config) {
if (typeof target !== 'object') {
Expand All @@ -38,7 +38,7 @@ function createTestStreamWithConfig(target, config) {
target.description,
target.live,
target.abr,
target.blacklist_ua
target.skip_ua
);

testStream.config = config;
Expand All @@ -62,7 +62,7 @@ module.exports = {
'https://test-streams.mux.dev/x36xhzz/url_6/193039199_mp4_h264_aac_hq_7.m3u8',
description: 'Big Buck Bunny - 480p only',
abr: false,
blacklist_ua: ['internet explorer'],
skip_ua: ['internet explorer'],
},
arte: {
url: 'https://test-streams.mux.dev/test_001/stream.m3u8',
Expand All @@ -74,15 +74,15 @@ module.exports = {
'https://test-streams.mux.dev/dai-discontinuity-deltatre/manifest.m3u8',
description: 'Ad-insertion in event stream',
abr: false,
blacklist_ua: ['internet explorer'],
skip_ua: ['internet explorer'],
},
issue666: {
url:
'https://playertest.longtailvideo.com/adaptive/issue666/playlists/cisq0gim60007xzvi505emlxx.m3u8',
description:
'Surveillance footage - https://github.com/video-dev/hls.js/issues/666',
abr: false,
blacklist_ua: ['internet explorer'],
skip_ua: ['internet explorer'],
},
closedCaptions: {
url: 'https://playertest.longtailvideo.com/adaptive/captions/playlist.m3u8',
Expand Down Expand Up @@ -111,29 +111,29 @@ module.exports = {
url: 'https://pl.streamingvideoprovider.com/mp3-playlist/playlist.m3u8',
description: 'MPEG Audio Only demo',
abr: false,
blacklist_ua: ['internet explorer', 'MicrosoftEdge', 'firefox'],
skip_ua: ['internet explorer', 'MicrosoftEdge', 'firefox'],
},
fmp4: {
url:
'https://storage.googleapis.com/shaka-demo-assets/angel-one-hls/hls.m3u8',
description: 'HLS fMP4 Angel-One multiple audio-tracks',
abr: true,
blacklist_ua: ['internet explorer'],
skip_ua: ['internet explorer'],
},
fmp4Bitmovin: {
url:
'https://bitdash-a.akamaihd.net/content/MI201109210084_1/m3u8s-fmp4/f08e80da-bf1d-4e3d-8899-f0f6155f6efa.m3u8',
description: 'HLS fMP4 by Bitmovin',
abr: true,
blacklist_ua: ['internet explorer'],
skip_ua: ['internet explorer'],
},
fmp4BitmovinHevc: {
url:
'https://bitmovin-a.akamaihd.net/content/dataset/multi-codec/hevc/stream_fmp4.m3u8',
description:
'HLS HEVC fMP4 by Bitmovin (Safari and Edge? only as of 2020-08)',
abr: true,
blacklist_ua: ['internet explorer'],
skip_ua: ['internet explorer'],
skipFunctionalTests: true,
},
offset_pts: {
Expand All @@ -148,7 +148,7 @@ module.exports = {
description:
'Shaka-packager Widevine DRM (EME) HLS-fMP4 - Angel One Demo',
abr: true,
blacklist_ua: [
skip_ua: [
'firefox',
'safari',
'internet explorer',
Expand Down

0 comments on commit d642557

Please sign in to comment.