Skip to content

Commit

Permalink
Implement setSequentialFocusStartingPoint
Browse files Browse the repository at this point in the history
This is proposed here: whatwg/html#5326

Change-Id: I2c0c0ac578180ce5e1cf327fb65c6450a7d49f60
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/4866726
Reviewed-by: Di Zhang <dizhangg@chromium.org>
Commit-Queue: Joey Arhar <jarhar@chromium.org>
Cr-Commit-Position: refs/heads/main@{#1197956}
  • Loading branch information
josepharhar authored and Chromium LUCI CQ committed Sep 18, 2023
1 parent 1ddf0a5 commit c098515
Show file tree
Hide file tree
Showing 4 changed files with 36 additions and 0 deletions.
4 changes: 4 additions & 0 deletions third_party/blink/renderer/core/dom/document.idl
Original file line number Diff line number Diff line change
Expand Up @@ -219,6 +219,10 @@ typedef (HTMLScriptElement or SVGScriptElement) HTMLOrSVGScriptElement;
attribute EventHandler onresume;
attribute EventHandler onsearch;
attribute EventHandler onvisibilitychange;

// Proposed setter for focus navigation starting point
// https://github.com/whatwg/html/issues/5326
[RuntimeEnabled=SetSequentialFocusStartingPoint, ImplementedAs=SetSequentialFocusNavigationStartingPoint] void setSequentialFocusStartingPoint(Element element);
};

Document includes GlobalEventHandlers;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3361,6 +3361,10 @@
origin_trial_feature_name: "ServiceWorkerStaticRouter",
public: true,
},
{
name: "SetSequentialFocusStartingPoint",
status: "experimental",
},
{
name: "SharedArrayBuffer",
base_feature: "none",
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
<!DOCTYPE html>
<link rel=author href="mailto:jarhar@chromium.org">
<link rel=help href="https://github.com/whatwg/html/issues/5326">
<script src="/resources/testharness.js"></script>
<script src="/resources/testharnessreport.js"></script>
<script src="/resources/testdriver.js"></script>
<script src="/resources/testdriver-vendor.js"></script>

<button id=b1>b1</button>
<div id=d1>d1</div>
<button id=b2>b2</button>

<script>
const tabKey = '\uE004';
promise_test(async () => {
assert_equals(document.activeElement, document.body,
'Focus should initially be set on the body element.');

document.setSequentialFocusStartingPoint(d1);
assert_equals(document.activeElement, document.body,
'Calling setSequentialFocusStartingPoint should not change the focused element.');

await test_driver.send_keys(document.activeElement, tabKey);
assert_equals(document.activeElement, b2,
'Pressing tab should focus the next button after the sequential focus starting point.');
}, 'document.setSequentialFocusStartingPoint should set the sequential focus starting point on any element.');
</script>
Original file line number Diff line number Diff line change
Expand Up @@ -2040,6 +2040,7 @@ interface Document : Node
method replaceChildren
method requestStorageAccess
method requestStorageAccessFor
method setSequentialFocusStartingPoint
method startViewTransition
method webkitCancelFullScreen
method webkitExitFullscreen
Expand Down

0 comments on commit c098515

Please sign in to comment.