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

Unified Diff: lib/elemHide.js

Issue 5697079653433344: Issue 340 - Element hiding reports NS_ERROR_NOT_AVAILABLE to error console (Closed)
Patch Set: Created April 16, 2014, 12: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/elemHide.js
===================================================================
--- a/lib/elemHide.js
+++ b/lib/elemHide.js
@@ -248,34 +248,41 @@ let ElemHide = exports.ElemHide =
return;
}
IO.writeToFile(styleURL.file, this._generateCSSContent(), function(e)
{
TimeLine.enter("ElemHide.apply() write callback");
this._applying = false;
- if (e && e.result == Cr.NS_ERROR_NOT_AVAILABLE)
- IO.removeFile(styleURL.file, function(e2) {});
+ // _generateCSSContent is throwing NS_ERROR_NOT_AVAILABLE to indicate that
+ // there are no filters. If that exception is passed through XPCOM we will
+ // see a proper exception here, otherwise a number.
+ let noFilters = (e == Cr.NS_ERROR_NOT_AVAILABLE || (e && e.result == Cr.NS_ERROR_NOT_AVAILABLE));
+ if (noFilters)
+ {
+ e = null;
+ IO.removeFile(styleURL.file, function(e) {});
+ }
else if (e)
Cu.reportError(e);
if (this._needsApply)
{
this._needsApply = false;
this.apply();
}
- else if (!e || e.result == Cr.NS_ERROR_NOT_AVAILABLE)
+ else if (!e)
{
ElemHide.isDirty = false;
ElemHide.unapply();
TimeLine.log("ElemHide.unapply() finished");
- if (!e)
+ if (!noFilters)
{
try
{
Utils.styleService.loadAndRegisterSheet(styleURL, Ci.nsIStyleSheetService.USER_SHEET);
ElemHide.applied = true;
}
catch (e)
{
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld