Skip to content

Commit 7b9ca7d

Browse files
aleventhalchromium-wpt-export-bot
authored andcommitted
Safe slot reassigment
1. Use GetWithoutInvalidation() instead of Get() in DCHECKs. We should never call Get() inside of a DCHECK(), because this can lead to a different code path depending on whether DCHECKs are enabled. 2. Get() should not cause immediate side effects. At most, it should queue up an invalidation for later processing. Fixing #1 and #2 were required in order to get past a first set of errors introduced by the new test. 3. The actual fix -- avoid infinite loop by calling a special new SlotAssignmentWillChange(), rather than ChildrenChanged(), where a minimal GetWithoutInvalidation() is called that does not lead to IsShadowContentRelevantForAccessibility() => FirstChild() => RecalcAssignedNodes() => ChildrenChanged() ... (infinite loop). A simpler potential fix is in CL:2965317 but requires more research. It's also mentioned in a TODO comment. Bug: 1219311 Change-Id: Iafaa289f241a851404ce352715d2970172a2e5f8 Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2961158 Reviewed-by: Joey Arhar <jarhar@chromium.org> Reviewed-by: Mason Freed <masonf@chromium.org> Reviewed-by: Dominic Mazzoni <dmazzoni@chromium.org> Commit-Queue: Aaron Leventhal <aleventhal@chromium.org> Cr-Commit-Position: refs/heads/master@{#892778}
1 parent f93078f commit 7b9ca7d

File tree

1 file changed

+34
-0
lines changed

1 file changed

+34
-0
lines changed
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
<html class="test-wait">
2+
<body>
3+
<script>
4+
customElements.define("my-detail", class extends HTMLElement {
5+
constructor() {
6+
super();
7+
this.attachShadow({ mode: "open", slotAssignment: "manual" });
8+
}
9+
connectedCallback() {
10+
const slot1 = document.createElement("slot");
11+
const child1 = document.createElement("span");
12+
this.appendChild(child1);
13+
child1.innerHTML = "x";
14+
this.shadowRoot.appendChild(slot1);
15+
slot1.style.display = "block";
16+
slot1.assign(child1);
17+
}
18+
});
19+
20+
function fuzz() {
21+
document.designMode = 'on';
22+
document.execCommand("selectAll");
23+
document.execCommand("InsertText");
24+
document.documentElement.className = '';
25+
}
26+
window.onload = () => {
27+
requestAnimationFrame(() => {
28+
requestAnimationFrame(fuzz);
29+
});
30+
};
31+
</script>
32+
<my-detail></my-detail>
33+
</body>
34+
</html>

0 commit comments

Comments
 (0)