Source code
Revision control
Copy as Markdown
Other Tools
Test Info: Warnings
- This test has a WPT meta file that expects 1 subtest issues.
- This WPT test may be referenced by the following Test IDs:
- /html/semantics/document-metadata/the-style-element/no-browsing-context.html - WPT Dashboard Interop Dashboard
<!DOCTYPE html>
<meta charset="utf-8">
<title>Style should not apply with no browsing context</title>
<script src="/resources/testharness.js"></script>
<script src="/resources/testharnessreport.js"></script>
<script>
"use strict";
test(() => {
const doc = document.implementation.createHTMLDocument();
const style = document.createElement("style");
style.textContent = `
p { color: red; }
`;
doc.head.appendChild(style);
doc.body.appendChild(doc.createElement("p"));
assert_equals(window.getComputedStyle(doc.querySelector("p")).color, "");
}, "no impact on getComputedStyle");
test(() => {
const doc = document.implementation.createHTMLDocument();
const style = doc.createElement("style");
style.textContent = '@import url("/css/support/a-green.css");';
doc.head.append(style);
assert_equals(style.parentNode, doc.head);
}, "Inserting an importing style without a browsing context does not throw");
</script>