[w3c/screen-orientation] Clarify the order of promise resolution and change event dispatch. (Issue #291)

EdgarChen created an issue (w3c/screen-orientation#291)

Per #120, #173 and also [the note in section 8.3](https://w3c.github.io/screen-orientation/#:~:text=As%20the%20promise%20needs%20to%20resolve%20after%20a%20%22change%22%20event%20is%20fired%2C%20we%20keep%20a%20reference%20to%20prevent%20it%20from%20being%20aborted%20by%20an%20event%27s%20handler%20function%20calling%20lock%28%29%2E):

> As the promise needs to resolve after a "[change](https://w3c.github.io/screen-orientation/#dfn-change)" event is fired, we keep a reference to prevent it from being aborted by an event's handler function calling [lock](https://w3c.github.io/screen-orientation/#dom-screenorientation-lock)().

the change event is expected to be fired before the promise is resolved.
There are also WTPs that verify this behavior,
- https://github.com/web-platform-tests/wpt/blob/bb262a93ae/screen-orientation/event-before-promise.html
- https://github.com/web-platform-tests/wpt/blob/bb262a93ae/screen-orientation/onchange-event.html

However, according to the current spec steps, the promise is resolved in [step 5.6.4 of section 8.3](https://w3c.github.io/screen-orientation/#:~:text=If%20promise%20is%20not%20null%2C%20resolve%20promise%20with%20undefined%2E), while the `update the screen orientation` [queues a task](https://w3c.github.io/screen-orientation/#dfn-update-the-screen-orientation:~:text=steps%2E-,Queue,screenOrientation%2E) to dispatch the `change` event. As a result, the promise is resolved before the change event is fired if I read the spec correctly.

This issue is filed to clarify which behavior is intended. Thanks!


-- 
Reply to this email directly or view it on GitHub:
https://github.com/w3c/screen-orientation/issues/291
You are receiving this because you are subscribed to this thread.

Message ID: <w3c/screen-orientation/issues/291@github.com>

Received on Tuesday, 24 November 2026 15:25:00 UTC