VelocityJS does not work within the context of Firefox extensions
Your system information
- VelocityJS version: 2.0.5b
- Browser: Firefox 64.0.2 (64-bit)
- Operating System: Windows 7 Ultimate 64-bit
Checklist
- Is this an issue with code?: Yes
- Is this an issue with documentation?: No
- Have you reproduced this in other browsers?: Yes
- Have you checked for updates?: Yes
- Have you checked for similar open issues?: Yes
Please remember that this is an issue tracker, support requests should be posted on StackOverflow - see CONTRIBUTING.md
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):
- Require VelocityJS in a content script of a Firefox extension
- VelocityJS will have errors initializing due to a bug in Firefox where (window instanceof Object) evaluates to false for content scripts. (window instanceof window.Object) will evaluate to true in firefox.
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.
Source: julianshapiro/velocity