Re: [IndexedDB] Problems unprefixing IndexedDB

On 8/9/12 10:13 PM, Cameron McCormack wrote:
> I was thinking that properties for operations have always been on
> prototypes, so people would already be used to var shadowing them.

Yes (modulo the fact that var didn't always shadow them per spec), but...

> You are right though that if people use that same pattern, they will fail
> similarly.

Precisely, but only in UAs that drop their prefixed name.  The ones that 
don't will continue to work.  Which is setting up some pretty perverse 
incentives.

> Are there pages that rely on var shadowing for certain names and having
> the variable start off undefined?  I can only assume there are.

It's pretty unclear.  Consider this testcase:

   <script>
     var open;
     alert(open);
   </script>

and observe that it does not alert undefined in Safari, Opera, or 
Chrome, though it does so in Gecko.

Now this could happen for two reasons: either "open" is not on the proto 
itself, or the UA doesn't implement var shadowing per the ECMA spec 
changes.  This testcase:

   <script>
     window.__proto__.foo = 5;
   </script>
   <script>
     var foo;
     alert(foo);
   </script>

alerts undefined Opera (which therefore does the shadowing correctly), 
but alerts "5" in Safari and Chrome (because V8 and JSC have not been 
updated to the change in "var" behavior).  Hence pages that assume 
shadowing would fail in those browsers.

Incidentally, this testcase:

   <script>
     window.__proto__.open = undefined;
     alert(open);
   </script>

alerts undefined in Gecko, WebKit+JSC, and WebKit+V8, but not in Opera, 
indicating that in Opera the "open" method is present the window itself. 
  And this testcase:

   <script>
     alert(window.__proto__.open);
   </script>

alerts undefined in Opera but not either of the WebKit options or Gecko, 
indicating that "open" is in fact only present on the window object 
there, not on the prototype.

Make of that mess of non-interoperability what you will.  And I haven't 
even had the chance to to test the various IE versions!  Though things 
will be more complicated there due to the lack of __proto__, except 
maybe in recent versions that have Object.getPrototypeOf anyway.  At the 
very least the first testcase above can be tested pretty easily in IE, 
and it would be interesting to see what happens in different IE versions 
there.

-Boris

Received on Friday, 10 August 2012 02:36:07 UTC