Closed Bug 874276 Opened 13 years ago Closed 12 years ago

DOM is out of date when accessed by script loaded with page-mod

Categories

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

defect

Tracking

(Not tracked)

RESOLVED INCOMPLETE

People

(Reporter: Michael.Balazs, Unassigned)

References

Details

User Agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10_8_2) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/29.0.1508.2 Safari/537.36 Steps to reproduce: Tried to load a content script into the new Google Hangouts (https://talkgadget.google.com/u/0/talkgadget/_/frame) page in Gmail. Tried to access the DOM normally and with unsafeWindow. The loading works through the interaction of two frames in main page (https://talkgadget.google.com/u/0/talkgadget/_/frame and https://talkgadget.google.com/u/0/talkgadget/_/chat) The first has an init script function init() { var frameType = window.location.hash[1]; var callbackWindow; switch (frameType) { case "t": callbackWindow = window.parent.opener; break; case "p": callbackWindow = window.top.opener.frames[ "gtn-roster-iframe-id"]; break; case "e": callbackWindow = window.parent.frames[ "gtn-roster-iframe-id"]; break; case "n": callbackWindow = null; break; default: throw Error('Unknown frame type: ' + frameType); } if (callbackWindow != null) { callbackWindow['_GC_OnFrameReady'](window); } } Which in turn populates the html of the page (https://talkgadget.google.com/u/0/talkgadget/_/frame). Actual results: The DOM gets populated by the call to callbackWindow['_GC_OnFrameReady'](window); and I can see it in the page source through a number of tools as well as visually on the page. However, the content script still sees the original unpopulated DOM thus preventing interaction. Expected results: The content script should have been updated to see the latest version of the DOM. I suspect that the populating of the DOM is this manor (from a function in another frame) prevented some trigger from firing which would have updated the reference to the DOM.
the behavior described here seems unlikely, as it would break a lot of things if it was true. what is probably happening is that your content script is getting executed before that init() function injects the new elements into DOM (likely first has to fetch them via XHR). this should be easy to test with a simple setTimeout() that delays the execution of your logic in content script. can you please verify if this is still happening?
Flags: needinfo?(Michael.Balazs)
hey Michael, i'm gonna close this per the previous comment. feel free to reopen if you can reproduce using the above instructions?
Status: UNCONFIRMED → RESOLVED
Closed: 12 years ago
Flags: needinfo?(Michael.Balazs)
Resolution: --- → INCOMPLETE
You need to log in before you can comment on or make changes to this bug.