Rietveld Code Review Tool
Help | Bug tracker | Discussion group | Source code

Unified Diff: lib/child/elemHide.js

Issue 29347296: Issue 4227 - Add some checks to consider edge conditions when element hiding stylesheet is applied (Closed)
Patch Set: Created July 6, 2016, 1:47 p.m.
Use n/p to move between diff chunks; N/P to move between comments.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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
});
}
});
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld