dpacassi / disable-javascript

Adds the ability to disable JavaScript on specific sites.
MIT License
272 stars 34 forks source link

[Bug] Canvas alternate content is not displayed #111

Open vehlwn opened 1 year ago

vehlwn commented 1 year ago

Firefox 108.0.2 Disable JavaScript 2.3.1 Linux ... 6.1.2-arch1-1 #1 SMP PREEMPT_DYNAMIC Sat, 31 Dec 2022 17:40:35 +0000 x86_64 GNU/Linux

When I disable JS through this extension the alternative content is not shown in place of canvas elements. But when I disable JS globally through about:config javascript.enabled option alternative content appears.

According to this doc for canvas element:

Alternative content You should provide alternate content inside the block. That content will be rendered both on older browsers that don't support canvas and in browsers with JavaScript disabled.

Example page:

<!DOCTYPE html>
<html lang="en">
  <head>
    <meta charset="UTF-8" />
    <title>Test canvas alternative content</title>
    <style>
      canvas {
        border: 1px solid black;
      }
    </style>
  </head>
  <body>
    <canvas width="300" height="300">
      Your browser does not support JavaScript!
    </canvas>
    <script>
      const canvas = document.querySelector("canvas");
      const ctx = canvas.getContext("2d");
      ctx.fillStyle = "green";
      ctx.fillRect(10, 10, 100, 100);
    </script>
  </body>
</html>

Run:

python -m http.server --bind 127.0.0.1 5000

When JS is enabled you should see a green rectangle. When JS in disabled through this extension I see empty canvas. When JS is disabled through about:config I see caption "Your browser does not support JavaScript!" as in Chromium when JS is disabled in chrome://settings/content/javascript