Skip to content

Commit 4e7480c

Browse files
committed
Refactor fullscreen rejection handling to use WebIDL react pattern
This commit modernizes how the Screen Orientation specification responds to fullscreen request rejections by using the WebIDL 'react' concept instead of the previous flag-based approach. Changes: - Replace flag-based 'pending fullscreen request flag unset due to rejection' pattern - Use WebIDL 'react' pattern with 'pending fullscreen request promise' - Update reference to use proper 'pending fullscreen request flag' terminology - Extract duplicated descendant document logic into helper algorithm 'reject descendant document orientation promises' - Add clarifying notes for algorithm logic and same-origin security restrictions - Maintain all existing algorithm behavior while modernizing the specification architecture This enables cleaner, more maintainable specification text that follows modern WebIDL patterns for promise-based APIs and eliminates code duplication. The change complements the fullscreen spec changes in whatwg/fullscreen that add both the exported flag and promise definitions needed for this integration. Fixes #254 Fixes #255
1 parent 245ed44 commit 4e7480c

File tree

1 file changed

+60
-3
lines changed

1 file changed

+60
-3
lines changed

index.html

Lines changed: 60 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -859,19 +859,76 @@ <h2>
859859
<li>[=Apply orientation lock=] `null` to |topDocument|.
860860
</li>
861861
</ol>
862+
<h2>
863+
Rejecting descendant document orientation promises
864+
</h2>
865+
<p>
866+
To <dfn>reject descendant document orientation promises</dfn> for a {{Document}} |document|, the [=user agent=] MUST:
867+
</p>
868+
<ol class="algorithm">
869+
<li>If |document| is not a [=top-level browsing context=]'s [=navigable/active document=], abort these steps.
870+
871+
<p class="note">Only top-level documents have descendant navigables to process.</p></li>
872+
<li>Let |descendantDocs| be an [=ordered set=] consisting of |document|'s
873+
[=Document/descendant navigables=]'s [=navigable/active documents=], if any, in tree order.</li>
874+
<li>[=Set/For each=] |descendantDoc:Document| in |descendantDocs|:
875+
<ol>
876+
<li>If |descendantDoc| is not [=same origin=] with |document|, continue.
877+
878+
<p class="note">Only same-origin descendant documents are processed to prevent cross-origin documents from detecting orientation lock states of their embedding documents, which could be used for timing attacks or fingerprinting.</p></li>
879+
<li>If |descendantDoc|'s {{Document/[[orientationPendingPromise]]}} is not `null`,
880+
[=reject and nullify the current lock promise=] of |descendantDoc| with an {{"AbortError"}}.</li>
881+
</ol>
882+
</li>
883+
</ol>
862884
</section>
863885
<section id="fullscreen-interaction">
864886
<h2>
865887
Interaction with Fullscreen API
866888
</h2>
867889
<p>
868890
A user agent SHOULD restrict the use of {{ScreenOrientation/lock()}} to
869-
simple fullscreen documents as a [=pre-lock condition=]. [[fullscreen]]
891+
documents that meet the <dfn>fullscreen pre-lock condition</dfn> as a
892+
[=pre-lock condition=]. [[fullscreen]]
893+
</p>
894+
<p>
895+
A {{Document}} |document| meets the [=fullscreen pre-lock condition=]
896+
if any of the following are true:
897+
</p>
898+
<ol>
899+
<li>|document| has a [=fullscreen element=].
900+
</li>
901+
<li>|document| has its [=pending fullscreen request flag=] set.
902+
</li>
903+
<li>|document| is [=same origin=] with its [=top-level browsing
904+
context=]'s [=navigable/active document=], and that [=top-level
905+
browsing context=]'s [=navigable/active document=] meets one of the
906+
above conditions.
907+
</li>
908+
</ol>
909+
<p class="note">
910+
The third condition allows same-origin iframes to lock the screen
911+
orientation when their parent document is in fullscreen or has
912+
requested fullscreen. This prevents cross-origin documents from
913+
detecting the fullscreen state of their embedding document.
914+
</p>
915+
<p>
916+
When a [=document=] |doc| exits fullscreen, the user agent MUST:
870917
</p>
918+
<ol class="algorithm">
919+
<li>Run the [=fully unlock the screen orientation steps=] with |doc|.</li>
920+
<li>[=Reject descendant document orientation promises=] for |doc|.</li>
921+
</ol>
871922
<p>
872-
When a [=document=] exits fullscreen, it also runs the [=fully unlock
873-
the screen orientation steps=]. [[fullscreen]]
923+
[=React=] to a [=document=] |doc|'s [=pending fullscreen request
924+
promise=]. When the promise is [=reject|rejected=], run the following
925+
steps:
874926
</p>
927+
<ol class="algorithm">
928+
<li>If |doc|'s {{Document/[[orientationPendingPromise]]}} is not `null`,
929+
[=reject and nullify the current lock promise=] of |doc| with an {{"AbortError"}}.</li>
930+
<li>[=Reject descendant document orientation promises=] for |doc|.</li>
931+
</ol>
875932
</section>
876933
<section id="appmanifest-interaction">
877934
<h2>

0 commit comments

Comments
 (0)