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

Side by Side Diff: lib/cssInjection.js

Issue 29691627: Issue 242 - Do not disable user style sheets on unrelated errors (Closed) Base URL: https://hg.adblockplus.org/adblockpluschrome/
Patch Set: Catch all errors but mark userStyleSheetsSupported=false only for cssOrigin error Created Feb. 21, 2018, 3:14 p.m.
Left:
Right:
Use n/p to move between diff chunks; N/P to move between comments.
Jump to:
View unified diff | Download patch
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 62 matching lines...) Expand 10 before | Expand all | Expand 10 after
73 browser.tabs.insertCSS(tabId, { 73 browser.tabs.insertCSS(tabId, {
74 code: styleSheet, 74 code: styleSheet,
75 cssOrigin: "user", 75 cssOrigin: "user",
76 frameId, 76 frameId,
77 matchAboutBlank: true, 77 matchAboutBlank: true,
78 runAt: "document_start" 78 runAt: "document_start"
79 }); 79 });
80 } 80 }
81 catch (error) 81 catch (error)
82 { 82 {
83 userStyleSheetsSupported = false; 83 if (/\bcssOrigin\b/.test(error.message))
84 userStyleSheetsSupported = false;
85
86 return false;
84 } 87 }
85 88
86 return userStyleSheetsSupported; 89 return true;
87 } 90 }
88 91
89 function removeStyleSheet(tabId, frameId, styleSheet) 92 function removeStyleSheet(tabId, frameId, styleSheet)
90 { 93 {
91 if (!styleSheetRemovalSupported) 94 if (!styleSheetRemovalSupported)
92 return; 95 return;
93 96
94 browser.tabs.removeCSS(tabId, { 97 browser.tabs.removeCSS(tabId, {
95 code: styleSheet, 98 code: styleSheet,
96 cssOrigin: "user", 99 cssOrigin: "user",
(...skipping 76 matching lines...) Expand 10 before | Expand all | Expand 10 after
173 response.inlineEmulated = true; 176 response.inlineEmulated = true;
174 177
175 return response; 178 return response;
176 }); 179 });
177 180
178 port.on("elemhide.injectSelectors", (message, sender) => 181 port.on("elemhide.injectSelectors", (message, sender) =>
179 { 182 {
180 updateFrameStyles(sender.page.id, sender.frame.id, message.selectors, 183 updateFrameStyles(sender.page.id, sender.frame.id, message.selectors,
181 message.groupName); 184 message.groupName);
182 }); 185 });
OLDNEW
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld