capricorn86/happy-dom

`window.getComputedStyle` not returning correct style

Opened this issue · 0 comments

Describe the bug

The window.getComputedStyle function consistently returns an object looking like CSSStyleDeclaration { parentRule: null }, no matter the element passed in.

To Reproduce

import assert from "assert";
import { Browser } from "happy-dom";

const browser = new Browser();
const page = browser.newPage();

await page.goto('https://www.google.com');
await page.waitUntilComplete();

const style = page.mainFrame.window.getComputedStyle(page.mainFrame.document.body);

console.log(style);
assert.strictEqual(style.getPropertyValue('min-width'), '400px');
assert.strictEqual(style.getPropertyValue('font-size'), '14px');
assert.strictEqual(style.getPropertyValue('background'), '#202124');

Expected behavior
I expected the properties to reflect those from the HTML in https://www.google.com/.

Screenshots
image

Device:

  • OS: MacOS
  • Browser: Firefox
  • Version 128.0

Additional context
https://replit.com/@jonathanmorley/RichSandybrownCareware