Closed Bug 1139099 Opened 9 years ago Closed 9 years ago

Dispatch a DOMDocElementInserted event to match document-element-inserted

Categories

(Core :: DOM: Navigation, defect)

defect
Not set
normal

Tracking

()

RESOLVED FIXED
mozilla39
Tracking Status
firefox39 --- fixed

People

(Reporter: mossop, Assigned: mossop)

References

Details

Attachments

(1 file, 1 obsolete file)

In the add-on SDK we use the document-element-inserted to tell us when a new document is being created letting us access things like readyState and add event listeners to wait for the document to finish loading etc.

The downside is that this is process-wide and sometimes we only care about documents in a given frame. It is also shimmed by the add-on compatibility code so we end up causing CPOW traffic that we can't avoid until the entire SDK is e10s compliant.

For similar reasons bug 567357 added a DOMWindowCreated event to match (chrome|content)-document-global-created. I tried switching to that but at that point various properties we use (inner window ID, document) aren't available. Strangely even adding a load event listener to the window we're given by this event doesn't work properly.

I'd like to see a DOMDocumentCreated event or similar to match document-element-inserted.
Blocks: 1139113
Attached patch patch (obsolete) — Splinter Review
This seems to work, I have no idea if it is safe but I guess if an observer niotification is then so is event dispatch. Open to alternative naming for the event.
Assignee: nobody → dtownsend
Status: NEW → ASSIGNED
Attachment #8572195 - Flags: review?(mrbkap)
Comment on attachment 8572195 [details] [diff] [review]
patch

Review of attachment 8572195 [details] [diff] [review]:
-----------------------------------------------------------------

::: dom/base/nsContentSink.cpp
@@ +1550,5 @@
>        NotifyObservers(domDoc, "document-element-inserted",
>                        EmptyString().get());
>    }
> +
> +  nsContentUtils::DispatchTrustedEvent(aDoc, aDoc,

This should use nsContentUtils::DispatchChromeEvent so that content pages can't observe the new event. It'd also be good to modify <http://mxr.mozilla.org/mozilla-central/source/dom/tests/mochitest/bugs/test_DOMWindowCreated_chromeonly.html?force=1> to ensure that content pages can't see this event either.
Attachment #8572195 - Flags: review?(mrbkap)
Summary: Dispatch a DOMDocumentCreated event to match document-element-inserted → Dispatch a DOMDocElementInserted event to match document-element-inserted
Attached patch patchSplinter Review
I made those changes
Attachment #8572195 - Attachment is obsolete: true
Attachment #8573332 - Flags: review?(mrbkap)
Attachment #8573332 - Flags: review?(mrbkap) → review+
https://hg.mozilla.org/mozilla-central/rev/76d066cad8ef
Status: ASSIGNED → RESOLVED
Closed: 9 years ago
Resolution: --- → FIXED
Target Milestone: --- → mozilla39
You need to log in before you can comment on or make changes to this bug.

Attachment

General

Created:
Updated:
Size: