Source code
Revision control
Copy as Markdown
Other Tools
Test Info:
- This WPT test may be referenced by the following Test IDs:
- /html/semantics/document-metadata/the-style-element/non-parser-style.html - WPT Dashboard Interop Dashboard
<!DOCTYPE html>
<meta charset="utf-8">
<title>Non-parser-inserted style elements should still work</title>
<link rel="author" title="Domenic Denicola" href="mailto:d@domenic.me">
<script src="/resources/testharness.js"></script>
<script src="/resources/testharnessreport.js"></script>
<p>Test</p>
<script>
"use strict";
setup({ single_test: true });
const el = document.createElement("style");
el.textContent = "p { color: rgb(1, 2, 3); }";
document.head.appendChild(el);
assert_not_equals(el.sheet, null);
assert_true(el.sheet instanceof CSSStyleSheet);
assert_array_equals(document.styleSheets, [el.sheet]);
assert_equals(getComputedStyle(document.querySelector("p")).color, "rgb(1, 2, 3)");
done();
</script>