blob: ce28cb6e5ac55e30f1c4b2cc8740c38e63d02806 [file] [log] [blame]
function getUserMedia(permission, constraints, successCallback, errorCallback) {
if (window.testRunner)
testRunner.setUserMediaPermission(permission == "allow");
else {
debug("This test can not be run without the testRunner");
finishJSTest();
return;
}
navigator.mediaDevices
.getUserMedia(constraints)
.then(successCallback, reject)
.catch(defaultRejectOrCatch);
function reject(e) {
if (errorCallback)
errorCallback(e);
else
defaultRejectOrCatch(e);
}
}
function defaultRejectOrCatch(e) {
testFailed('getUserMedia failed:' + e);
finishJSTest();
}
function setupVideoElementWithStream(stream)
{
mediaStream = stream;
testPassed('mediaDevices.getUserMedia generated a stream successfully.');
evalAndLog('video.srcObject = mediaStream');
}