Source code
Revision control
Copy as Markdown
Other Tools
Test Info:
- This WPT test may be referenced by the following Test IDs:
- /css/cssom/getComputedStyle-shadow-host.html - WPT Dashboard Interop Dashboard
<!DOCTYPE html>
<meta charset="utf-8">
<title>getComputedStyle() in shadow host</title>
<script src="/resources/testharness.js"></script>
<script src="/resources/testharnessreport.js"></script>
<div id="div"></div>
<script>
"use strict";
test(() => {
window.customElements.define("x-foo", class extends window.HTMLElement {
constructor() {
super();
const style = document.createElement("style");
style.textContent = ":host { color: red }";
this.attachShadow({ mode: "open" }).appendChild(style);
}
});
const div = document.getElementById("div");
const elm = document.createElement("x-foo");
div.appendChild(elm);
assert_equals(window.getComputedStyle(elm).color, "rgb(255, 0, 0)");
});
</script>