From 3edd4fddafaa0e87f450984612657c7d16433ae6 Mon Sep 17 00:00:00 2001 From: Mike Habicher Date: Thu, 12 Jun 2014 14:56:46 -0400 Subject: [PATCH] Bug 1022766 - allow autoFocus() to interrupt earlier calls, r=dhylands --- dom/camera/DOMCameraControl.cpp | 18 ++---- dom/camera/test/mochitest.ini | 1 + dom/camera/test/test_bug1022766.html | 97 ++++++++++++++++++++++++++++ 3 files changed, 104 insertions(+), 12 deletions(-) create mode 100644 dom/camera/test/test_bug1022766.html diff --git a/dom/camera/DOMCameraControl.cpp b/dom/camera/DOMCameraControl.cpp index 26881e030c7..d724894ef76 100644 --- a/dom/camera/DOMCameraControl.cpp +++ b/dom/camera/DOMCameraControl.cpp @@ -788,18 +788,12 @@ nsDOMCameraControl::AutoFocus(CameraAutoFocusCallback& aOnSuccess, { MOZ_ASSERT(mCameraControl); - nsRefPtr 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 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; diff --git a/dom/camera/test/mochitest.ini b/dom/camera/test/mochitest.ini index 166adc818fd..e6947adda37 100644 --- a/dom/camera/test/mochitest.ini +++ b/dom/camera/test/mochitest.ini @@ -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] diff --git a/dom/camera/test/test_bug1022766.html b/dom/camera/test/test_bug1022766.html new file mode 100644 index 00000000000..ff255a343f0 --- /dev/null +++ b/dom/camera/test/test_bug1022766.html @@ -0,0 +1,97 @@ + + + + Test for bug 1022766 + + + + + + + +This image is going to load + + + +