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

Delta Between Two Patch Sets: lib/content/elemHideEmulation.js

Issue 29590629: Issue 5956 - Catch exception when enumerating stylesheets (Closed) Base URL: https://hg.adblockplus.org/adblockpluscore/
Left Patch Set: Created Oct. 27, 2017, 11:27 p.m.
Right Patch Set: Catch the exceptions inside too Created Oct. 30, 2017, 7:25 p.m.
Left:
Right:
Use n/p to move between diff chunks; N/P to move between comments.
Jump to:
Left: Side by side diff | Download
Right: Side by side diff | Download
« no previous file with change/comment | « no previous file | no next file » | no next file with change/comment »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
LEFTRIGHT
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-present eyeo GmbH 3 * Copyright (C) 2006-present 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 397 matching lines...) Expand 10 before | Expand all | Expand 10 after
408 let cssStyles = []; 408 let cssStyles = [];
409 409
410 let stylesheetOnlyChange = !!stylesheets; 410 let stylesheetOnlyChange = !!stylesheets;
411 if (!stylesheets) 411 if (!stylesheets)
412 stylesheets = this.document.styleSheets; 412 stylesheets = this.document.styleSheets;
413 413
414 try 414 try
415 { 415 {
416 for (let stylesheet of stylesheets) 416 for (let stylesheet of stylesheets)
417 { 417 {
418 // Explicitly ignore third-party stylesheets to ensure consistent behavi or 418 try
419 // between Firefox and Chrome. 419 {
420 if (!this.isSameOrigin(stylesheet)) 420 // Explicitly ignore third-party stylesheets to ensure consistent beha vior
kzar 2017/11/03 10:20:50 Nit: This line is too long, did you check the code
421 continue; 421 // between Firefox and Chrome.
422 422 if (!this.isSameOrigin(stylesheet))
423 let rules = stylesheet.cssRules;
424 if (!rules)
425 continue;
426
427 for (let rule of rules)
428 {
429 if (rule.type != rule.STYLE_RULE)
430 continue; 423 continue;
431 424
432 cssStyles.push(stringifyStyle(rule)); 425 let rules = stylesheet.cssRules;
426 if (!rules)
427 continue;
428
429 for (let rule of rules)
430 {
431 if (rule.type != rule.STYLE_RULE)
432 continue;
433
434 cssStyles.push(stringifyStyle(rule));
435 }
436 }
437 catch (e)
438 {
439 // On Firefox we seem to get a InvalidAccessError when
kzar 2017/11/03 10:20:50 Nit: "...get an...".
440 // accessing the stylesheet under some circumstances.
433 } 441 }
434 } 442 }
435 } 443 }
436 catch (e) 444 catch (e)
437 { 445 {
438 // Make sure to not interrupt.
439 // On Firefox we seem to get a InvalidAccessError when 446 // On Firefox we seem to get a InvalidAccessError when
kzar 2017/11/03 10:20:50 Maybe combine these two identical comments and add
440 // enumerating the stylesheets. 447 // enumerating the stylesheet under some circumstances.
441 } 448 }
442 449
443 let patterns = this.patterns.slice(); 450 let patterns = this.patterns.slice();
444 let pattern = null; 451 let pattern = null;
445 let generator = null; 452 let generator = null;
446 453
447 let processPatterns = () => 454 let processPatterns = () =>
448 { 455 {
449 let cycleStart = performance.now(); 456 let cycleStart = performance.now();
450 457
(...skipping 149 matching lines...) Expand 10 before | Expand all | Expand 10 after
600 characterData: true, 607 characterData: true,
601 subtree: true 608 subtree: true
602 } 609 }
603 ); 610 );
604 this.document.addEventListener("load", this.onLoad.bind(this), true); 611 this.document.addEventListener("load", this.onLoad.bind(this), true);
605 } 612 }
606 } 613 }
607 }; 614 };
608 615
609 exports.ElemHideEmulation = ElemHideEmulation; 616 exports.ElemHideEmulation = ElemHideEmulation;
LEFTRIGHT
« no previous file | no next file » | Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Toggle Comments ('s')

Powered by Google App Engine
This is Rietveld