зеркало из https://github.com/mozilla/gecko-dev.git
Bug 913243 - Load ErrorPage.js only when error occurs. r=fabrice
This commit is contained in:
Родитель
0aa113210f
Коммит
50dfaff474
|
@ -8,6 +8,8 @@ let Cu = Components.utils;
|
|||
let Cc = Components.classes;
|
||||
let Ci = Components.interfaces;
|
||||
|
||||
dump("############ ErrorPage.js\n");
|
||||
|
||||
let ErrorPageHandler = {
|
||||
_reload: function() {
|
||||
docShell.QueryInterface(Ci.nsIWebNavigation).reload(Ci.nsIWebNavigation.LOAD_FLAGS_NONE);
|
||||
|
@ -31,12 +33,8 @@ let ErrorPageHandler = {
|
|||
}
|
||||
},
|
||||
|
||||
domContentLoadedHandler: function(e) {
|
||||
let target = e.originalTarget;
|
||||
let targetDocShell = target.defaultView
|
||||
.QueryInterface(Ci.nsIInterfaceRequestor)
|
||||
.getInterface(Ci.nsIWebNavigation);
|
||||
if (targetDocShell != docShell) {
|
||||
_bindPageEvent: function(target) {
|
||||
if (!target) {
|
||||
return;
|
||||
}
|
||||
|
||||
|
@ -52,11 +50,23 @@ let ErrorPageHandler = {
|
|||
}
|
||||
},
|
||||
|
||||
domContentLoadedHandler: function(e) {
|
||||
let target = e.originalTarget;
|
||||
let targetDocShell = target.defaultView
|
||||
.QueryInterface(Ci.nsIInterfaceRequestor)
|
||||
.getInterface(Ci.nsIWebNavigation);
|
||||
if (targetDocShell != docShell) {
|
||||
return;
|
||||
}
|
||||
this._bindPageEvent(target);
|
||||
},
|
||||
|
||||
init: function() {
|
||||
addMessageListener("ErrorPage:ReloadPage", this._reload.bind(this));
|
||||
addEventListener('DOMContentLoaded',
|
||||
this.domContentLoadedHandler.bind(this),
|
||||
true);
|
||||
this._bindPageEvent(content.document);
|
||||
}
|
||||
};
|
||||
|
||||
|
|
|
@ -149,6 +149,26 @@ let ErrorPage = {
|
|||
}
|
||||
},
|
||||
|
||||
_listenError: function(frameLoader) {
|
||||
let self = this;
|
||||
let frameElement = frameLoader.ownerElement;
|
||||
let injectErrorPageScript = function() {
|
||||
let mm = frameLoader.messageManager;
|
||||
try {
|
||||
mm.loadFrameScript(kErrorPageFrameScript, true, true);
|
||||
} catch (e) {
|
||||
dump('Error loading ' + kErrorPageFrameScript + ' as frame script: ' + e + '\n');
|
||||
}
|
||||
mm.addMessageListener('ErrorPage:AddCertException', self._addCertException.bind(self));
|
||||
frameElement.removeEventListener('mozbrowsererror', injectErrorPageScript, true);
|
||||
};
|
||||
|
||||
frameElement.addEventListener('mozbrowsererror',
|
||||
injectErrorPageScript,
|
||||
true // use capture
|
||||
);
|
||||
},
|
||||
|
||||
init: function errorPageInit() {
|
||||
Services.obs.addObserver(this, 'in-process-browser-or-app-frame-shown', false);
|
||||
Services.obs.addObserver(this, 'remote-browser-frame-shown', false);
|
||||
|
@ -156,17 +176,7 @@ let ErrorPage = {
|
|||
|
||||
observe: function errorPageObserve(aSubject, aTopic, aData) {
|
||||
let frameLoader = aSubject.QueryInterface(Ci.nsIFrameLoader);
|
||||
let mm = frameLoader.messageManager;
|
||||
|
||||
// This won't happen from dom/ipc/preload.js in non-OOP builds.
|
||||
try {
|
||||
if (Services.prefs.getBoolPref("dom.ipc.tabs.disabled") === true) {
|
||||
mm.loadFrameScript(kErrorPageFrameScript, true, true);
|
||||
}
|
||||
} catch (e) {
|
||||
dump('Error loading ' + kErrorPageFrameScript + ' as frame script: ' + e + '\n');
|
||||
}
|
||||
mm.addMessageListener('ErrorPage:AddCertException', this._addCertException.bind(this));
|
||||
this._listenError(frameLoader);
|
||||
}
|
||||
};
|
||||
|
||||
|
|
|
@ -49,11 +49,6 @@ if (!('BrowserElementIsPreloaded' in this)) {
|
|||
} catch (e) {
|
||||
}
|
||||
}
|
||||
// Those are produc-specific files that's sometimes unavailable.
|
||||
try {
|
||||
Services.scriptloader.loadSubScript("chrome://browser/content/ErrorPage.js");
|
||||
} catch (e) {
|
||||
}
|
||||
|
||||
Services.scriptloader.loadSubScript("chrome://global/content/BrowserElementPanning.js");
|
||||
ContentPanning.init();
|
||||
|
|
|
@ -94,11 +94,6 @@ const BrowserElementIsPreloaded = true;
|
|||
} catch (e) {
|
||||
}
|
||||
|
||||
// Those are produc-specific files that's sometimes unavailable.
|
||||
try {
|
||||
Services.scriptloader.loadSubScript("chrome://browser/content/ErrorPage.js", global);
|
||||
} catch (e) {
|
||||
}
|
||||
Services.scriptloader.loadSubScript("chrome://global/content/BrowserElementPanning.js", global);
|
||||
Services.scriptloader.loadSubScript("chrome://global/content/BrowserElementChildPreload.js", global);
|
||||
|
||||
|
|
Загрузка…
Ссылка в новой задаче