[Bug 8241] Named properties on window

http://www.w3.org/Bugs/Public/show_bug.cgi?id=8241

--- Comment #13 from Cameron McCormack <cam@mcc.id.au> 2011-06-28 00:45:43 UTC ---
(In reply to comment #11)
> In the Firefox, case at least, I think part of your problem is that you're
> lumping together _different_ sorts of named properties.  In particular frame
> names are treated quite differently from properties that come from the global
> scope polluter in Gecko; I can't speak to other browsers.

Thanks, that's indeed what I've been missing.  I did some more testing:

http://people.mozilla.org/~cmccormack/tests/window-named-frame-vs-polluter.html
http://people.mozilla.org/~cmccormack/tests/window-named-frame-vs-polluter-quirks.html

> The exact Gecko name resolution process on Window is:

I got slightly different results for Gecko than your ordering -- in particular,
it looks like global scope polluter properties do get resolved in preference to
event handler properties.

So, ignoring the location/navigator/document/java/packages trickiness, the
above tests tell me the following about what things frame properties and global
scope pollution properties override:

  Firefox:
    * Frame properties override:
        Object.prototype properties, builtin and added
        Window.prototype properties, builtin and added
        event listener properties
      but not:
        JS builtin globals
        constructor
        variables or assignments on global
    * GSP properties override:
        event listener properties
      but nothing else.

  Chrome:
    * Frame properties override:
        Object.prototype properties, builtin and added
        Window.prototype properties, builtin and added
        event listener properties
        constructor
      but not:
        JS builtin globals
        variables or assignments on global
    * GSP properties override nothing.

  Safari:
    * Frame properties override:
        Object.prototype properties, builtin and added
        Window.prototype properties, builtin and added
      but not:
        JS builtin globals
        event listener properties
        constructor
        variables or assignments on global
    * GSP properties override nothing.

  Opera:
    * Frame properties override:
        Object.prototype properties, builtin and added
        Window.prototype properties, builtin and added
        event listener properties
        constructor
      but not:
        JS builtin globals
        variables or assignments on global
    * GSP properties override:
        Object.prototype properties, builtin and added
        Window.prototype added properties
        event listener properties
        constructor
      but not:
        Window.prototype builtin properties
        or anything else

  IE:
    * Frame properties override nothing.
    * GSP properties override:
        Window.prototype builtin properties
      but not:
        Window.prototype added properties
        or anything else.

Everyone is different, some slightly some wildly.  (And none of these schemes
fits in with the model of having a single set of named properties on Window.)

For the global scope polluter properties, ignoring event listener properties
for the moment, we have Firefox, Chrome and Safari all putting them at the
bottom of the resolution chain.  IE does the same except that elements with IDs
that match any of the Window.prototype builtin names (like open, alert, etc.),
the GSP property wins.  Opera behaves quite differently; GSP properties
override everything except for frame names, Window.prototype builtin names and
own properties on the window object (variables, JS builtin constructors).

For frame properties, Firefox/Chrome/Safari/Opera all have them override
properties from the prototype chain and not own properties on the window, but
whether they override event listener properties or "constructor" is
inconsistent.  (There'll definitely be differences in whether the event
listener properties are own properties on the window vs accessor properties on
Window.prototype.)  IE is the odd one out, where frame properties don't
override anything except for GSP properties.  Did IE do this to match what the
specs currently say?  I'm a little surprised that didn't break anything.

Here is a simple first order approximation to the different resolution orders
(and this is most of a difference for IE):

  1. Own properties on window (which would include JS builtin
     global properties like Array, Object, etc.)
  2. Frames
  3. Properties from the prototype chain (which would include
     "constructor" & event listener properties)
  4. Global scope polluter

Would this work?

-- 
Configure bugmail: http://www.w3.org/Bugs/Public/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
You are on the CC list for the bug.

Received on Tuesday, 28 June 2011 00:45:55 UTC