mirror of
https://gitlab.winehq.org/wine/wine-gecko.git
synced 2024-09-13 09:24:08 -07:00
Bug 1022766 - allow autoFocus() to interrupt earlier calls, r=dhylands
This commit is contained in:
parent
be89066c92
commit
3edd4fddaf
@ -788,18 +788,12 @@ nsDOMCameraControl::AutoFocus(CameraAutoFocusCallback& aOnSuccess,
|
||||
{
|
||||
MOZ_ASSERT(mCameraControl);
|
||||
|
||||
nsRefPtr<CameraAutoFocusCallback> cb = mAutoFocusOnSuccessCb;
|
||||
if (cb) {
|
||||
if (aOnError.WasPassed()) {
|
||||
// There is already a call to AutoFocus() in progress, abort this new one
|
||||
// and invoke the error callback (if one was passed in).
|
||||
NS_DispatchToMainThread(new ImmediateErrorCallback(&aOnError.Value(),
|
||||
NS_LITERAL_STRING("AutoFocusAlreadyInProgress")));
|
||||
} else {
|
||||
// Only throw if no error callback was passed in.
|
||||
aRv = NS_ERROR_FAILURE;
|
||||
}
|
||||
return;
|
||||
nsRefPtr<CameraErrorCallback> ecb = mAutoFocusOnErrorCb.forget();
|
||||
if (ecb) {
|
||||
// There is already a call to AutoFocus() in progress, cancel it and
|
||||
// invoke the error callback (if one was passed in).
|
||||
NS_DispatchToMainThread(new ImmediateErrorCallback(ecb,
|
||||
NS_LITERAL_STRING("AutoFocusInterrupted")));
|
||||
}
|
||||
|
||||
mAutoFocusOnSuccessCb = &aOnSuccess;
|
||||
|
@ -10,3 +10,4 @@ support-files = camera_common.js
|
||||
[test_camera_fake_parameters.html]
|
||||
[test_camera_hardware_face_detection.html]
|
||||
[test_camera_hardware_auto_focus_moving_cb.html]
|
||||
[test_bug1022766.html]
|
||||
|
97
dom/camera/test/test_bug1022766.html
Normal file
97
dom/camera/test/test_bug1022766.html
Normal file
@ -0,0 +1,97 @@
|
||||
<!DOCTYPE HTML>
|
||||
<html>
|
||||
<head>
|
||||
<title>Test for bug 1022766</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: 'cif',
|
||||
previewSize: {
|
||||
width: 352,
|
||||
height: 288
|
||||
}
|
||||
};
|
||||
|
||||
function onError(e) {
|
||||
ok(false, "Error" + JSON.stringify(e));
|
||||
}
|
||||
|
||||
var Camera = {
|
||||
cameraObj: null,
|
||||
_otherPictureSize: null,
|
||||
get viewfinder() {
|
||||
return document.getElementById('viewfinder');
|
||||
},
|
||||
|
||||
firstCallFailed: false,
|
||||
secondCallSucceeded: false,
|
||||
checkForDone: function test_checkForDone() {
|
||||
if (Camera.firstCallFailed && Camera.secondCallSucceeded) {
|
||||
Camera.cameraObj.release();
|
||||
Camera.cameraObj = null;
|
||||
CameraTest.end();
|
||||
}
|
||||
},
|
||||
|
||||
successOne: function test_successOne(focused) {
|
||||
ok(false, "First call to autoFocus() succeeded unexpectedly");
|
||||
},
|
||||
failureOne: function test_failureOne(error) {
|
||||
ok(error == "AutoFocusInterrupted", "First call to autoFocus() failed with: "
|
||||
+ error);
|
||||
Camera.firstCallFailed = true;
|
||||
Camera.checkForDone();
|
||||
},
|
||||
successTwo: function test_successTwo(focused) {
|
||||
ok(true, "Second call to autoFocus() succeeded");
|
||||
Camera.secondCallSucceeded = true;
|
||||
Camera.checkForDone();
|
||||
},
|
||||
failureTwo: function test_failureTwo(error) {
|
||||
ok(false, "Second call to autoFocus() failed unexpectedly with: " + error);
|
||||
},
|
||||
|
||||
start: function test_start() {
|
||||
function onSuccess(camera, config) {
|
||||
Camera.cameraObj = camera;
|
||||
Camera.viewfinder.mozSrcObject = camera;
|
||||
Camera.viewfinder.play();
|
||||
|
||||
// It doesn't matter if the emulator supports focus or not;
|
||||
// this is just testing the sequencing.
|
||||
camera.autoFocus(Camera.successOne, Camera.failureOne);
|
||||
camera.autoFocus(Camera.successTwo, Camera.failureTwo);
|
||||
};
|
||||
|
||||
navigator.mozCameras.getCamera(whichCamera, config, onSuccess, onError);
|
||||
}
|
||||
}
|
||||
|
||||
window.addEventListener('beforeunload', function() {
|
||||
Camera.viewfinder.mozSrcObject = null;
|
||||
if (Camera.cameraObj) {
|
||||
Camera.cameraObj.release();
|
||||
Camera.cameraObj = null;
|
||||
}
|
||||
});
|
||||
|
||||
CameraTest.begin("hardware", function(test) {
|
||||
test.set("auto-focus-process-failure", function() {
|
||||
Camera.start();
|
||||
})
|
||||
});
|
||||
|
||||
</script>
|
||||
</body>
|
||||
|
||||
</html>
|
Loading…
Reference in New Issue
Block a user