mirror of
https://github.com/gorhill/uBlock.git
synced 2024-10-04 16:47:15 +02:00
getMessageManager() can throw
This commit is contained in:
parent
503ea4e638
commit
d8a47f1c0b
@ -36,13 +36,27 @@ const hostName = Services.io.newURI(Components.stack.filename, null, null).host;
|
|||||||
/******************************************************************************/
|
/******************************************************************************/
|
||||||
|
|
||||||
const getMessageManager = function(win) {
|
const getMessageManager = function(win) {
|
||||||
return win
|
let iface = win
|
||||||
.QueryInterface(Ci.nsIInterfaceRequestor)
|
.QueryInterface(Ci.nsIInterfaceRequestor)
|
||||||
.getInterface(Ci.nsIDocShell)
|
.getInterface(Ci.nsIDocShell)
|
||||||
.sameTypeRootTreeItem
|
.sameTypeRootTreeItem
|
||||||
.QueryInterface(Ci.nsIDocShell)
|
.QueryInterface(Ci.nsIDocShell)
|
||||||
.QueryInterface(Ci.nsIInterfaceRequestor)
|
.QueryInterface(Ci.nsIInterfaceRequestor);
|
||||||
.getInterface(Ci.nsIContentFrameMessageManager);
|
|
||||||
|
try {
|
||||||
|
return iface.getInterface(Ci.nsIContentFrameMessageManager);
|
||||||
|
} catch (ex) {
|
||||||
|
// This can throw. It appears `shouldLoad` can be called *after* a
|
||||||
|
// tab has been closed. For example, a case where this happens all
|
||||||
|
// the time (FF38):
|
||||||
|
// - Open twitter.com (assuming you have an account and are logged in)
|
||||||
|
// - Close twitter.com
|
||||||
|
// There will be an exception raised when `shouldLoad` is called
|
||||||
|
// to process a XMLHttpRequest with URL `https://twitter.com/i/jot`
|
||||||
|
// fired from `https://twitter.com/`, *after* the tab is closed.
|
||||||
|
// In such case, `win` is `about:blank`.
|
||||||
|
}
|
||||||
|
return null;
|
||||||
};
|
};
|
||||||
|
|
||||||
/******************************************************************************/
|
/******************************************************************************/
|
||||||
@ -163,6 +177,10 @@ const contentObserver = {
|
|||||||
}
|
}
|
||||||
|
|
||||||
let messageManager = getMessageManager(context);
|
let messageManager = getMessageManager(context);
|
||||||
|
if ( messageManager === null ) {
|
||||||
|
return this.ACCEPT;
|
||||||
|
}
|
||||||
|
|
||||||
let details = {
|
let details = {
|
||||||
frameId: isTopLevel ? 0 : this.getFrameId(context),
|
frameId: isTopLevel ? 0 : this.getFrameId(context),
|
||||||
openerURL: openerURL,
|
openerURL: openerURL,
|
||||||
|
Loading…
Reference in New Issue
Block a user