OLD | NEW |
1 /* | 1 /* |
2 * This file is part of Adblock Plus <https://adblockplus.org/>, | 2 * This file is part of Adblock Plus <https://adblockplus.org/>, |
3 * Copyright (C) 2006-2016 Eyeo GmbH | 3 * Copyright (C) 2006-2016 Eyeo GmbH |
4 * | 4 * |
5 * Adblock Plus is free software: you can redistribute it and/or modify | 5 * Adblock Plus is free software: you can redistribute it and/or modify |
6 * it under the terms of the GNU General Public License version 3 as | 6 * it under the terms of the GNU General Public License version 3 as |
7 * published by the Free Software Foundation. | 7 * published by the Free Software Foundation. |
8 * | 8 * |
9 * Adblock Plus is distributed in the hope that it will be useful, | 9 * Adblock Plus is distributed in the hope that it will be useful, |
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of | 10 * but WITHOUT ANY WARRANTY; without even the implied warranty of |
(...skipping 315 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
326 return; | 326 return; |
327 | 327 |
328 port.emitWithResponse("elemhideEnabled", { | 328 port.emitWithResponse("elemhideEnabled", { |
329 frames: getFrames(subject), | 329 frames: getFrames(subject), |
330 isPrivate: isPrivate(subject) | 330 isPrivate: isPrivate(subject) |
331 }).then(({ | 331 }).then(({ |
332 enabled, contentType, docDomain, thirdParty, location, filter, | 332 enabled, contentType, docDomain, thirdParty, location, filter, |
333 filterType | 333 filterType |
334 }) => | 334 }) => |
335 { | 335 { |
| 336 if (Cu.isDeadWrapper(subject)) |
| 337 { |
| 338 // We are too late, the window is gone already. |
| 339 return; |
| 340 } |
| 341 |
336 if (enabled) | 342 if (enabled) |
337 { | 343 { |
338 if (!this.sheet) | 344 if (!this.sheet) |
339 { | 345 { |
340 this.sheet = Utils.styleService.preloadSheet(this.styleURL, | 346 this.sheet = Utils.styleService.preloadSheet(this.styleURL, |
341 Ci.nsIStyleSheetService.USER_SHEET); | 347 Ci.nsIStyleSheetService.USER_SHEET); |
342 } | 348 } |
343 | 349 |
344 let utils = subject.QueryInterface(Ci.nsIInterfaceRequestor) | 350 let utils = subject.QueryInterface(Ci.nsIInterfaceRequestor) |
345 .getInterface(Ci.nsIDOMWindowUtils); | 351 .getInterface(Ci.nsIDOMWindowUtils); |
346 utils.addSheet(this.sheet, Ci.nsIStyleSheetService.USER_SHEET); | 352 try |
| 353 { |
| 354 utils.addSheet(this.sheet, Ci.nsIStyleSheetService.USER_SHEET); |
| 355 } |
| 356 catch (e) |
| 357 { |
| 358 // Ignore NS_ERROR_ILLEGAL_VALUE - it will be thrown if we try to add |
| 359 // the stylesheet multiple times to the same document (the observer |
| 360 // will be notified twice for some documents). |
| 361 if (e.result != Cr.NS_ERROR_ILLEGAL_VALUE) |
| 362 throw e; |
| 363 } |
347 } | 364 } |
348 else if (filter) | 365 else if (filter) |
349 { | 366 { |
350 RequestNotifier.addNodeData(subject.document, subject.top, { | 367 RequestNotifier.addNodeData(subject.document, subject.top, { |
351 contentType, docDomain, thirdParty, location, filter, filterType | 368 contentType, docDomain, thirdParty, location, filter, filterType |
352 }); | 369 }); |
353 } | 370 } |
354 }); | 371 }); |
355 } | 372 } |
356 }; | 373 }; |
357 observer.init(); | 374 observer.init(); |
OLD | NEW |