Closed Bug 667817 Opened 13 years ago Closed 11 years ago

window.location object in page-mod contentscripts seems broken.

Categories

(Add-on SDK Graveyard :: General, defect, P2)

defect

Tracking

(Not tracked)

RESOLVED FIXED

People

(Reporter: KWierso, Assigned: ochameau)

References

()

Details

In the linked add-on in Builder, the contentscript runs on any page.
It logs the current page's window.location to the console.
It then shows the typeof for window.location.
It then iterates through all properties of the window.location object, logging each to the console.
After the loop finishes, it manually logs each of the properties to the console.



That should all work fine.

But it doesn't:

window.location logs the correct location.

typeof window.location is "object".

Nothing within the loop is logged. 

But all of the individual properties work when called manually.



This all works with Firebug and/or Firefox Nightly's new Scratchpad feature, for the record.
Location objects are handled differently in some wrapper code, e.g., [1].  I don't know what's going on here, but given the other sandbox- and wrapper-related bugs Jetpack has uncovered, this might be another one.

[1] http://mxr.mozilla.org/mozilla-central/source/js/src/xpconnect/wrappers/WrapperFactory.cpp#384
OS: Windows 7 → All
Priority: -- → P3
Hardware: x86 → All
Target Milestone: --- → Future
Upping priority just to get this figured out, at least.

Alex, any idea?
Priority: P3 → P2
Target Milestone: Future → 1.2
Assignee: nobody → poirot.alex
Target Milestone: 1.2 → 1.1
The proxy code is buggy when you use for..in loop.
The following code is wrong:
https://github.com/mozilla/addon-sdk/blob/master/packages/api-utils/lib/content/content-proxy.js#L758-764
I should not use Object.keys as it list only *own* enumerable properties although `enumerate` trap expect to retrieve names of all enumerable properties: own and prototype inherited ones.
Unfortunately, if I use a correct code:
  let result = [];
  for (let name in obj) {
    result.push(name);
  };
  return result;
I end up facing another bug around collection, where this for..in loop goes wrong (enumerate more items than expected)
(First bug around Collection fixed here:
https://github.com/mozilla/addon-sdk/blob/master/packages/api-utils/lib/content/content-proxy.js#L439-448 )

I definitively need to digg these Collections issues. I was not able to reduce these buggy behaviors to simple snippets. FYI, because of this, it is the only one wrapper issue that doesn't have a platform bug opened.
Status: NEW → ASSIGNED
Another issue has been reported around `location`.
If you change location using:
  window.location="http://mozilla.org";
Nothing happens, instead, `location` attribute is just replaced by a string.
(Pushing all open bugs to the --- milestone for the new triage system)
Target Milestone: 1.1 → ---
I think that these issues around location have been fixed with the removal of proxies for content scripts.
Please reopen if needed.
Status: ASSIGNED → RESOLVED
Closed: 11 years ago
Resolution: --- → FIXED
You need to log in before you can comment on or make changes to this bug.