Commit bfd85c71 authored by Francois Beaufort's avatar Francois Beaufort Committed by Commit Bot

getPhotoCapabilities and getPhotoSettings reject with an ended track

This CL makes sure InvalidStateError and OperationError are respectively
thrown when calling getPhotoCapabilitlies & getSettings if the
MediaStreamTrack is ended and stopped while getting photo capabilities
and settings.

Bug: 1134569
Change-Id: Ie318319885b7796b17cb155ffcd2a81d7f98de17
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2445016Reviewed-by: default avatarReilly Grant <reillyg@chromium.org>
Commit-Queue: François Beaufort <beaufort.francois@gmail.com>
Cr-Commit-Position: refs/heads/master@{#813283}
parent 37013fcf
...@@ -181,6 +181,13 @@ ScriptPromise ImageCapture::getPhotoCapabilities(ScriptState* script_state) { ...@@ -181,6 +181,13 @@ ScriptPromise ImageCapture::getPhotoCapabilities(ScriptState* script_state) {
auto* resolver = MakeGarbageCollected<ScriptPromiseResolver>(script_state); auto* resolver = MakeGarbageCollected<ScriptPromiseResolver>(script_state);
ScriptPromise promise = resolver->Promise(); ScriptPromise promise = resolver->Promise();
if (TrackIsInactive(*stream_track_)) {
resolver->Reject(MakeGarbageCollected<DOMException>(
DOMExceptionCode::kInvalidStateError,
"The associated Track is in an invalid state."));
return promise;
}
if (!service_.is_bound()) { if (!service_.is_bound()) {
resolver->Reject(MakeGarbageCollected<DOMException>( resolver->Reject(MakeGarbageCollected<DOMException>(
DOMExceptionCode::kNotFoundError, kNoServiceError)); DOMExceptionCode::kNotFoundError, kNoServiceError));
...@@ -207,6 +214,13 @@ ScriptPromise ImageCapture::getPhotoSettings(ScriptState* script_state) { ...@@ -207,6 +214,13 @@ ScriptPromise ImageCapture::getPhotoSettings(ScriptState* script_state) {
auto* resolver = MakeGarbageCollected<ScriptPromiseResolver>(script_state); auto* resolver = MakeGarbageCollected<ScriptPromiseResolver>(script_state);
ScriptPromise promise = resolver->Promise(); ScriptPromise promise = resolver->Promise();
if (TrackIsInactive(*stream_track_)) {
resolver->Reject(MakeGarbageCollected<DOMException>(
DOMExceptionCode::kInvalidStateError,
"The associated Track is in an invalid state."));
return promise;
}
if (!service_.is_bound()) { if (!service_.is_bound()) {
resolver->Reject(MakeGarbageCollected<DOMException>( resolver->Reject(MakeGarbageCollected<DOMException>(
DOMExceptionCode::kNotFoundError, kNoServiceError)); DOMExceptionCode::kNotFoundError, kNoServiceError));
...@@ -963,6 +977,14 @@ void ImageCapture::OnMojoGetPhotoState( ...@@ -963,6 +977,14 @@ void ImageCapture::OnMojoGetPhotoState(
return; return;
} }
if (TrackIsInactive(*stream_track_)) {
resolver->Reject(MakeGarbageCollected<DOMException>(
DOMExceptionCode::kOperationError,
"The associated Track is in an invalid state."));
service_requests_.erase(resolver);
return;
}
photo_settings_ = PhotoSettings::Create(); photo_settings_ = PhotoSettings::Create();
photo_settings_->setImageHeight(photo_state->height->current); photo_settings_->setImageHeight(photo_state->height->current);
photo_settings_->setImageWidth(photo_state->width->current); photo_settings_->setImageWidth(photo_state->width->current);
......
This is a testharness.js-based test.
PASS exercises ImageCapture.getPhotoCapabilities()
FAIL getPhotoCapabilities() of an ended Track should throw "InvalidStateError" assert_unreached: Should have rejected: undefined Reached unreachable code
FAIL throw "OperationError" when the MediaStreamTrack is stopped while getting photo capabilities assert_unreached: should throw "OperationError" Reached unreachable code
Harness: the test ran to completion.
This is a testharness.js-based test.
PASS exercises ImageCapture.getPhotoSettings()
FAIL getPhotoSettings() of an ended Track should throw "InvalidStateError" assert_unreached: Should have rejected: undefined Reached unreachable code
FAIL throw "OperationError" when the MediaStreamTrack is stopped while getting photo settings assert_unreached: should throw "OperationError" Reached unreachable code
Harness: the test ran to completion.
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment