Skip to main content

Bug Tracker

Side navigation

#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)
Change History (16)

Changed January 15, 2010 10:42PM UTC by eegee comment:1

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

Changed February 02, 2010 09:53PM UTC by cz comment:2

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 February 05, 2010 04:57PM UTC by orderthruchaos comment:3

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.

Changed March 02, 2010 02:27PM UTC by orderthruchaos comment:4

Actually the method in #6131 is probably safer.

Changed March 30, 2010 12:57PM UTC by cz comment:5

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

Changed June 15, 2010 01:46AM UTC by dmethvin comment:6

component: unfiledsupport

Changed October 04, 2010 08:23PM UTC by koshi comment:7

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.

Changed October 18, 2010 11:54PM UTC by snover comment:8

component: supportmisc
keywords: → needsreview
milestone: 1.4.1
priority: majorlow
version: 1.41.4.3

Changed November 11, 2010 01:44AM UTC by dmethvin comment:9

keywords: needsreview
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.

Changed November 14, 2010 04:06PM UTC by jerone comment:10

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.

Changed December 09, 2010 02:16PM UTC by yah.avatar@gmail.com comment:11

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

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

Enjoy,

yah.

Changed December 16, 2010 10:10PM UTC by anonymous comment:12

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

Changed February 09, 2011 07:56PM UTC by jerone comment:13

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

Changed February 15, 2011 01:10PM UTC by eegee comment:14

Replying to [comment:13 jerone]:

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

Great, thanks for the update.

Changed March 07, 2011 10:44PM UTC by anonymous comment:15

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.

Changed March 22, 2011 01:52PM UTC by Kambfhase comment:16

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.