Skip to content

Commit f6153c5

Browse files
committed
Merge pull request #160 from webrtc/fixTests
Add browser version check in the webdriver creation step
2 parents 591b93f + 429ee1b commit f6153c5

File tree

3 files changed

+36
-3
lines changed

3 files changed

+36
-3
lines changed

adapter.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright (c) 2014 The WebRTC project authors. All Rights Reserved.
2+
* Copyright (c) 2015 The WebRTC project authors. All Rights Reserved.
33
*
44
* Use of this source code is governed by a BSD-style license
55
* that can be found in the LICENSE file in the root of the source

test/selenium-lib.js

Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,9 +13,37 @@
1313
var webdriver = require('selenium-webdriver');
1414
var chrome = require('selenium-webdriver/chrome');
1515
var firefox = require('selenium-webdriver/firefox');
16+
var fs = require('fs');
1617

1718
var sharedDriver = null;
1819

20+
function getBrowserVersion() {
21+
var browser = process.env.BROWSER;
22+
var browserChannel = process.env.BVER;
23+
var symlink = './browsers/bin/' + browser + '-' + browserChannel + '/';
24+
var path = fs.readlink(symlink);
25+
26+
// Browser reg expressions and position to look for the milestone version.
27+
var chromeExp = '/Chrom(e|ium)\/([0-9]+)\./';
28+
var firefoxExp = '/Firefox\/([0-9]+)\./';
29+
var chromePos = 2;
30+
var firefoxPos = 1;
31+
32+
var browserVersion = function(path, expr, pos) {
33+
var match = path.match(expr);
34+
return match && match.length >= pos && parseInt(match[pos], 10);
35+
};
36+
37+
switch (browser) {
38+
case 'chrome':
39+
return browserVersion(path, chromeExp, chromePos);
40+
case 'firefox':
41+
return browserVersion(path, firefoxExp, firefoxPos);
42+
default:
43+
return 'non supported browser.';
44+
}
45+
}
46+
1947
function buildDriver() {
2048
if (sharedDriver) {
2149
return sharedDriver;
@@ -45,6 +73,11 @@ function buildDriver() {
4573
.addArguments('use-fake-device-for-media-stream')
4674
.addArguments('use-fake-ui-for-media-stream');
4775

76+
// Only enable this for Chrome >= 49.
77+
if (process.env.BROWSER === 'chrome' && getBrowserVersion >= '49') {
78+
chromeOptions.addArguments('--enable-experimental-web-platform-features');
79+
}
80+
4881
sharedDriver = new webdriver.Builder()
4982
.forBrowser(process.env.BROWSER)
5083
.setFirefoxOptions(firefoxOptions)

test/test.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -384,7 +384,7 @@ test('attachMediaStream', function(t) {
384384
webdriver.By.id('video')), 3000);
385385
})
386386
.then(function(videoElement) {
387-
t.pass('attachMediaStream succesfully attached stream to video element');
387+
t.pass('attachMediaStream successfully attached stream to video element');
388388
videoElement.getAttribute('videoWidth')
389389
.then(function(width) {
390390
videoElement.getAttribute('videoHeight')
@@ -471,7 +471,7 @@ test('reattachMediaStream', function(t) {
471471
webdriver.By.id('video')), 3000);
472472
})
473473
.then(function(videoElement) {
474-
t.pass('attachMediaStream succesfully attached stream to video element');
474+
t.pass('attachMediaStream successfully attached stream to video element');
475475
videoElement.getAttribute('videoWidth')
476476
.then(function(width) {
477477
videoElement.getAttribute('videoHeight')

0 commit comments

Comments
 (0)