|
91 | 91 | updateLockButton(lockButton);
|
92 | 92 | }
|
93 | 93 |
|
| 94 | + async function unlock() { |
| 95 | + await screen.orientation.unlock(); |
| 96 | + updateLockButton(); |
| 97 | + } |
| 98 | + |
94 | 99 | screen.orientation.addEventListener("change", updateLockButton);
|
95 | 100 |
|
96 | 101 | window.addEventListener("load", updateLockButton);
|
|
99 | 104 | <button onclick="rotate(this)" id="button">
|
100 | 105 | Lock to...
|
101 | 106 | </button>
|
102 |
| - <button onclick="screen.orientation.unlock()"> |
| 107 | + <button onclick="unlock()"> |
103 | 108 | Unlock
|
104 | 109 | </button>
|
105 | 110 | </pre>
|
|
392 | 397 | [Exposed=Window]
|
393 | 398 | interface ScreenOrientation : EventTarget {
|
394 | 399 | Promise<undefined> lock(OrientationLockType orientation);
|
395 |
| - undefined unlock(); |
| 400 | + Promise<undefined> unlock(); |
396 | 401 | readonly attribute OrientationType type;
|
397 | 402 | readonly attribute unsigned short angle;
|
398 | 403 | attribute EventHandler onchange;
|
@@ -503,30 +508,29 @@ <h2>
|
503 | 508 | <li>Let |document:Document| be [=this=]'s [=relevant global
|
504 | 509 | object=]'s [=associated `Document`=].
|
505 | 510 | </li>
|
506 |
| - <li>If |document| is not [=Document/fully active=], |
507 |
| - [=exception/throw=] an {{"InvalidStateError"}} {{DOMException}}. |
| 511 | + <li data-tests="non-fully-active.html">If |document| is not |
| 512 | + [=Document/fully active=], return [=a promise rejected with=] an |
| 513 | + {{"InvalidStateError"}} {{DOMException}}. |
508 | 514 | </li>
|
509 |
| - <li data-tests="lock-sandboxed-iframe.html">If |document| has the |
510 |
| - [=sandboxed orientation lock browsing context flag=] set, return |
511 |
| - `undefined`. |
| 515 | + <li>If |document| has the [=sandboxed orientation lock browsing |
| 516 | + context flag=] set, return [=a promise resolved with=] `undefined`. |
512 | 517 | </li>
|
513 | 518 | <li>If screen's [=Screen/active orientation lock=] is `null`, return
|
514 |
| - `undefined`. |
| 519 | + return [=a promise resolved with=] `undefined`. |
| 520 | + </li> |
| 521 | + <li data-tests="lock-basic.html">If |document|'s |
| 522 | + {{Document/[[orientationPendingPromise]]}} is not `null`, [=reject |
| 523 | + and nullify the current lock promise=] of |document| with an |
| 524 | + {{"AbortError"}}. |
515 | 525 | </li>
|
516 |
| - <li>If |document|'s {{Document/[[orientationPendingPromise]]}} is not |
517 |
| - `null`, [=reject and nullify the current lock promise=] of |document| |
518 |
| - with an {{"AbortError"}}. |
| 526 | + <li data-tests="lock-basic.html">Set |document|'s |
| 527 | + {{Document/[[orientationPendingPromise]]}} to [=a new promise=]. |
519 | 528 | </li>
|
520 | 529 | <li>[=Apply orientation lock=] `null` to |document|.
|
521 | 530 | </li>
|
| 531 | + <li>Return |document|'s {{Document/[[orientationPendingPromise]]}}. |
| 532 | + </li> |
522 | 533 | </ol>
|
523 |
| - <p class='note' title="Why does unlock() not return a promise?"> |
524 |
| - {{unlock()}} does not return a promise because it is equivalent to |
525 |
| - locking to the [=default screen orientation=] which might or might |
526 |
| - not be known by the [=user agent=]. Hence, the [=user agent=] can not |
527 |
| - predict what the new orientation is going to be and even if it is |
528 |
| - going to change at all. |
529 |
| - </p> |
530 | 534 | </section>
|
531 | 535 | <section>
|
532 | 536 | <h2>
|
|
0 commit comments