jQuery issues have moved to GitHub. This site is now a static archive of the old Trac bugs site. Some functions and pages are no longer available.
Skip to main content
jQuery sites navigation menu
●
jQuery
●
Plugins
●
UI
●
Meetups
●
Forum
●
Blog
●
About
●
Donate
jQuery Core navigation menu
●
Download
●
Documentation
●
Tutorials
●
Bug Tracker
●
Discussion
Bug Tracker
Side navigation
New Ticket
View Tickets
Ticket Graph
Roadmap
Recent Changes
●
← Previous Ticket
●
Next Ticket →
#5833
closed
bug
(patchwelcome)
Opened January 15, 2010 10:40PM UTC
Closed November 11, 2010 01:44AM UTC
Last modified March 22, 2011 01:52PM UTC
Greasemonkey "@require" error
Reported by: |
eegee
|
Owned by: |
|
Priority:
|
low
|
Milestone: |
|
Component: |
misc |
Version: |
1.4.3 |
Keywords: |
|
Cc: |
|
Blocked by:
|
|
Blocking:
|
|
Description
When including either "jquery-1.4.js" or "jquery-1.4.min.js" using the "@require" key in Greasemonkey v0.8.20091209.4 with Firefox v3.5.7 it reports the following error in Firebug v1.4.5 using the Development version of jQuery v1.4:
"Component is not available
file:///.../jquery-latestmin.js
Line 918"
(I have removed the directory location as it is irrelevant). It worked with with jQuery v1.3.5.
Attachments (2)
●
jquery-1.4.1.js-event_detection.patch (0.5 KB) - added by orderthruchaos
February 05, 2010 04:49PM UTC.
Patch that (potentially) fixes event support.
●
jquery-1.4.2.js.GMfix.diff (1.0 KB) - added by koshi
October 04, 2010 07:52PM UTC.
Safe access to wrappedJSObject
Change History (16)
EDIT: I meant to say it worked with the latest jQuery v1.3.x
This was introduced with the addition of eventSupported() used to determine support for onsubmit and onchange (for submitBubbles and changeBubbles). First mention I can find of it is here:
http://dev.jquery.com/ticket/5267
Inside the eventSupported function, the created HTMLDivElement is wrapped with XPCNativeWrapper under Greasemonkey.. and blam, "Component is not available"
No more jQuery under Greasemonkey. Verified with 1.4 and 1.4.1. Last working revision under Greasemonkey is 1.3.2.
I have added a patch which allows the div to be inspected by using the .wrappedJSObject property of the new div. My only concern is security effects in Firefox versions before 3. Starting in v3, this property returns a XPCSafeJSObjectWrapper, which is meant to allow inspection of the object.
Note that this same problem may prevent jQuery 1.4+ from working under the Jetpack extension system.
Actually the method in #6131 is probably safer.
The method in #6131 may be safer, but it doesn't actually keep the desired functionality. There are a few working solutions in this thread: http://forum.jquery.com/topic/importing-jquery-1-4-1-into-greasemonkey-scripts-generates-an-error
component: |
unfiled → support
|
All proposed solutions in the forum thread are either unsafe or doesn't keep the desired functionality.
It is unsafe to access ANY property of wrappedJSObject. An attack is based on a malformed getter on a prototype property.
Firefox 4 (JavaScript 1.8.5) has introduced getOwnPropertyDescriptor and other methods which maybe can be useful for safe observation of properties. For now we can only check if property is "clean" (has no custom getter) and then access this property (does not invoke it but only check a property type).
Theoretically there is yet watch-based attack. But it seems like Firefox (tested on FF 3.6) does not call watcher on indirect property assignment (through attribute assignment). To be more safe the setAttribute called on the wrapper.
See jquery-1.4.2.js.GMfix.diff patch.
component: |
support → misc
|
keywords: |
→ needsreview
|
milestone: |
1.4.1
|
priority: |
major → low
|
version: |
1.4 → 1.4.3
|
keywords: |
needsreview
|
resolution: |
→ patchwelcome
|
status: |
new → closed
|
Perhaps some Greasemonkey devs can examine the patch or propose an alternate fix? Without close cooperation from Greasemonkey users we can't proceed.
As version 1.4.4 still has problems with GreaseMonkey, I uploaded a [[http://userscripts.org/scripts/show/90232|working UserScript]] version of jQuery 1.4.4 with 2 fixes. Fixes are on line 575 to 577 and line 1112 to 1127 of the userscript.
Here's a working minified version of jQuery 1.4.4 for Greasemonkey:
http://userscripts.org/scripts/review/92329
Enjoy,
yah.
Replying to [comment:10 jerone]:
As version 1.4.4 still has problems with GreaseMonkey, I uploaded a [[http://userscripts.org/scripts/show/90232|working UserScript]] version of jQuery 1.4.4 with 2 fixes. Fixes are on line 575 to 577 and line 1112 to 1127 of the userscript.
Sorry, it doesn't totally work. html.mozMatchesSelector somehow doesn't get detected correctly in Greasemonkey (jQuery assumes it works, but it doesn't give the right answer), which causes .is and .closest to not work (at least). And of course I was using those..
For the records, jQuery 1.5 is compatible with GreaseMonkey again.
Replying to [comment:13 jerone]:
For the records, jQuery 1.5 is compatible with GreaseMonkey again.
Great, thanks for the update.
Replying to [comment:13 jerone]:
For the records, jQuery 1.5 is compatible with GreaseMonkey again.
This is not the case. There are several functions that won't work with GM 0.9.1.
The problem still lies in mozMatchesSelector and eventSupported.
Afaik the mozMatchesSelector problem only happens in Firefox 4. I filed a bug against Greasemonkey with a more general test case, because they might know a way to fix that: https://github.com/greasemonkey/greasemonkey/issues#issue/1300
Quickfix for jQuery: http://jsfiddle.net/JFsht/1/
That little snippet makes jQuery.is() work correctly again.
dation