gecko/dom/camera/test/test_bug1104913.html

82 lines
2.2 KiB
HTML

<!DOCTYPE HTML>
<html>
<head>
<title>Test for bug 1104913</title>
<script type="text/javascript" src="/MochiKit/MochiKit.js"></script>
<script type="text/javascript" src="/tests/SimpleTest/SimpleTest.js"></script>
<script type="text/javascript" src="camera_common.js"></script>
<link rel="stylesheet" type="text/css" href="/tests/SimpleTest/test.css" />
</head>
<body>
<video id="viewfinder" width="200" height="200" autoplay></video>
<img src="#" alt="This image is going to load" id="testimage"/>
<script class="testbody" type="text/javascript;version=1.7">
var whichCamera = navigator.mozCameras.getListOfCameras()[0];
var config = {
mode: 'picture',
recorderProfile: 'qvga',
pictureSize: {
width: 640,
height: 480
},
previewSize: {
width: 320,
height: 240
}
};
function onError(e) {
ok(false, "Error: " + JSON.stringify(e));
}
var Camera = {
cameraObj: null,
get viewfinder() {
return document.getElementById('viewfinder');
},
start: function test_start() {
function getCamera_onSuccess(d) {
var camera = d.camera;
var cfg = d.configuration;
Camera.cameraObj = camera;
Camera.viewfinder.mozSrcObject = camera;
Camera.viewfinder.play();
// Check the default configuration
ok(cfg.mode === config.mode, "Initial mode = " + cfg.mode);
ok(cfg.previewSize.width === config.previewSize.width &&
cfg.previewSize.height === config.previewSize.height,
"Initial preview size = " + cfg.previewSize.width + "x" + cfg.previewSize.height);
ok(cfg.pictureSize.width === config.pictureSize.width &&
cfg.pictureSize.height === config.pictureSize.height,
"Initial picture size = " + cfg.pictureSize.width + "x" + cfg.pictureSize.height);
ok(cfg.recorderProfile === config.recorderProfile,
"Initial recorder profile = '" + cfg.recorderProfile + "'");
SimpleTest.finish();
}
navigator.mozCameras.getCamera(whichCamera, {}).then(getCamera_onSuccess, onError);
}
}
SimpleTest.waitForExplicitFinish();
window.addEventListener('beforeunload', function() {
Camera.viewfinder.mozSrcObject = null;
if (Camera.cameraObj) {
Camera.cameraObj.release();
Camera.cameraObj = null;
}
});
Camera.start();
</script>
</body>
</html>