Closed Bug 926369 Opened 11 years ago Closed 10 years ago

Object.keys method returns different results when using on global window object

Categories

(Core :: DOM: Core & HTML, defect)

27 Branch
x86_64
Windows 8
defect
Not set
normal

Tracking

()

RESOLVED FIXED
mozilla27

People

(Reporter: duongna, Assigned: peterv)

References

Details

User Agent: Mozilla/5.0 (Windows NT 6.2; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/30.0.1599.69 Safari/537.36

Steps to reproduce:

Run the following script:
<script>
    console.log(Object.keys(window));
    if(top == window){}
    console.log(Object.keys(window));
</script>


Actual results:

Returned value of the 2 calls are different:
["window", "document", "InstallTrigger", "console", "process", "global", "Mocha", "mocha", "sinon", "expect", "location", "mouseEvents", "msPointerEvents", "keyEvents", "uiEvents", "bubbleEvents", "touchEvents", "gestureEvents", "before", "after", "beforeEach", "afterEach", "context", "describe", "xcontext", "xdescribe", "specify", "it", "xspecify", "xit", "getInterface"]
["window", "document", "InstallTrigger", "console", "process", "global", "Mocha", "mocha", "sinon", "expect", "location", "mouseEvents", "msPointerEvents", "keyEvents", "uiEvents", "bubbleEvents", "touchEvents", "gestureEvents", "before", "after", "beforeEach", "afterEach", "context", "describe", "xcontext", "xdescribe", "specify", "it", "xspecify", "xit", "getInterface", "top"]


Expected results:

They should definitely be the same
Unless I'm mistaken, this is the expected behavior, per specifications of JS/DOM:
  |if (top == window) {}|
implicitly declares global value |top|, i.e. |window.top|.

Am I missing something?
I thought that |top| is a built in property of the |window| and should be available from beginning. Is it lazy loaded in Firefox?
top is an unforgeable property, so it should exist directly on |window|.  That it doesn't, initially, is probably a side effect of window not being WebIDL yet.  This is a DOM bug, really, not a JS bug.
Component: JavaScript Engine → DOM: Core & HTML
Depends on: 789261
(In reply to Jeff Walden [:Waldo] (remove +bmo to email) from comment #3)
> top is an unforgeable property, so it should exist directly on |window|. 
> That it doesn't, initially, is probably a side effect of window not being
> WebIDL yet.  This is a DOM bug, really, not a JS bug.
yes. @duongna, this bug should be fixed as a side-effect of fixing of bug 789261.
There are other ways in which using the window object doesn't comply to ECMAScript reflection methods. That should all be fixed when bug 789261 is fixed.
Component: DOM: Core & HTML → JavaScript Engine
Component: JavaScript Engine → DOM: Core & HTML
This was fixed by bug 918345.
Status: UNCONFIRMED → RESOLVED
Closed: 10 years ago
Depends on: 918345
Resolution: --- → FIXED
Assignee: nobody → peterv
Target Milestone: --- → mozilla27
You need to log in before you can comment on or make changes to this bug.