Bug Tracker

Opened 10 years ago

Closed 9 years ago

Last modified 9 years ago

#5833 closed bug (patchwelcome)

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 (465 bytes) - added by orderthruchaos 10 years ago.
Patch that (potentially) fixes event support.
jquery-1.4.2.js.GMfix.diff (1.0 KB) - added by koshi 9 years ago.
Safe access to wrappedJSObject

Download all attachments as: .zip

Change History (18)

comment:1 Changed 10 years ago by eegee

EDIT: I meant to say it worked with the latest jQuery v1.3.x

comment:2 Changed 10 years ago by cz

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.

Changed 10 years ago by orderthruchaos

Patch that (potentially) fixes event support.

comment:3 Changed 10 years ago by orderthruchaos

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.

comment:4 Changed 10 years ago by orderthruchaos

Actually the method in #6131 is probably safer.

comment:5 Changed 10 years ago by cz

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

comment:6 Changed 9 years ago by dmethvin

Component: unfiledsupport

Changed 9 years ago by koshi

Attachment: jquery-1.4.2.js.GMfix.diff added

Safe access to wrappedJSObject

comment:7 Changed 9 years ago by koshi

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.

comment:8 Changed 9 years ago by snover

Component: supportmisc
Keywords: needsreview added
Milestone: 1.4.1
Priority: majorlow
Version: 1.41.4.3

comment:9 Changed 9 years ago by dmethvin

Keywords: needsreview removed
Resolution: patchwelcome
Status: newclosed

Perhaps some Greasemonkey devs can examine the patch or propose an alternate fix? Without close cooperation from Greasemonkey users we can't proceed.

comment:10 Changed 9 years ago by jerone

As version 1.4.4 still has problems with GreaseMonkey, I uploaded a 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.

comment:11 Changed 9 years ago by yah.avatar@…

Here's a working minified version of jQuery 1.4.4 for Greasemonkey:

http://userscripts.org/scripts/review/92329

Enjoy, yah.

comment:12 in reply to:  10 Changed 9 years ago by anonymous

Replying to jerone:

As version 1.4.4 still has problems with GreaseMonkey, I uploaded a 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..

comment:13 Changed 9 years ago by jerone

For the records, jQuery 1.5 is compatible with GreaseMonkey again.

comment:14 in reply to:  13 Changed 9 years ago by eegee

Replying to jerone:

For the records, jQuery 1.5 is compatible with GreaseMonkey again.

Great, thanks for the update.

comment:15 in reply to:  13 Changed 9 years ago by anonymous

Replying to 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.

comment:16 Changed 9 years ago by Kambfhase

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.

Note: See TracTickets for help on using tickets.