gloo icon indicating copy to clipboard operation
gloo copied to clipboard

Work around firefox webextensions bug

Open DCNick3 opened this issue 3 years ago • 3 comments

Importing gloo_timers in firefox webextension's content script results in an error: LinkError: import object field '__wbg_clearTimeout_65417660fe82f08d' is not a Function

It actually seems to be a firefox bug: https://bugzilla.mozilla.org/show_bug.cgi?id=1787770

This can simply be worked around by refering to timer functions using window object (setInterval -> window.setInterval) which this PR does. I do not think this would impact users outside of webextensions in any way, as window.setInterval and setInterval are the same functions in usual context (but apparently not in content scripts...)

DCNick3 avatar Aug 29 '22 14:08 DCNick3

Well, looks like this work around is not good enough. While the wasm module does instantiate fine, it still raises an error TypeError: 'clearTimeout' called on an object that does not implement interface Window. when the function is actually invoked.

DCNick3 avatar Aug 29 '22 14:08 DCNick3

Now this should work. Instead of using window object to refer to the function I make wasm-bindgen generate a wrapper around the desired function by marking it with catch. This way wasm module does not error out on instantiation and is actually able to use those APIs

DCNick3 avatar Aug 29 '22 14:08 DCNick3

It seems as a fix for the Firefox bug is underway. I would say we shouldn't merge this and let Firefox handle it.

ranile avatar Sep 16 '22 17:09 ranile