Truly independent web browser
<!DOCTYPE html>
<script src="../../include.js"></script>
<style id="rules">
.item { color: rgb(20, 24, 28) }
#sentinel { outline-color: rgb(10, 100, 200) }
</style>
<div id="root"></div>
<script>
test(() => {
const sheet = document.getElementById("rules").sheet;
// The first CSSOM edit recompiles shared contents into a private stylesheet. Insert and remove
// a dummy rule first, so the rule edits below are incremental edits.
sheet.insertRule(":not(*) {}", 0);
sheet.deleteRule(0);
const root = document.getElementById("root");
for (let index = 0; index < 100; ++index) {
const item = document.createElement("div");
item.className = "item";
root.appendChild(item);
}
root.lastElementChild.id = "sentinel";
internals.updateStyle();
const rules = document.getElementById("rules").sheet.cssRules;
rules[0].style.setProperty("color", "#14181c");
rules[1].style.setProperty("outline-color", "rgb(200, 100, 10)");
internals.updateStyle();
rules[0].style.setProperty("color", "rgb(20, 24, 28)");
rules[1].style.setProperty("outline-color", "rgb(10, 100, 200)");
internals.updateStyle();
println(`ordinary item: ${getComputedStyle(root.firstElementChild).color}`);
println(`sentinel: ${getComputedStyle(root.lastElementChild).outlineColor}`);
});
</script>