Bug 1925188 - Don't abort pending promise by screen.orientation.lock during change event. r=dom-core,edgar

We should clear pending orientation lock promise in document before change
event is dispatched. After that, we should resolve this promise.

Differential Revision: https://phabricator.services.mozilla.com/D225945
This commit is contained in:
Makoto Kato 2024-10-21 01:20:32 +00:00
parent 83916cbffc
commit 355f5977be
2 changed files with 9 additions and 4 deletions

View File

@ -802,15 +802,18 @@ ScreenOrientation::DispatchChangeEventAndResolvePromise() {
RefPtr<ScreenOrientation> self = this;
return NS_NewRunnableFunction(
"dom::ScreenOrientation::DispatchChangeEvent", [self, doc]() {
DebugOnly<nsresult> rv = self->DispatchTrustedEvent(u"change"_ns);
NS_WARNING_ASSERTION(NS_SUCCEEDED(rv), "DispatchTrustedEvent failed");
RefPtr<Promise> pendingPromise;
if (doc) {
Promise* pendingPromise = doc->GetOrientationPendingPromise();
pendingPromise = doc->GetOrientationPendingPromise();
if (pendingPromise) {
pendingPromise->MaybeResolveWithUndefined();
doc->ClearOrientationPendingPromise();
}
}
DebugOnly<nsresult> rv = self->DispatchTrustedEvent(u"change"_ns);
NS_WARNING_ASSERTION(NS_SUCCEEDED(rv), "DispatchTrustedEvent failed");
if (pendingPromise) {
pendingPromise->MaybeResolveWithUndefined();
}
});
}

View File

@ -4,9 +4,11 @@
[Unlocking the screen orientation after a change event must not abort]
expected:
if (os == "mac") and debug: [FAIL, NOTRUN]
if (os == "android"): PASS
FAIL
[Re-locking the screen orientation after a change event fires must not abort]
expected:
if (os == "mac") and debug: [FAIL, TIMEOUT]
if (os == "android"): PASS
FAIL