Closed
Bug 875781
Opened 12 years ago
Closed 6 years ago
content-document-global-created is not fired for tabs/windows created with window.open()
Categories
(Firefox :: General, defect)
Tracking
()
RESOLVED
INVALID
People
(Reporter: leandrotp22, Unassigned)
Details
When opening a new tab or window with window.open(), no matter the arguments used, the content-document-global-created notification will not fire for the page that's being loaded. This has a lot of implications, for example, greasemonkey scripts set to run at document-start will only run after the document is loaded.
The bug only happens if the window that's being opened is from the same domain of the opener, it does not happen for intersitial pop-ups.
I also found that user-agent overrides (from general.useragent.override) will not work in this scenario as well. The page's scripts will see the original FF user-agent instead of the override. Maybe this is related to that notification.
This can be reproduced easily:
1 - Make a page a.htm with code: <a href="javascript:void(window.open('b.htm'))">test</a>
2 - Make a page b.htm with code: <script>alert(navigator.userAgent);</script>
3 - Go to about:config and change general.useragent.override (or use User Agent Switcher)
Host them in a web server, and click the link on a.htm. When b.htm opens, it will display the original FF user-agent instead of the override. If there's a greasemonkey script for that page, it will not run before the page script.
If the page is loaded directly, or if it's opened from another domain, everything happens as it should.
Reporter | ||
Comment 1•12 years ago
|
||
I found that user-agent overrides have nothing to do with this bug. I was getting these results in my tests because of <a href="https://bugzilla.mozilla.org/show_bug.cgi?id=814379>bug 814379</a>. I'm developing an addon (<a href="https://addons.mozilla.org/firefox/addon/user-agent-js-fixer/">User-Agent JS Fixer</a>) to fix that bug, and that's why I was getting these strange results.
Anyway, the notification isn't being fired for windows created with window.open(), and this affects a lot of addons, including greasemonkey. In my case, I had to change my code to use document-element-inserted instead of content-document-global-created.
Comment 2•6 years ago
|
||
If the navigation is same-origin, then the about:blank window is created, then the navigation happens and reuses the same window, so a new window is NOT created. If the content-document-global-created listener is filtering by URL, it will be fairly confused by this, of course. If the intent is to detect documents, not windows, then content-document-global-created is not the right notification to be watching.
Status: UNCONFIRMED → RESOLVED
Closed: 6 years ago
Resolution: --- → INVALID
You need to log in
before you can comment on or make changes to this bug.
Description
•