Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Modules using 'requestAnimationFrame' are broken within firefox extensions #3855

Closed
iamolivinius opened this issue Mar 22, 2016 · 5 comments
Closed
Milestone

Comments

@iamolivinius
Copy link
Contributor

I guess all of semantic-ui's modules are invoked like this.. more or less

;(function ( $, window, document, undefined ) {
  ...
})( jQuery, window, document );

This works fine in the usual browser window environment but fails for example if you invoke the sidebar module from a Firefox extension's content script.

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

Other famous JS libraries fixed similar issues by replacing the window object with the "real" global object. see:

lodash/lodash#1340
zloirock/core-js#91

I was able to fix the error by adding the following code (extracted from core-js) to the sidebar module:

var global = typeof window != 'undefined' && window.Math == Math
  ? window : typeof self != 'undefined' && self.Math == Math ? self : Function('return this')();

;(function ( $, window, document, undefined ) {
  ...
})( jQuery, global, document );

TC39 is also making some efforts in this direction but the proposed getGlobal function is not reliable within Firefox extensions: https://github.com/tc39/proposal-global#rationale

@jlukic
Copy link
Member

jlukic commented Mar 25, 2016

Thanks for the thorough bug post.

Pretty easy fix with no downsides. Will probably toss that sucker right in the SEAF

@jlukic jlukic added this to the 2.1.9 milestone Mar 25, 2016
@jlukic
Copy link
Member

jlukic commented Mar 29, 2016

Thoughts on

;(function ( $, window, document, undefined ) {
...
})( jQuery, (typeof window != 'undefined' && window.Math == Math) ? window : (typeof self != 'undefined' && self.Math == Math) ? self : Function('return this')(), document );

@jlukic
Copy link
Member

jlukic commented Mar 29, 2016

This should do it

@jlukic jlukic closed this as completed Mar 29, 2016
@jlukic
Copy link
Member

jlukic commented Mar 29, 2016

Argh messed up find & replace. Will fix in another commit.

jlukic added a commit that referenced this issue Mar 29, 2016
@jlukic jlukic modified the milestones: 2.1.9, 2.2 May 1, 2016
sbdchd added a commit to getlinky/linky that referenced this issue Jan 17, 2017
Currently a bug with vue <transition> and firefox extensions which
results in

    TypeError: 'requestAnimationFrame' called on an object that does not implement interface Window.
    Stack trace:
    zt@resource://gre/modules/ExtensionContent.jsm -> moz-extension://3b35a7b5-6bf4-744d-900b-04c8768fdd55/js/content_script.js:6:30523
    Gt@resource://gre/modules/ExtensionContent.jsm -> moz-extension://3b35a7b5-6bf4-744d-900b-04c8768fdd55/js/content_script.js:7:551
    tn@resource://gre/modules/ExtensionContent.jsm -> moz-extension://3b35a7b5-6bf4-744d-900b-04c8768fdd55/js/content_script.js:7:1640
    d@resource://gre/modules/ExtensionContent.jsm -> moz-extension://3b35a7b5-6bf4-744d-900b-04c8768fdd55/js/content_script.js:6:23084
    o@resource://gre/modules/ExtensionContent.jsm -> moz-extension://3b35a7b5-6bf4-744d-900b-04c8768fdd55/js/content_script.js:6:22291
    xt/<@resource://gre/modules/ExtensionContent.jsm -> moz-extension://3b35a7b5-6bf4-744d-900b-04c8768fdd55/js/content_script.js:6:26311
    we/e.prototype._update@resource://gre/modules/ExtensionContent.jsm -> moz-extension://3b35a7b5-6bf4-744d-900b-04c8768fdd55/js/content_script.js:6:10301
    we/e.prototype._mount/n._watcher<@resource://gre/modules/ExtensionContent.jsm -> moz-extension://3b35a7b5-6bf4-744d-900b-04c8768fdd55/js/content_script.js:6:10082
    Ji.prototype.get@resource://gre/modules/ExtensionContent.jsm -> moz-extension://3b35a7b5-6bf4-744d-900b-04c8768fdd55/js/content_script.js:7:26477
    Ji.prototype.run@resource://gre/modules/ExtensionContent.jsm -> moz-extension://3b35a7b5-6bf4-744d-900b-04c8768fdd55/js/content_script.js:7:27130
    z@resource://gre/modules/ExtensionContent.jsm -> moz-extension://3b35a7b5-6bf4-744d-900b-04c8768fdd55/js/content_script.js:6:4802
    Ai</</<@resource://gre/modules/ExtensionContent.jsm -> moz-extension://3b35a7b5-6bf4-744d-900b-04c8768fdd55/js/content_script.js:7:23148
    e@resource://gre/modules/ExtensionContent.jsm -> moz-extension://3b35a7b5-6bf4-744d-900b-04c8768fdd55/js/content_script.js:7:22607

see Semantic-Org/Semantic-UI#3855
@danmoller
Copy link

danmoller commented Jan 25, 2018

I still get this error when I try to put angular as a content script....

(Which can be solved with the workarond proposed by the OP)

NoxHarmonium added a commit to NoxHarmonium/reagent that referenced this issue Jul 30, 2019
* Browser extensions in Firefox have a weird issue where functions that
are on the DOM or on window cannot be assigned to a variable without
being bound to the context they came from
* Related links:
** https://lwhorton.github.io/2018/10/20/clojurescript-interop-with-javascript.html#pitfalls
** https://github.com/bvaughn/react-virtualized/pull/1013/files
** Semantic-Org/Semantic-UI#3855
NoxHarmonium added a commit to NoxHarmonium/reagent that referenced this issue Aug 29, 2019
* Browser extensions in Firefox have a weird issue where functions that
are on the DOM or on window cannot be assigned to a variable without
being bound to the context they came from
* Related links:
** https://lwhorton.github.io/2018/10/20/clojurescript-interop-with-javascript.html#pitfalls
** https://github.com/bvaughn/react-virtualized/pull/1013/files
** Semantic-Org/Semantic-UI#3855
NoxHarmonium added a commit to NoxHarmonium/reagent that referenced this issue Sep 7, 2019
* Browser extensions in Firefox have a weird issue where functions that
are on the DOM or on window cannot be assigned to a variable without
being bound to the context they came from
* Related links:
** https://lwhorton.github.io/2018/10/20/clojurescript-interop-with-javascript.html#pitfalls
** https://github.com/bvaughn/react-virtualized/pull/1013/files
** Semantic-Org/Semantic-UI#3855
NoxHarmonium added a commit to NoxHarmonium/reagent that referenced this issue Sep 21, 2019
* Browser extensions in Firefox have a weird issue where functions that
are on the DOM or on window cannot be assigned to a variable without
being bound to the context they came from
* Related links:
** https://lwhorton.github.io/2018/10/20/clojurescript-interop-with-javascript.html#pitfalls
** https://github.com/bvaughn/react-virtualized/pull/1013/files
** Semantic-Org/Semantic-UI#3855
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants