diff --git a/package.json b/package.json index f9274261f87..51fee6032f8 100644 --- a/package.json +++ b/package.json @@ -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" }, diff --git a/tests/functional/auto/.eslintrc.js b/tests/functional/auto/.eslintrc.js new file mode 100644 index 00000000000..4cadc9b0781 --- /dev/null +++ b/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, + }, +}; diff --git a/tests/functional/auto/setup.js b/tests/functional/auto/setup.js index 7cc2671e8d8..3903175a48c 100644 --- a/tests/functional/auto/setup.js +++ b/tests/functional/auto/setup.js @@ -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) { @@ -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, @@ -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); @@ -249,7 +246,7 @@ async function testSeekOnVOD(url, config) { if (!isFinite(duration)) { callback({ code: 'non-finite-duration', - duration, + duration: duration, logs: self.logString, }); } @@ -257,13 +254,14 @@ async function testSeekOnVOD(url, config) { 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, }); } @@ -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); @@ -297,7 +296,7 @@ async function testSeekOnVOD(url, config) { callback({ code: 'buffer-gaps', bufferedRanges: video.buffered.length, - duration, + duration: duration, logs: self.logString, }); } @@ -420,7 +419,7 @@ async function sauceConnect(tunnelIdentifier) { ); sauceConnectLauncher( { - tunnelIdentifier, + tunnelIdentifier: tunnelIdentifier, }, (err, sauceConnectProcess) => { if (err) { @@ -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; } diff --git a/tests/test-streams.js b/tests/test-streams.js index edefe8b375c..4d3cfe25df8 100644 --- a/tests/test-streams.js +++ b/tests/test-streams.js @@ -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') { @@ -38,7 +38,7 @@ function createTestStreamWithConfig(target, config) { target.description, target.live, target.abr, - target.blacklist_ua + target.skip_ua ); testStream.config = config; @@ -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', @@ -74,7 +74,7 @@ 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: @@ -82,7 +82,7 @@ module.exports = { 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', @@ -111,21 +111,21 @@ 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: @@ -133,7 +133,7 @@ module.exports = { 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: { @@ -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',