Bug 517768 - crash with view page source and external editor [@nsDocShell::OnStateChange(nsIWebProgress*, nsIRequest*, unsigned int, unsigned int) ]. r=bz
Bug 517768 - crash with view page source and external editor [@nsDocShell::OnStateChange(nsIWebProgress*, nsIRequest*, unsigned int, unsigned int) ]. r=bz
--- a/toolkit/components/viewsource/content/viewSourceUtils.js
+++ b/toolkit/components/viewsource/content/viewSourceUtils.js
@@ -136,16 +136,17 @@ var gViewSourceUtils = {
.deleteTemporaryFileOnExit(file);
} else {
// we'll use nsIWebPageDescriptor to get the source because it may
// not have to refetch the file from the server
// XXXbz this is so broken... This code doesn't set up this docshell
// at all correctly; if somehow the view-source stuff managed to
// execute script we'd be in big trouble here, I suspect.
var webShell = Components.classes["@mozilla.org/docshell;1"].createInstance();
+ webShell.QueryInterface(Components.interfaces.nsIBaseWindow).create();
this.viewSourceProgressListener.webShell = webShell;
var progress = webShell.QueryInterface(this.mnsIWebProgress);
progress.addProgressListener(this.viewSourceProgressListener,
this.mnsIWebProgress.NOTIFY_STATE_DOCUMENT);
var pageLoader = webShell.QueryInterface(this.mnsIWebPageDescriptor);
pageLoader.loadPage(aPageDescriptor, this.mnsIWebPageDescriptor.DISPLAY_AS_SOURCE);
}
}
@@ -209,21 +210,22 @@ var gViewSourceUtils = {
if (aIID.equals(this.mnsIWebProgressListener) ||
aIID.equals(Components.interfaces.nsISupportsWeakReference) ||
aIID.equals(Components.interfaces.nsISupports))
return this;
throw Components.results.NS_NOINTERFACE;
},
destroy: function() {
- this.webShell = null;
- this.editor = null;
- this.callBack = null;
- this.data = null;
- this.file = null;
+ this.webShell.QueryInterface(Components.interfaces.nsIBaseWindow).destroy();
+ this.webShell = null;
+ this.editor = null;
+ this.callBack = null;
+ this.data = null;
+ this.file = null;
},
onStateChange: function(aProgress, aRequest, aFlag, aStatus) {
// once it's done loading...
if ((aFlag & this.mnsIWebProgressListener.STATE_STOP) && aStatus == 0) {
try {
if (!this.file) {
// it's not saved to file yet, it's in the webshell