Hi satyr,
thanks for taking the time to look over this.  Your snippet and my
script both work fine with most GM scripts.  The problem arises when
the GM menu command invoked from Ubiquity uses some GM_* API function.
 In order to reproduce it with your snippet, you have to create a
one-line Greasemonkey script like

GM_registerMenuCommand('foo', function(){ GM_setValue('bar', 42) });

and ensure you place the script *first* in the script list (this is
because your snippet executes the first menu command it encounters; if
you have more than one, you have to place the GM script above in the
list to ensure the menu command get registered first as well.)

If you do that, you'll see in the error console:

Error: Greasemonkey access violation: unsafeWindow cannot call GM_setValue.


As I said in the GM thread, I modified the GM extension to show more
in depth information about the error.  What I'm getting in this case
is:

Error:
Greasemonkey access violation: unsafeWindow cannot call GM_setValue from
file:///<profile>/extensions/[email protected]/modules/sandboxfactory.js#ubiquity://command-editor-code.
 ----------
Error:
Stack trace:

* 
file://<profile>/extensions/%7Be4a8a97b-f2ed-450b-b12d-ee082ba24781%7D/components/greasemonkey.js
* chrome://greasemonkey/content/miscapis.js
* chrome://greasemonkey/content/utils.js
* 
file:///<profile>/extensions/%7Be4a8a97b-f2ed-450b-b12d-ee082ba24781%7D/components/greasemonkey.js
*
* 
file:///<profile>/extensions/[email protected]/modules/sandboxfactory.js#ubiquity://command-editor-code

Greasemonkey then sees that the first call comes from a file: url
which doesn't belong to Greasemonkey, and disallows execution.   I've
already talked the GM guys about this, but I am curious about why
Ubiquity scripts are "file:" urls and not "chrome:"

On Tue, Dec 29, 2009 at 1:49 AM, satyr <[email protected]> wrote:
> Hm, I can't seem to reproduce it. This snippet worked fine for me.
>
> function cmd_testUserScriptCommand(){
>  var mi = (Utils.currentChromeWindow.document
>            .querySelector('#userscript-commands-sb > menupopup > menuitem'));
>  mi && mi._commandFunc();
> }

--

You received this message because you are subscribed to the Google Groups 
"ubiquity-firefox" group.
To post to this group, send email to [email protected].
To unsubscribe from this group, send email to 
[email protected].
For more options, visit this group at 
http://groups.google.com/group/ubiquity-firefox?hl=en.


Reply via email to