Files
firefox/testing/web-platform/tests/css/cssom/CSSStyleSheet-constructable-disabled-regular-sheet-insertion.html
Emilio Cobos Álvarez ba32c1b0ef Bug 1617746 - Deal with duplicate adopted stylesheets correctly. r=nordzilla
This also fixes some other bits, like mAdoptedStyleSheets.ElementAt(0) (which
really should be "the first applicable adopted stylesheet") and so on. Added a
test for that.

The new invariant also implies that a DocumentOrShadowRoot can't appear twice in
StyleSheet::mAdopters.

Also clears adopted stylesheets in Document::ResetStylesheetsToURI, as it's the
right thing to do (if you hit that code path with constructable sheets you'd end
up asserting, as we'd call FillStyleSetDocumentSheets after and find sheets in
there). I don't quite have a test-case for that though.

Differential Revision: https://phabricator.services.mozilla.com/D64151
2020-02-27 01:46:17 +00:00

23 lines
959 B
HTML

<!doctype html>
<title>Shouldn't crash / assert when inserting a stylesheet after there are disabled constructable sheets</title>
<link rel="author" title="Emilio Cobos Álvarez" href="mailto:[email protected]">
<link rel="help" href="https://wicg.github.io/construct-stylesheets/">
<script src = '/resources/testharness.js'></script>
<script src = '/resources/testharnessreport.js'></script>
<div id="host"></div>
<script>
test(function() {
let sheet = new CSSStyleSheet({ disabled: true });
sheet.replaceSync("div { color: red }");
let root = document.getElementById("host").attachShadow({ mode: "open" });
root.adoptedStyleSheets = [sheet];
let style = document.createElement("style");
root.innerHTML = `
<style>div { color: green }</style>
<div>Should be green</div>
`;
assert_equals(getComputedStyle(root.querySelector("div")).color, "rgb(0, 128, 0)", "Should insert the sheet at the right position and not crash");
});
</script>