Javascript canvas only works on Chrome, not Firefox

I can see that the canvas is there from dev tools and a outline goes around the canvas just fine.
I don’t get any errors from the console.

Firefox Version: 128.0.2 (64-bit)
I’m running Pop-os.

const canvas = document.getElementById("canvas")

const ctx = canvas.getContext("2d")

ctx.fillStyle = "red"
ctx.fillRect(30, 30, canvas.width, canvas.height)
<canvas id="canvas" width="300" height="300"></canvas>

The canvas should be completely filled with red, which it is on chrome.