diff --git a/.github/workflows/interop-tests.yml b/.github/workflows/interop-tests.yml index 8ec60e1bf..68b5fca33 100644 --- a/.github/workflows/interop-tests.yml +++ b/.github/workflows/interop-tests.yml @@ -13,11 +13,11 @@ jobs: browserB: [firefox, chrome] bver: ['unstable'] steps: - - uses: actions/checkout@v3 - - uses: actions/setup-node@v3 + - uses: actions/checkout@v4 + - uses: actions/setup-node@v4 - run: npm install - - run: BROWSER=${{matrix.browserA}} BVER=${{matrix.bver}} ./node_modules/travis-multirunner/setup.sh - - run: BROWSER=${{matrix.browserB}} BVER=${{matrix.bver}} ./node_modules/travis-multirunner/setup.sh - run: sudo rm /usr/bin/chromedriver /usr/bin/geckodriver # remove preinstalled github chromedriver/geckodriver from $PATH - run: Xvfb :99 & + - run: BROWSER=${{matrix.browserA}} BVER=${{matrix.version}} node -e "require('./test/webdriver').buildDriver()" # preinstall + - run: BROWSER=${{matrix.browserB}} BVER=${{matrix.version}} node -e "require('./test/webdriver').buildDriver()" # preinstall - run: BROWSER_A=${{matrix.browserA}} BROWSER_B=${{matrix.browserB}} BVER=${{matrix.bver}} DISPLAY=:99.0 node_modules/.bin/jest --retries=3 test/interop/ diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index bee0c5cd7..4ea17dfcd 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -6,8 +6,8 @@ jobs: lint: runs-on: ubuntu-latest steps: - - uses: actions/checkout@v3 - - uses: actions/setup-node@v3 + - uses: actions/checkout@v4 + - uses: actions/setup-node@v4 - run: npm install - run: npm run eslint - run: npm run stylelint @@ -20,10 +20,10 @@ jobs: browser: [chrome] version: [stable] steps: - - uses: actions/checkout@v2 - - uses: actions/setup-node@v3 + - uses: actions/checkout@v4 + - uses: actions/setup-node@v4 - run: npm install - - run: BROWSER=${{matrix.browser}} BVER=${{matrix.version}} ./node_modules/travis-multirunner/setup.sh - run: sudo rm /usr/bin/chromedriver # remove preinstalled github chromedriver from $PATH - run: Xvfb :99 & + - run: BROWSER=${{matrix.browser}} BVER=${{matrix.version}} node -e "require('./test/webdriver').buildDriver()" # preinstall - run: BROWSER=${{matrix.browser}} BVER=${{matrix.version}} DISPLAY=:99.0 npm run jest -- --retries=3 diff --git a/package.json b/package.json index 37766e8b1..c2eb0d2ff 100644 --- a/package.json +++ b/package.json @@ -1,14 +1,12 @@ { "name": "webrtc-samples", + "private": true, "version": "1.0.0", "description": "Project checking for WebRTC GitHub samples repo", "keywords": [ - "webrtc", - "demos", - "samples", - "javascript" + "webrtc" ], - "homepage": "https://github.com/webrtc/samples", + "homepage": "https://webrtc.github.io/samples/", "bugs": { "url": "https://github.com/webrtc/samples/issues" }, @@ -29,14 +27,14 @@ "'**/third_party/*.js'" ], "devDependencies": { + "@puppeteer/browsers": "^2.2.0", "eslint": "^8.9.0", "eslint-config-google": "^0.14.0", "eslint-plugin-jest": "^27.4.0", "http-server": "^14.1.0", "jest": "^29.7.0", - "selenium-webdriver": "^4.12.0", + "selenium-webdriver": "^4.19.0", "stylelint": "^14.5.3", - "stylelint-config-recommended": "^7.0.0", - "travis-multirunner": "^5.0.1" + "stylelint-config-recommended": "^7.0.0" } } diff --git a/src/content/datachannel/basic/js/test.js b/src/content/datachannel/basic/js/test.js index aef58e6cf..5094ec469 100644 --- a/src/content/datachannel/basic/js/test.js +++ b/src/content/datachannel/basic/js/test.js @@ -13,8 +13,8 @@ const path = '/src/content/datachannel/basic/index.html'; const url = `${process.env.BASEURL ? process.env.BASEURL : ('file://' + process.cwd())}${path}`; describe('datachannel basic', () => { - beforeAll(() => { - driver = seleniumHelpers.buildDriver(); + beforeAll(async () => { + driver = await seleniumHelpers.buildDriver(); }); afterAll(() => { return driver.quit(); diff --git a/src/content/datachannel/channel/js/test.js b/src/content/datachannel/channel/js/test.js index 1b9797e91..c7a848c89 100644 --- a/src/content/datachannel/channel/js/test.js +++ b/src/content/datachannel/channel/js/test.js @@ -16,8 +16,8 @@ const path = '/src/content/datachannel/channel/index.html'; const url = `${process.env.BASEURL ? process.env.BASEURL : ('file://' + process.cwd())}${path}`; describe('datachannel and broadcast channels', () => { - beforeAll(() => { - driver = seleniumHelpers.buildDriver(); + beforeAll(async () => { + driver = await seleniumHelpers.buildDriver(); }); afterAll(() => { return driver.quit(); diff --git a/src/content/datachannel/datatransfer/js/test.js b/src/content/datachannel/datatransfer/js/test.js index 44f0058d0..cb0b0f401 100644 --- a/src/content/datachannel/datatransfer/js/test.js +++ b/src/content/datachannel/datatransfer/js/test.js @@ -16,8 +16,8 @@ const path = '/src/content/datachannel/datatransfer/index.html'; const url = `${process.env.BASEURL ? process.env.BASEURL : ('file://' + process.cwd())}${path}`; describe('datachannel datatransfer', () => { - beforeAll(() => { - driver = seleniumHelpers.buildDriver(); + beforeAll(async () => { + driver = await seleniumHelpers.buildDriver(); }); afterAll(() => { return driver.quit(); diff --git a/src/content/datachannel/filetransfer/js/test.js b/src/content/datachannel/filetransfer/js/test.js index efb8cc06c..c4e8ee5c6 100644 --- a/src/content/datachannel/filetransfer/js/test.js +++ b/src/content/datachannel/filetransfer/js/test.js @@ -16,8 +16,8 @@ const path = '/src/content/datachannel/filetransfer/index.html'; const url = `${process.env.BASEURL ? process.env.BASEURL : ('file://' + process.cwd())}${path}`; describe('datachannel filetransfer', () => { - beforeAll(() => { - driver = seleniumHelpers.buildDriver(); + beforeAll(async () => { + driver = await seleniumHelpers.buildDriver(); }); afterAll(() => { return driver.quit(); diff --git a/src/content/devices/input-output/js/test.js b/src/content/devices/input-output/js/test.js index c1ba3f3d6..02725351a 100644 --- a/src/content/devices/input-output/js/test.js +++ b/src/content/devices/input-output/js/test.js @@ -15,8 +15,8 @@ const path = '/src/content/devices/input-output/index.html'; const url = `${process.env.BASEURL ? process.env.BASEURL : ('file://' + process.cwd())}${path}`; describe('input-output', () => { - beforeAll(() => { - driver = seleniumHelpers.buildDriver(); + beforeAll(async () => { + driver = await seleniumHelpers.buildDriver(); }); afterAll(() => { return driver.quit(); diff --git a/src/content/getusermedia/gum/js/test.js b/src/content/getusermedia/gum/js/test.js index 6c0a48b3b..ff471fe77 100644 --- a/src/content/getusermedia/gum/js/test.js +++ b/src/content/getusermedia/gum/js/test.js @@ -16,8 +16,8 @@ const path = '/src/content/getusermedia/gum/index.html'; const url = `${process.env.BASEURL ? process.env.BASEURL : ('file://' + process.cwd())}${path}`; describe('getUserMedia', () => { - beforeAll(() => { - driver = seleniumHelpers.buildDriver(); + beforeAll(async () => { + driver = await seleniumHelpers.buildDriver(); }); afterAll(() => { return driver.quit(); diff --git a/src/content/getusermedia/resolution/js/test.js b/src/content/getusermedia/resolution/js/test.js index 2484a1301..be1bb4a31 100644 --- a/src/content/getusermedia/resolution/js/test.js +++ b/src/content/getusermedia/resolution/js/test.js @@ -17,8 +17,8 @@ const path = '/src/content/getusermedia/resolution/index.html'; const url = `${process.env.BASEURL ? process.env.BASEURL : ('file://' + process.cwd())}${path}`; describe('getUserMedia resolutions', () => { - beforeAll(() => { - driver = seleniumHelpers.buildDriver(); + beforeAll(async () => { + driver = await seleniumHelpers.buildDriver(); }); afterAll(() => { return driver.quit(); diff --git a/src/content/insertable-streams/endtoend-encryption/js/test.js b/src/content/insertable-streams/endtoend-encryption/js/test.js index 6f17dfb4c..a12556370 100644 --- a/src/content/insertable-streams/endtoend-encryption/js/test.js +++ b/src/content/insertable-streams/endtoend-encryption/js/test.js @@ -16,8 +16,8 @@ const path = '/src/content/insertable-streams/endtoend-encryption/index.html'; const url = `${process.env.BASEURL ? process.env.BASEURL : ('file://' + process.cwd())}${path}`; describe('insertable streams e2ee', () => { - beforeAll(() => { - driver = seleniumHelpers.buildDriver(); + beforeAll(async () => { + driver = await seleniumHelpers.buildDriver(); }); afterAll(() => { return driver.quit(); diff --git a/src/content/peerconnection/audio/js/test.js b/src/content/peerconnection/audio/js/test.js index 3b88c8420..eef856a7f 100644 --- a/src/content/peerconnection/audio/js/test.js +++ b/src/content/peerconnection/audio/js/test.js @@ -15,8 +15,8 @@ const path = '/src/content/peerconnection/audio/index.html'; const url = `${process.env.BASEURL ? process.env.BASEURL : ('file://' + process.cwd())}${path}`; describe('audio-only peerconnection', () => { - beforeAll(() => { - driver = seleniumHelpers.buildDriver(); + beforeAll(async () => { + driver = await seleniumHelpers.buildDriver(); }); afterAll(() => { return driver.quit(); diff --git a/src/content/peerconnection/change-codecs/js/test.js b/src/content/peerconnection/change-codecs/js/test.js index 7ead6d0b5..35fc84f3e 100644 --- a/src/content/peerconnection/change-codecs/js/test.js +++ b/src/content/peerconnection/change-codecs/js/test.js @@ -16,8 +16,8 @@ const path = '/src/content/peerconnection/change-codecs/index.html'; const url = `${process.env.BASEURL ? process.env.BASEURL : ('file://' + process.cwd())}${path}`; describe('peerconnection with setCodecPreferences', () => { - beforeAll(() => { - driver = seleniumHelpers.buildDriver(); + beforeAll(async () => { + driver = await seleniumHelpers.buildDriver(); }); afterAll(() => { return driver.quit(); diff --git a/src/content/peerconnection/channel/js/test.js b/src/content/peerconnection/channel/js/test.js index 91e1d6160..31cb0e09a 100644 --- a/src/content/peerconnection/channel/js/test.js +++ b/src/content/peerconnection/channel/js/test.js @@ -16,8 +16,8 @@ const path = '/src/content/peerconnection/channel/index.html'; const url = `${process.env.BASEURL ? process.env.BASEURL : ('file://' + process.cwd())}${path}`; describe('peerconnection and broadcast channels', () => { - beforeAll(() => { - driver = seleniumHelpers.buildDriver(); + beforeAll(async () => { + driver = await seleniumHelpers.buildDriver(); }); afterAll(() => { return driver.quit(); diff --git a/src/content/peerconnection/dtmf/js/test.js b/src/content/peerconnection/dtmf/js/test.js index e4028af24..fb0ef29b4 100644 --- a/src/content/peerconnection/dtmf/js/test.js +++ b/src/content/peerconnection/dtmf/js/test.js @@ -17,8 +17,8 @@ const path = '/src/content/peerconnection/dtmf/index.html'; const url = `${process.env.BASEURL ? process.env.BASEURL : ('file://' + process.cwd())}${path}`; describe('peerconnection dtmf', () => { - beforeAll(() => { - driver = seleniumHelpers.buildDriver(); + beforeAll(async () => { + driver = await seleniumHelpers.buildDriver(); }); afterAll(() => { return driver.quit(); diff --git a/src/content/peerconnection/multiple/js/test.js b/src/content/peerconnection/multiple/js/test.js index 8ecc44f3d..5b8fd55aa 100644 --- a/src/content/peerconnection/multiple/js/test.js +++ b/src/content/peerconnection/multiple/js/test.js @@ -16,8 +16,8 @@ const path = '/src/content/peerconnection/multiple/index.html'; const url = `${process.env.BASEURL ? process.env.BASEURL : ('file://' + process.cwd())}${path}`; describe('multiple peerconnections', () => { - beforeAll(() => { - driver = seleniumHelpers.buildDriver(); + beforeAll(async () => { + driver = await seleniumHelpers.buildDriver(); }); afterAll(() => { return driver.quit(); diff --git a/src/content/peerconnection/munge-sdp/js/test.js b/src/content/peerconnection/munge-sdp/js/test.js index 8b145b80c..109d4c58e 100644 --- a/src/content/peerconnection/munge-sdp/js/test.js +++ b/src/content/peerconnection/munge-sdp/js/test.js @@ -16,8 +16,8 @@ const path = '/src/content/peerconnection/munge-sdp/index.html'; const url = `${process.env.BASEURL ? process.env.BASEURL : ('file://' + process.cwd())}${path}`; describe('peerconnection sdp munging', () => { - beforeAll(() => { - driver = seleniumHelpers.buildDriver(); + beforeAll(async () => { + driver = await seleniumHelpers.buildDriver(); }); afterAll(() => { return driver.quit(); diff --git a/src/content/peerconnection/negotiate-timing/js/test.js b/src/content/peerconnection/negotiate-timing/js/test.js index 0c9f5ef6a..1bcc52714 100644 --- a/src/content/peerconnection/negotiate-timing/js/test.js +++ b/src/content/peerconnection/negotiate-timing/js/test.js @@ -16,8 +16,8 @@ const path = '/src/content/peerconnection/negotiate-timing/index.html'; const url = `${process.env.BASEURL ? process.env.BASEURL : ('file://' + process.cwd())}${path}`; describe('peerconnection with negotiation timing', () => { - beforeAll(() => { - driver = seleniumHelpers.buildDriver(); + beforeAll(async () => { + driver = await seleniumHelpers.buildDriver(); }); afterAll(() => { return driver.quit(); diff --git a/src/content/peerconnection/pc1/js/test.js b/src/content/peerconnection/pc1/js/test.js index 15d2ed567..07c72373a 100644 --- a/src/content/peerconnection/pc1/js/test.js +++ b/src/content/peerconnection/pc1/js/test.js @@ -16,8 +16,8 @@ const path = '/src/content/peerconnection/pc1/index.html'; const url = `${process.env.BASEURL ? process.env.BASEURL : ('file://' + process.cwd())}${path}`; describe('simple peerconnection', () => { - beforeAll(() => { - driver = seleniumHelpers.buildDriver(); + beforeAll(async () => { + driver = await seleniumHelpers.buildDriver(); }); afterAll(() => { return driver.quit(); diff --git a/src/content/peerconnection/restart-ice/js/test.js b/src/content/peerconnection/restart-ice/js/test.js index 8ef8671af..b3a7bf3e1 100644 --- a/src/content/peerconnection/restart-ice/js/test.js +++ b/src/content/peerconnection/restart-ice/js/test.js @@ -16,8 +16,8 @@ const path = '/src/content/peerconnection/restart-ice/index.html'; const url = `${process.env.BASEURL ? process.env.BASEURL : ('file://' + process.cwd())}${path}`; describe('peerconnection ice restart', () => { - beforeAll(() => { - driver = seleniumHelpers.buildDriver(); + beforeAll(async () => { + driver = await seleniumHelpers.buildDriver(); }); afterAll(() => { return driver.quit(); diff --git a/src/content/peerconnection/states/js/test.js b/src/content/peerconnection/states/js/test.js index 382e53ff7..354069d54 100644 --- a/src/content/peerconnection/states/js/test.js +++ b/src/content/peerconnection/states/js/test.js @@ -16,8 +16,8 @@ const path = '/src/content/peerconnection/states/index.html'; const url = `${process.env.BASEURL ? process.env.BASEURL : ('file://' + process.cwd())}${path}`; describe('peerconnection states', () => { - beforeAll(() => { - driver = seleniumHelpers.buildDriver(); + beforeAll(async () => { + driver = await seleniumHelpers.buildDriver(); }); afterAll(() => { return driver.quit(); diff --git a/src/content/peerconnection/trickle-ice/js/test.js b/src/content/peerconnection/trickle-ice/js/test.js index 6a39c3bdf..3539b9764 100644 --- a/src/content/peerconnection/trickle-ice/js/test.js +++ b/src/content/peerconnection/trickle-ice/js/test.js @@ -16,8 +16,8 @@ const path = '/src/content/peerconnection/trickle-ice/index.html'; const url = `${process.env.BASEURL ? process.env.BASEURL : ('file://' + process.cwd())}${path}`; describe('Trickle-Ice', () => { - beforeAll(() => { - driver = seleniumHelpers.buildDriver(); + beforeAll(async () => { + driver = await seleniumHelpers.buildDriver(); }); afterAll(() => { return driver.quit(); diff --git a/src/content/peerconnection/upgrade/js/test.js b/src/content/peerconnection/upgrade/js/test.js index 31e7744a0..de0e7324f 100644 --- a/src/content/peerconnection/upgrade/js/test.js +++ b/src/content/peerconnection/upgrade/js/test.js @@ -16,8 +16,8 @@ const path = '/src/content/peerconnection/upgrade/index.html'; const url = `${process.env.BASEURL ? process.env.BASEURL : ('file://' + process.cwd())}${path}`; describe('peerconnection upgrade from audio-only to audio-video', () => { - beforeAll(() => { - driver = seleniumHelpers.buildDriver(); + beforeAll(async () => { + driver = await seleniumHelpers.buildDriver(); }); afterAll(() => { return driver.quit(); diff --git a/test/interop/connection.test.js b/test/interop/connection.test.js index 8cec7a5d8..da0a434e9 100644 --- a/test/interop/connection.test.js +++ b/test/interop/connection.test.js @@ -21,8 +21,8 @@ describe(`basic interop test ${browserA} => ${browserB}`, function() { browserLogging: true, } drivers = [ - buildDriver(browserA, options), - buildDriver(browserB, options), + await buildDriver(browserA, options), + await buildDriver(browserB, options), ]; clients = drivers.map(driver => { return { diff --git a/test/webdriver.js b/test/webdriver.js index 7cda410fb..6ae301552 100644 --- a/test/webdriver.js +++ b/test/webdriver.js @@ -6,20 +6,47 @@ * tree. */ const os = require('os'); +const path = require('path'); const webdriver = require('selenium-webdriver'); const chrome = require('selenium-webdriver/chrome'); const firefox = require('selenium-webdriver/firefox'); const safari = require('selenium-webdriver/safari'); +const puppeteerBrowsers = require('@puppeteer/browsers'); + +async function download(browser, version, cacheDir, platform) { + const buildId = await puppeteerBrowsers + .resolveBuildId(browser, platform, version); + await puppeteerBrowsers.install({ + browser, + buildId, + cacheDir, + platform + }); + return buildId; +} +const cacheDir = path.join(process.cwd(), 'browsers'); + if (os.platform() === 'win32') { process.env.PATH += ';' + process.cwd() + '\\node_modules\\chromedriver\\lib\\chromedriver\\'; process.env.PATH += ';' + process.cwd() + '\\node_modules\\geckodriver'; } else { - process.env.PATH += ':node_modules/.bin'; + process.env.PATH = path.join(process.env.PATH, 'node_modules', '.bin'); } -function buildDriver(browser = process.env.BROWSER || 'chrome', options = {version: process.env.BVER}) { +async function buildDriver(browser = process.env.BROWSER || 'chrome', options = {version: process.env.BVER}) { + const platform = puppeteerBrowsers.detectBrowserPlatform(); + + const buildId = await download(browser, options.version || 'stable', + cacheDir, platform); + if (browser === 'chrome') { + process.env.CHROME_BIN = puppeteerBrowsers + .computeExecutablePath({browser, buildId, cacheDir, platform}); + } else if (browser === 'firefox') { + process.env.FIREFOX_BIN = puppeteerBrowsers + .computeExecutablePath({browser, buildId, cacheDir, platform}); + } // Chrome options. const chromeOptions = new chrome.Options() .addArguments('allow-insecure-localhost') @@ -28,11 +55,8 @@ function buildDriver(browser = process.env.BROWSER || 'chrome', options = {versi if (options.chromeFlags) { options.chromeFlags.forEach((flag) => chromeOptions.addArguments(flag)); } - if (options.chromepath) { chromeOptions.setChromeBinaryPath(options.chromepath); - } else if (os.platform() === 'linux' && options.version) { - chromeOptions.setChromeBinaryPath('browsers/bin/chrome-' + options.version); } if (!options.devices || options.headless) { @@ -65,6 +89,7 @@ function buildDriver(browser = process.env.BROWSER || 'chrome', options = {versi }); } + // Safari options. const safariOptions = new safari.Options(); safariOptions.setTechnologyPreview(options.version === 'unstable'); @@ -73,8 +98,6 @@ function buildDriver(browser = process.env.BROWSER || 'chrome', options = {versi let firefoxPath = firefox.Channel.RELEASE; if (options.firefoxpath) { firefoxPath = options.firefoxpath; - } else if (os.platform() == 'linux' && options.version) { - firefoxPath = 'browsers/bin/firefox-' + options.version; } if (options.headless) { firefoxOptions.addArguments('-headless');