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-pseudo-class.html - WPT Dashboard Interop Dashboard
<!DOCTYPE html>
<meta charset="utf-8">
<title>getComputedStyle should not return pseudo-class styles by default</title>
<script src="/resources/testharness.js"></script>
<script src="/resources/testharnessreport.js"></script>
<style>
button { background-color: rgb(127, 255, 212); }
button:hover { background-color: rgb(255, 228, 196); }
</style>
<button id="button">Submit</button>
<script>
"use strict";
test(() => {
const button = document.getElementById("button");
const styles = window.getComputedStyle(button);
assert_equals(styles.backgroundColor, "rgb(127, 255, 212)");
}, "getComputedStyle should return the default style, not :hover style");
</script>