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:
@@ -802,15 +802,18 @@ ScreenOrientation::DispatchChangeEventAndResolvePromise() {
|
|||||||
RefPtr<ScreenOrientation> self = this;
|
RefPtr<ScreenOrientation> self = this;
|
||||||
return NS_NewRunnableFunction(
|
return NS_NewRunnableFunction(
|
||||||
"dom::ScreenOrientation::DispatchChangeEvent", [self, doc]() {
|
"dom::ScreenOrientation::DispatchChangeEvent", [self, doc]() {
|
||||||
DebugOnly<nsresult> rv = self->DispatchTrustedEvent(u"change"_ns);
|
RefPtr<Promise> pendingPromise;
|
||||||
NS_WARNING_ASSERTION(NS_SUCCEEDED(rv), "DispatchTrustedEvent failed");
|
|
||||||
if (doc) {
|
if (doc) {
|
||||||
Promise* pendingPromise = doc->GetOrientationPendingPromise();
|
pendingPromise = doc->GetOrientationPendingPromise();
|
||||||
if (pendingPromise) {
|
if (pendingPromise) {
|
||||||
pendingPromise->MaybeResolveWithUndefined();
|
|
||||||
doc->ClearOrientationPendingPromise();
|
doc->ClearOrientationPendingPromise();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
DebugOnly<nsresult> rv = self->DispatchTrustedEvent(u"change"_ns);
|
||||||
|
NS_WARNING_ASSERTION(NS_SUCCEEDED(rv), "DispatchTrustedEvent failed");
|
||||||
|
if (pendingPromise) {
|
||||||
|
pendingPromise->MaybeResolveWithUndefined();
|
||||||
|
}
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -4,9 +4,11 @@
|
|||||||
[Unlocking the screen orientation after a change event must not abort]
|
[Unlocking the screen orientation after a change event must not abort]
|
||||||
expected:
|
expected:
|
||||||
if (os == "mac") and debug: [FAIL, NOTRUN]
|
if (os == "mac") and debug: [FAIL, NOTRUN]
|
||||||
|
if (os == "android"): PASS
|
||||||
FAIL
|
FAIL
|
||||||
|
|
||||||
[Re-locking the screen orientation after a change event fires must not abort]
|
[Re-locking the screen orientation after a change event fires must not abort]
|
||||||
expected:
|
expected:
|
||||||
if (os == "mac") and debug: [FAIL, TIMEOUT]
|
if (os == "mac") and debug: [FAIL, TIMEOUT]
|
||||||
|
if (os == "android"): PASS
|
||||||
FAIL
|
FAIL
|
||||||
|
|||||||
Reference in New Issue
Block a user