Ticket #106 (new defect)

Opened 3 months ago

Last modified 3 weeks ago

DOMNodeInserted event doesn't allow GM_xmlhttpRequest

Reported by: neave..@gmail.com Assigned to:
Priority: trivial Milestone:
Version: Keywords:
Cc:

Description

I'm not sure if this is a bug or not, but I figured I'd post it anyway.
If you add a "DOMNodeInserted" event to an element and have it call a GM_xmlhttpRequest, you get the following error:
Error: Greasemonkey access violation: unsafeWindow cannot call GM_xmlhttpRequest.
If you do this on a "click" event, there is no access violation.
Workaround is to use setTimeout within the DOMNodeInserted callback function and have that call GM_xmlhttpRequest instead, it seems to work.
(ie: setTimeout(function() { GM_xmlhttpRequest(...) }, 0); )

Sample script: http://64.90.176.34/greasemonkeyBug.user.js
Sample page: http://64.90.176.34/greasemonkeyBug.html

Result:
64.90.176.34/Bug Test: DOMNodeInserted - pre-GM_xmlhttpRequest

----------

Error: Greasemonkey access violation: unsafeWindow cannot call GM_xmlhttpRequest.

----------

64.90.176.34/Bug Test: DOMNodeInserted - post-GM_xmlhttpRequest

----------

64.90.176.34/Bug Test: click - pre-GM_xmlhttpRequest

----------

64.90.176.34/Bug Test: click - post-GM_xmlhttpRequest

----------

64.90.176.34/Bug Test: DOMNodeInserted - setTimeout - pre-GM_xmlhttpRequest

----------

64.90.176.34/Bug Test: DOMNodeInserted - setTimeout - post-GM_xmlhttpRequest


Firefox: 2.0.0.14
Greasemonkey: 0.7.20080121.0

Attachments

Change History

07/08/08 07:59:22 changed by singpoly..@gmail.com

I also have this problem.

07/14/08 03:03:04 changed by Me three

This has affected me as well and it's quite aggravating.

This page at the GreaseSpot? wiki may be relevant: http://wiki.greasespot.net/0.7.20080121.0_compatibility

In a userscript that I'm writing for a very AJAX-y site, I'm attaching listeners for DOMNodeInserted and DOMNodeRemoved events to an element node that works as a sort of container for other element nodes that are created sporadically.

After reading that, I tried some of the (kludgey) workarounds suggested in the GreaseSpot? Wiki page, but just got different errors. This may be related to the fact that the functions that are calling GM_xmlhttpRequest are still being triggered from my DOMNodeInserted event handling function.


Add/Change #106 (DOMNodeInserted event doesn't allow GM_xmlhttpRequest)