-
Notifications
You must be signed in to change notification settings - Fork 1.6k
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
VelocityJS does not work within the context of Firefox extensions #902
Comments
Will have to think about what to do here (and actually get time for Velocity again) - that change is a complete no-go due to it breaking in several other circumstances (including NodeJS support) - if you can come up with a solution that works in both then feel free to PR something. |
I see. I guess an alternate solution would be to calculate the Object safely ahead of time, like: const safeObject = function () {
if (window && window.navigator && window.navigator.userAgent.indexOf("Firefox") > 0 ) {
return window.Object
}
return Object
}() And then compare against that. |
It really needs to be dynamic - and that's a lot of extra code to run every tick - can cache things like whether it's Firefox (ugh, I hate browser detection, even if it is the only way to fix browser bugs) - so something along those lines might be valid - and only needed for a specific use-case too, so maybe not much of a hit at all if done right! :-) |
It wouldn't need to run every tick, just once when velocity first loads in. The value would be cached as a global |
Totally agree about browser detection though, it's too bad this issue has been in Firefox for 3+ years with no fix in sight. |
Sadly the way Velocity works it needs to check if something is a subclass of something else - which means |
Making a note here - extensions have got a slightly different context, and different capabilities, than regular browser windows. V3 is getting written to not have an issue with this so it'll work a lot better for these situations - and I really want to ensure that the unit (or possibly integration) testing can actually check for it working in different browser / extensions / nodejs contexts! |
Your system information
Checklist
Please describe your issue in as much detail as possible:
This is an issue specifically with using velocity inside a Firefox extension.
Regarding the question "Have you reproduced this in other browsers?", I have tested this in chrome 71.0.3578.98 (Official Build) (64-bit) and the issue is not present there, since this is a Firefox specific bug.
Regarding Firefox, I have reported the relevant bug here, it's been linked to an issue open for 3 years now:
https://bugzilla.mozilla.org/show_bug.cgi?id=1523139
However, this can be fixed for Firefox users with a simple patch. In the registerNormalization function, the args are validated by asserting that the constructor is an instance of an Object. If this is changed to window.Object it will fix the Firefox issue.
Steps for reproducing this issue (code):
JSFiddle example showing issue in action (code):
I cannot make a JS fiddle of this since this issue is only present within the content script of an extension.
The text was updated successfully, but these errors were encountered: