Ticket #108 (closed defect: fixed)

Opened 5 months ago

Last modified 3 months ago

var sidebar = "foo"; -> invalid value

Reported by: anonymous Assigned to: oyasu..@gmail.com
Priority: major Milestone: 0.8.1
Version: Keywords:
Cc:

Description

since a change between 20080417 and 20080418 creating a variable "sidebar" in a script leads to an javascript error:

"invalid value"

Attachments

Change History

05/18/08 11:13:55 changed by anonymous

Unusual. I get the same thing if I just alert(sidebar).

06/11/08 14:03:19 changed by aranti..@gmail.com

  • milestone set to 0.8.

06/12/08 08:17:17 changed by aranti..@gmail.com

  • milestone changed from 0.8 to 0.8.1.

The core developers have voted; 0.8 will be released as is, any issues will be fixed in an 0.8 relesae. Thus: moving the milestone.

06/19/08 08:20:58 changed by aranti..@gmail.com

Ticket #125 told us this happens for "scroll" and ticket #138 told us this happens for "external".

I don't yet know anything about how/why this happens, but a pattern is beginning to emerge.

06/21/08 19:49:00 changed by blindwander..@gmail.com

#125 came about after I installed 0.8 and I think I was likely using 20080417 prior to going to the official 0.8 release (the version string looks familiar). I know I downloaded it off the mailing list.

06/24/08 12:21:39 changed by oyasu..@gmail.com

  • owner set to oyasu..@gmail.com.
  • status changed from new to assigned.

The issue can be overcome for most scripts by wrapping the script in the "(function(){" ... "})();" hack GM 0.7 and prior enforced them to have (thus making the this object useless for scripts and interactive script debugging, as in 0.7).

The cause is apparently very ungraceful handling of name collisions with any xpconnect wrapped (sidebar, external) or XPCNativeWrapper function wrapper (scroll) property on the sandbox's __proto__ object (which we set to safeWin).

It can be experimented interactively in Firebug by running a script with the sole line unsafeWindow.gm = this; in it (and then using try { gm.eval("var sidebar = 1;"); } catch(e) { e } constructs, for instance, from the Firebug command line).

I see several possible ways of catering this. One is to do a similar fallback like the one we have for adding backwards compat with scripts assuming themselves to be function wrapped: detecting the particular compile error class and falling back to function-wrapping for scripts that encounter the issue.

While it will work well, it will make scripts depending on the this object feature suspiciously break (would gain a function wrapper they didn't use to have), as soon as Mozilla adds new cruft on the window object. Perhaps we should file a Mozilla bug on this? (https://bugzilla.mozilla.org/show_bug.cgi?id=435151 might be related.)

06/27/08 11:12:01 changed by aranti..@gmail.com

This seems to also be related to: http://groups.google.com/group/greasemonkey-users/t/6ebd3db308b36ac0

What that came down to is that saying "var parent" had all sorts of weird complications.

I vote very strongly for moving back to the guaranteed anonymous function wrapper around user scripts that GM 0.7 had. I believe it would completely fix this ticket, in all its versions. (Though to be honest, I still need to test that statement.)

06/30/08 20:40:34 changed by oyasu..@gmail.com

  • status changed from assigned to closed.
  • resolution set to fixed.

(In [748]) Fixes #108 by adding the @unwrap header and changing the default back to scripts run in an anonymous function wrapper in the GM sandbox, when it was not present on installation. (Also a small cleanup of the load sequence in the greasemonkey service.)


Add/Change #108 (var sidebar = "foo"; -> invalid value)




Action