Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Fix clicking labels for delegatesFocus form associated custom elements
I don't really think this behavior is well specced, but I think this behavior makes sense and it's the same as Firefox. Safari doesn't support form-associated custom elements yet. Fixed: 1300587 Change-Id: Ica4c91c7178c6c4800c3925745d1705d09e30e16 Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/3501331 Reviewed-by: Mason Freed <masonf@chromium.org> Commit-Queue: Joey Arhar <jarhar@chromium.org> Cr-Commit-Position: refs/heads/main@{#983491}
- Loading branch information
1 parent
7705d2a
commit 62daabb
Showing
2 changed files
with
49 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
38 changes: 38 additions & 0 deletions
38
...ty/blink/web_tests/external/wpt/custom-elements/form-associated/label-delegatesFocus.html
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,38 @@ | ||
<!DOCTYPE html> | ||
<link rel=author href="mailto:jarhar@chromium.org"> | ||
<link rel=help href="https://bugs.chromium.org/p/chromium/issues/detail?id=1300587"> | ||
<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> | ||
|
||
<form> | ||
<label for=custom>label</label> | ||
<my-custom-element id=custom></my-custom-element> | ||
</form> | ||
|
||
<script> | ||
class MyCustomElement extends HTMLElement { | ||
static formAssociated = true; | ||
constructor() { | ||
super(); | ||
const root = this.attachShadow({ | ||
delegatesFocus: true, | ||
mode: 'open' | ||
}); | ||
root.appendChild(document.createElement('input')); | ||
} | ||
}; | ||
customElements.define('my-custom-element', MyCustomElement); | ||
|
||
window.onload = () => { | ||
promise_test(async () => { | ||
const label = document.querySelector('label'); | ||
const customElement = document.querySelector('my-custom-element'); | ||
const input = customElement.shadowRoot.querySelector('input'); | ||
await test_driver.click(label); | ||
assert_equals(document.activeElement, customElement); | ||
assert_equals(customElement.shadowRoot.activeElement, input); | ||
}, `Clicking on a label for a form associated custom element with delegatesFocus should focus the custom element's focus delegate.`); | ||
}; | ||
</script> |