Closed
Bug 567357
Opened 15 years ago
Closed 15 years ago
Fire a DOMWindowCreated DOM event to match the observer notification in bug 549539
Categories
(Core :: DOM: Core & HTML, defect)
Tracking
()
RESOLVED
FIXED
mozilla2.0b6
Tracking | Status | |
---|---|---|
status1.9.2 | --- | .7-fixed |
People
(Reporter: benjamin, Assigned: benjamin)
References
Details
(Keywords: dev-doc-needed)
Attachments
(1 file, 1 obsolete file)
8.49 KB,
patch
|
sicking
:
review+
|
Details | Diff | Splinter Review |
Bug 549539 added a (chrome|content)-document-global-created observer-service notification. People using the message manager, however, don't have easy access to the observer service and really want to be scoped to the current tab and its descendent frames anyway. This patch adds a chrome-listener-only DOMWindowCreated event which has the same effect (fires before any content script is run).
There is one issue I'm not sure about here: this patch ends up issuing a WARNING: fix the caller! file c:/builds/mozilla-central/ff-debug/content/events/src/../../../../src/content/events/src/nsEventDispatcher.cpp, line 512
because DocumentViewerImpl::InitInternal holds an nsAutoScriptBlocker. This means at least that any observers of (chrome|content)-document-global-created, as well as any event listeners of this new DOM event, need to be careful not to cause re-entrancy into DocumentViewerImpl::InitPresentationStuff. The script-blocker was added in bug 528493. Is there some way to silence this warning by refactoring InitInternal so that it actually is safe to run any scripts during that time, suppressing InitPresentationStuff?
Assignee | ||
Comment 1•15 years ago
|
||
Attachment #446714 -
Flags: superreview?(roc)
Attachment #446714 -
Flags: review?(jonas)
Comment 2•15 years ago
|
||
Don't we need something similar for the window-destroyed case, then? Except there's no obvious place to dispatch the event for that one....
Assignee | ||
Comment 3•15 years ago
|
||
None of my current candidate-consumers do: they typically just add something to the global object like window.Mochitest = mychromething, or window.InstallTrigger, or add an event listener to the document for things like form autofill, etc. None of those clients really care about when the document goes away.
Comment 4•15 years ago
|
||
Ah, ok.
Will chrome consumers in e10s receive observer service notifications at all? Or do we need a different setup for the consumers who do care about window destruction? Note that the destruction message is async, so can be remoted easily as needed.
Assignee | ||
Comment 5•15 years ago
|
||
Not sure what "chome consumers" you mean. The observer service will function normally in both the chrome and content processes. It's just that my current plan is that the content process will only run builtin XPCOM components (libxul, plus maybe platform JS components), and extensions/apps won't have the opportunity to register contractids/category entries in the content process.
Comment 6•15 years ago
|
||
> Not sure what "chome consumers" you mean.
Firebug, for one. It wants to know when it can forget all the script info it cached for a window.
Assignee | ||
Comment 7•15 years ago
|
||
I don't think we know how Firebug is going to work yet in content-land.
Comment on attachment 446714 [details] [diff] [review]
DOMWindowCreated, rev. 1
+ if (domEventDoc)
+ domEventDoc->CreateEvent(NS_LITERAL_STRING("event"), getter_AddRefs(event));
{}
Attachment #446714 -
Flags: superreview?(roc) → superreview+
Comment 9•15 years ago
|
||
Please don't add DOM events which fire at unsafe time.
But is the script blocker still needed in DocumentViewer?
nsSubDocumentFrame::ShowViewer is called async nowadays.
Comment 10•15 years ago
|
||
Are we talking the blocker in InitInternal? I don't see how async would help with the flushing problem that blocker tries to address...
Comment 11•15 years ago
|
||
I was just looking at the stack trace for which the blocker was added, but
perhaps I misinterpreted that.
I agree with comment 9. Could you add a scriptrunner (nsContentUtils::AddScriptRunner) which fires the event?
Attachment #446714 -
Flags: review?(jonas)
Comment 13•15 years ago
|
||
Will that still guarantee that the event fires before content script can run?
Comment 14•15 years ago
|
||
I guess it should, more or less by definition....
Assignee | ||
Comment 15•15 years ago
|
||
Scriptrunner FTW
Attachment #446714 -
Attachment is obsolete: true
Attachment #447911 -
Flags: review?(jonas)
Comment 16•15 years ago
|
||
would this patch solve this assertion:
###!!! ASSERTION: Want to fire mutation events, but it's not safe: '(aNode->IsNodeOfType(nsINode::eCONTENT) && static_cast<nsIContent*>(aNode)-> IsInNativeAnonymousSubtree()) || sScriptBlockerCount == sRemovableScriptBlockerCount', file /home/joel/mozilla/src/content/base/src/nsContentUtils.cpp, line 3419
Assignee | ||
Comment 17•15 years ago
|
||
That depends on the stack at the time.
Comment on attachment 447911 [details] [diff] [review]
DOMWindowCreated, rev. 2
Use nsContentUtils::DispatchChromeEvent instead, that'll save you much of this code.
r=me with that
Attachment #447911 -
Flags: review?(jonas) → review+
Assignee | ||
Comment 19•15 years ago
|
||
Status: NEW → RESOLVED
Closed: 15 years ago
Resolution: --- → FIXED
Comment 20•15 years ago
|
||
could this have caused the 100ms startup regression in bug 574457?
Fixed on 1.9.2 as part of bug 549539
status1.9.2:
--- → .6-fixed
(In reply to comment #20)
> could this have caused the 100ms startup regression in bug 574457?
That seems very unlikely. Simply firing the notification when no one is listening should be a very low cost operation. Especially in the context of creating a new global object.
Updated•15 years ago
|
Keywords: dev-doc-needed
Updated•13 years ago
|
Target Milestone: --- → mozilla2.0b6
Version: unspecified → Trunk
Updated•6 years ago
|
Component: DOM → DOM: Core & HTML
You need to log in
before you can comment on or make changes to this bug.
Description
•