Skip to content

Commit 3b48be9

Browse files
committed
First pass at automated multi-browser/device testing. closes videojs#419
I've got a way to run tests across every browser and device out there except for IE8, and IE8 should work except I'm running into a Browserstack bug that I've let them know about. It uses a project called bunyip, which internallt uses Yeti (YUI), Pagekite, and Browserstack. Next steps include: - Making it all automatic. Right now you have to wait for browsers to connect and then manually hit enter when they have. - Make it a grunt task - Document it all so others can use it I think this is close enough for me to close the milestone 4.0 issue.
1 parent 2138d4f commit 3b48be9

File tree

12 files changed

+2271
-1568
lines changed

12 files changed

+2271
-1568
lines changed

.bunyipconfig.js.example

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
/*
2+
Bunyip is a tool for multi-browser/device testing
3+
https://github.com/ryanseddon/bunyip
4+
It uses a few service under the hood including:
5+
Browsertack - http://browserstack.com
6+
Pagekite https://pagekite.net
7+
You'll need accounts at both to use bunyip
8+
You'll also need to download and install pagekite.py
9+
*/
10+
var config = {
11+
"browserstack": {
12+
"username": "[email protected]",
13+
"password": "your browserstack password",
14+
"timeout": 300
15+
},
16+
"port": 9000,
17+
"tunnellink": "your-subdomain.pagekite.me",
18+
"tunnel": "pagekite.py <port> your-subdomain.pagekite.me"
19+
};
20+
21+
module.exports = config;

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@ dev.html
55
projects
66
.zenflow-log
77
test/*.map
8+
.bunyipconfig.js
89

910
node_modules
1011
npm-debug.log

browsers.json

Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,37 @@
1+
[
2+
{
3+
"os": "win",
4+
"browser": "chrome",
5+
"version": "27.0"
6+
},
7+
{
8+
"os": "win",
9+
"browser": "firefox",
10+
"version": "20.0"
11+
},
12+
{
13+
"os": "win",
14+
"browser": "ie",
15+
"version": "9.0"
16+
},
17+
{
18+
"os": "win",
19+
"browser": "ie",
20+
"version": "10.0"
21+
},
22+
{
23+
"os": "ios",
24+
"device": "iPhone 5",
25+
"version": "6.0"
26+
},
27+
{
28+
"os": "ios",
29+
"device": "iPad 3rd (6.0)",
30+
"version": "6.0"
31+
},
32+
{
33+
"os": "android",
34+
"device": "Samsung Galaxy Tab 2 10.1",
35+
"version": "4.0"
36+
}
37+
]

src/js/lib.js

Lines changed: 10 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -275,7 +275,13 @@ vjs.addClass = function(element, classToAdd){
275275
vjs.removeClass = function(element, classToRemove){
276276
if (element.className.indexOf(classToRemove) == -1) { return; }
277277
var classNames = element.className.split(' ');
278-
classNames.splice(classNames.indexOf(classToRemove),1);
278+
// IE8 Does not support array.indexOf so using a for loop
279+
for (var i = classNames.length - 1; i >= 0; i--) {
280+
if (classNames[i] === classToRemove) {
281+
classNames.splice(i,1);
282+
}
283+
}
284+
// classNames.splice(classNames.indexOf(classToRemove),1);
279285
element.className = classNames.join(' ');
280286
};
281287

@@ -368,16 +374,14 @@ vjs.getAttributeValues = function(tag){
368374
* @param {String} strCssRule Style name
369375
* @return {String} Style value
370376
*/
371-
vjs.getComputedStyleValue = function(el, strCssRule){
377+
vjs.getComputedDimension = function(el, strCssRule){
372378
var strValue = '';
373379
if(document.defaultView && document.defaultView.getComputedStyle){
374380
strValue = document.defaultView.getComputedStyle(el, '').getPropertyValue(strCssRule);
375381

376382
} else if(el.currentStyle){
377-
strCssRule = strCssRule.replace(/\-(\w)/g, function (strMatch, p1){
378-
return p1.toUpperCase();
379-
});
380-
strValue = el.currentStyle[strCssRule];
383+
// IE8 Width/Height support
384+
strValue = el['client'+strCssRule.substr(0,1).toUpperCase() + strCssRule.substr(1)] + 'px';
381385
}
382386
return strValue;
383387
};

src/js/player.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -165,7 +165,6 @@ vjs.Player.prototype.createEl = function(){
165165

166166
// Make player findable on elements
167167
tag['player'] = el['player'] = this;
168-
169168
// Default state of video is paused
170169
this.addClass('vjs-paused');
171170

@@ -197,6 +196,7 @@ vjs.Player.prototype.loadTech = function(techName, source){
197196
// So we need to remove it if we're not loading HTML5
198197
} else if (techName !== 'Html5' && this.tag) {
199198
this.el_.removeChild(this.tag);
199+
this.tag.player = null;
200200
this.tag = null;
201201
}
202202

test/index.html

Lines changed: 25 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@
1818
(function(){
1919

2020
// ADD NEW TEST FILES HERE
21-
var tests = [
21+
window.tests = [
2222
'test/unit/core-object.js',
2323
'test/unit/lib.js',
2424
'test/unit/events.js',
@@ -30,22 +30,30 @@
3030
'test/unit/controls.js',
3131
'test/unit/plugins.js'
3232
];
33-
var compiledTests = "build/files/test.minified.video.js";
3433

3534
var projectRoot = '../';
3635
var scripts = [];
3736

37+
window.loadScripts = function(scripts) {
38+
for (var i = 0; i < scripts.length; i++) {
39+
document.write("<script src='" + projectRoot + scripts[i] + "'><\/script>" );
40+
}
41+
}
42+
3843
// Choose either the raw source and tests
3944
// Or the compiled source + tests.
4045
// Use ?comiled to use the compiled tests
4146
if (QUnit.urlParams.min || QUnit.urlParams.compiled) {
42-
scripts.push(compiledTests);
47+
window.compiled = true;
4348
} else {
44-
scripts = scripts.concat(['build/source-loader.js'], tests);
45-
}
49+
// Bunyip/Yeti starts tests after it's done loading which can
50+
// lead to a double Qunit.start error which reads as
51+
// "Uncaught Error: pushFailure() assertion outside test"
52+
if (window.$yetify) {
53+
QUnit.config.autostart = false;
54+
}
4655

47-
for (var i = 0; i < scripts.length; i++) {
48-
document.write( "<script src='" + projectRoot + scripts[i] + "'><\/script>" );
56+
loadScripts(['build/source-loader.js']);
4957
}
5058

5159
})()
@@ -60,5 +68,15 @@ <h2 id="qunit-userAgent"></h2>
6068
<ol id="qunit-tests"></ol>
6169
<div id="qunit-fixture"></div>
6270
</div>
71+
72+
<script>
73+
// Loading tests before the end to give IE time to load vjs before tests
74+
if (!window.compiled) {
75+
loadScripts(window.tests);
76+
} else {
77+
var compiledTests = "build/files/test.minified.video.js";
78+
loadScripts([compiledTests]);
79+
}
80+
</script>
6381
</body>
6482
</html>

0 commit comments

Comments
 (0)