Truly independent web browser
<!DOCTYPE html>
<script src="../../include.js"></script>
<script src="../../work-test.js"></script>
<div id="container"></div>
<script>
test(() => {
const sheet = new CSSStyleSheet();
document.adoptedStyleSheets = [sheet];
for (let index = 0; index < 64; ++index)
container.appendChild(document.createElement("div"));
const target = container.firstElementChild;
const other = container.lastElementChild;
other.className = "other";
internals.updateStyle();
function mutate(label, mutation) {
const work = styleWork(mutation);
const fullPass = work.passes().includes("FULL") ? " (full pass)" : "";
println(`${label} restyled: [${work.restyled().map(shortStyleName).join(", ")}]${fullPass}`);
println(`${label} target opacity: ${getComputedStyle(target).opacity}`);
println(`${label} other opacity: ${getComputedStyle(other).opacity}`);
}
mutate("insert", () => {
sheet.insertRule(":not(*) { color: red; }");
sheet.insertRule(".other { opacity: 0.75; }");
target.style.opacity = "0.5";
});
mutate("delete", () => {
sheet.deleteRule(1);
target.style.opacity = "0.25";
});
mutate("declaration", () => {
sheet.cssRules[0].style.opacity = "0.125";
target.style.opacity = "0.75";
});
});
</script>