forked from muaz-khan/DetectRTC
-
Notifications
You must be signed in to change notification settings - Fork 0
/
DetectRTC.js
56 lines (48 loc) · 2.43 KB
/
DetectRTC.js
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
describe('DetectRTC', function() {
it('DetectRTC compiled using grunt', function() {
console.log('------------------------------');
console.log('\x1b[31m%s\x1b[0m ', 'DetectRTC.js');
browser.driver.get('https://webrtcweb.com/DetectRTC/DetectRTC.html').then(function() {
var booleans = {};
var failed = {};
['hasWebcam', 'hasMicrophone', 'hasSpeakers', 'isApplyConstraintsSupported',
'isAudioContextSupported', 'isCanvasSupportsStreamCapturing',
'isCreateMediaStreamSourceSupported', 'isGetUserMediaSupported',
'isMobileDevice', 'isMultiMonitorScreenCapturingSupported', 'isORTCSupported',
'isPromisesSupported', 'isRTPSenderReplaceTracksSupported', 'isRemoteStreamProcessingSupported',
'isRtpDataChannelsSupported', 'isScreenCapturingSupported', 'isSctpDataChannelsSupported',
'isSetSinkIdSupported', 'isVideoSupportsStreamCapturing', 'isWebRTCSupported',
'isWebSocketsBlocked', 'isWebSocketsSupported', 'isWebsiteHasMicrophonePermissions', 'isWebsiteHasWebcamPermissions'
].forEach(function(prop) {
browser.driver.findElement(by.id(prop)).getText().then(function(value) {
if (!value.toString().length) {
failed[prop] = true;
return;
}
if (typeof value !== 'boolean') {
if (value === 'true') {
value = true;
} else if (value === 'false') {
value = false;
} else {
value = value;
}
}
booleans[prop] = value;
});
});
browser.wait(function() {
Object.keys(booleans).forEach(function(key) {
console.log(key + ': ' + booleans[key]);
});
if (Object.keys(failed).length) {
Object.keys(failed).forEach(function(key) {
console.error(key + ': test failed.');
});
throw new Error(Object.keys(failed).length + ' tests failed.');
}
return true;
}, 1000, 'DetectRTC did not return valid information.');
});
});
});