<!DOCTYPE html>
<meta charset="utf-8">
<title>Updating the textContent of a style element must change the results of getComputedStyle</title>
<script src="/resources/testharness.js"></script>
<script src="/resources/testharnessreport.js"></script>

<!-- Derived from https://github.com/jsdom/jsdom/issues/2292 -->

<style>
  .my-class {
    font-size: 1.5em;
  }
</style>

<h1 class="my-class">Hello world</h1>

<script>
"use strict";
const el = document.querySelector(".my-class");
let insertedStyle;

test(() => {
  assert_equals(getComputedStyle(el).fontSize, "1.5em");
}, "Sanity check: getComputedStyle works as expected");

test(() => {
  insertedStyle = document.createElement("style");
  insertedStyle.textContent = ".my-class { font-size: 2em; }";
  document.head.appendChild(insertedStyle);

  assert_equals(getComputedStyle(el).fontSize, "2em");
}, "Inserting a new CSS element that overrides the old one updates the computed style");

test(() => {
  insertedStyle.textContent = ".my-class { font-size: 3em; }";

  assert_equals(getComputedStyle(el).fontSize, "3em");
}, "Updating the inserted CSS element changes the computed style");
</script>

Add regression test for dynamic <style> updates
Add regression test for dynamic <style> updates

Closes #2292, which was previously fixed (probably by one of 0c54ed399b7399d3ab86e8a9d59fa7ea34e060da, dbda070c9d33fb2762abedc23376757d9f8ec7d3, or f32113b6e1307832eb75d295d9da8185dd27006a) but not explicitly tested against.