TypeError: 'cancelAnimationFrame' called on an object that does not implement interface Window

I used interact.js in my extension and encountered this problem. I fixed this question to interact.js (see https://github.com/taye/interact.js/pull/810), but I think it looks more like an Firefox extension issue: why cancelAnimationFrame must be run in window context in the content script?

Steps to reproduce:

  1. Clone https://github.com/lmk123/firefox-addon-interactjs-bug
  2. In Firefox: Open the about:debugging page, click “This Firefox” (in newer versions of Firefox), click “Load Temporary Add-on”, then select manifest.json file in the extension’s directory.
  3. Open https://www.google.com, a “drag me” text will appear in the upper left corner
  4. Open dev tools, switch to the “Debugger” tab, and check the “Pause on exceptions” option on the right
  5. Now, drag the “drag me” text

You will see this error in Debugger:

You can edit manifest.json, replace interact.js to interact-fixed.js, reload the extension and the
google web page, now everything work fine.

This is probably a bug with how the window global in content scripts works which leads to cancelAnimationFrame not behaving properly when not being called on window, as interact.js seems to be doing.

It’d probably be best to file a bug for this at https://bugzilla.mozilla.org/enter_bug.cgi?product=WebExtensions