| Index: lib/child/elemHide.js |
| =================================================================== |
| --- a/lib/child/elemHide.js |
| +++ b/lib/child/elemHide.js |
| @@ -328,27 +328,44 @@ let observer = { |
| port.emitWithResponse("elemhideEnabled", { |
| frames: getFrames(subject), |
| isPrivate: isPrivate(subject) |
| }).then(({ |
| enabled, contentType, docDomain, thirdParty, location, filter, |
| filterType |
| }) => |
| { |
| + if (Cu.isDeadWrapper(subject)) |
| + { |
| + // We are too late, the window is gone already. |
| + return; |
| + } |
| + |
| if (enabled) |
| { |
| if (!this.sheet) |
| { |
| this.sheet = Utils.styleService.preloadSheet(this.styleURL, |
| Ci.nsIStyleSheetService.USER_SHEET); |
| } |
| let utils = subject.QueryInterface(Ci.nsIInterfaceRequestor) |
| .getInterface(Ci.nsIDOMWindowUtils); |
| - utils.addSheet(this.sheet, Ci.nsIStyleSheetService.USER_SHEET); |
| + try |
| + { |
| + utils.addSheet(this.sheet, Ci.nsIStyleSheetService.USER_SHEET); |
| + } |
| + catch (e) |
| + { |
| + // Ignore NS_ERROR_ILLEGAL_VALUE - it will be thrown if we try to add |
| + // the stylesheet multiple times to the same document (the observer |
| + // will be notified twice for some documents). |
| + if (e.result != Cr.NS_ERROR_ILLEGAL_VALUE) |
| + throw e; |
| + } |
| } |
| else if (filter) |
| { |
| RequestNotifier.addNodeData(subject.document, subject.top, { |
| contentType, docDomain, thirdParty, location, filter, filterType |
| }); |
| } |
| }); |