Bug 1416066 - Add page-content-fully-loaded notification to process-content.js.
MozReview-Commit-ID: 3xfh5SRjvkA
--- a/toolkit/content/process-content.js
+++ b/toolkit/content/process-content.js
@@ -17,16 +17,17 @@ Services.cpmm.addMessageListener("gmp-pl
.getService(Ci.mozIGeckoMediaPluginService);
gmpservice.RunPluginCrashCallbacks(msg.data.pluginID, msg.data.pluginName);
});
if (gInContentProcess) {
let ProcessObserver = {
TOPICS: [
+ "content-document-global-created",
"inner-window-destroyed",
"xpcom-shutdown",
],
init() {
for (let topic of this.TOPICS) {
Services.obs.addObserver(this, topic);
Services.cpmm.addMessageListener("Memory:GetSummary", this);
@@ -57,16 +58,26 @@ if (gInContentProcess) {
rss,
ghosts,
}
});
},
observe(subject, topic, data) {
switch (topic) {
+ case "content-document-global-created": {
+ let loadListener = () => {
+ subject.removeEventListener("load", loadListener);
+ if (subject.document.location.pathname !== "blank") {
+ Services.obs.notifyObservers(subject, "page-content-fully-loaded");
+ }
+ };
+ subject.addEventListener("load", loadListener);
+ break;
+ }
case "inner-window-destroyed": {
// Forward inner-window-destroyed notifications with the
// inner window ID, so that code in the parent that should
// do something when content windows go away can do it
let innerWindowID =
subject.QueryInterface(Ci.nsISupportsPRUint64).data;
Services.cpmm.sendAsyncMessage("Toolkit:inner-window-destroyed",
innerWindowID);