123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101 |
- 'use strict';
- var test = require('tape');
- var webdriver = require('selenium-webdriver');
- var chrome = require('selenium-webdriver/chrome');
- var firefox = require('selenium-webdriver/firefox');
- function buildDriver(browser) {
-
-
- var profile = new firefox.Profile();
- profile.setPreference('media.navigator.streams.fake', true);
- var firefoxOptions = new firefox.Options()
- .setProfile(profile);
-
-
- var chromeOptions = new chrome.Options()
-
- .addArguments('allow-file-access-from-files')
- .addArguments('use-fake-device-for-media-stream')
- .addArguments('use-fake-ui-for-media-stream');
-
- return new webdriver.Builder()
- .forBrowser(browser || process.env.BROWSER || 'firefox')
- .setFirefoxOptions(firefoxOptions)
- .setChromeOptions(chromeOptions)
- .build();
- }
- function doJoin(driver, room) {
- return driver.get('file://' + process.cwd() + '/index.html?' + room);
- }
- function test3(browserA, browserB, browserC, t) {
- var room = 'testing_' + Math.floor(Math.random() * 100000);
- var userA = buildDriver(browserA);
- doJoin(userA, room);
- var userB = buildDriver(browserB);
- doJoin(userB, room);
- var userC = buildDriver(browserC);
- doJoin(userC, room);
- userA.wait(function () {
- return userA.executeScript('return (function() {' +
- 'var connected = 0;' +
- 'webrtc.getPeers().forEach(function (peer) {' +
- ' if (peer.pc.iceConnectionState === \'connected\' || peer.pc.iceConnectionState === \'completed\') connected++;' +
- '});' +
- 'return connected === 2;' +
- '})()');
- }, 15 * 1000)
- .then(function () {
-
- })
- .then(function () {
- t.pass('Mesh connected');
- userA.quit();
- userB.quit();
- userC.quit().then(function () {
- t.end();
- });
- })
- .then(null, function (err) {
- t.fail('Mesh failed');
- userA.quit();
- userB.quit();
- userC.quit().then(function () {
- t.end();
- });
- });
- }
- test('Mesh, Chrome-Chrome-Chrome', function (t) {
- test3('chrome', 'chrome', 'chrome', t);
- });
- test('Mesh, Chrome-Firefox-Firefox', function (t) {
- test3('chrome', 'firefox', 'firefox', t);
- });
- test('Mesh, Firefox-Firefox-Chrome', function (t) {
- test3('firefox', 'firefox', 'chrome', t);
- });
- test('Mesh, Chrome-Chrome-Firefox', function (t) {
- test3('chrome', 'chrome', 'chrome', t);
- });
- test('Mesh, Firefox-Firefox-Firefox', function (t) {
- test3('firefox', 'firefox', 'firefox', t);
- });
|