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

Unified Diff: chrome/content/ui/composer.js

Issue 29329450: Issue 3208 - Don`t use numerical content types outside nsIContentPolicy.shouldLoad (Closed)
Patch Set: Created Oct. 29, 2015, 12:23 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 | lib/contentPolicy.js » ('j') | lib/contentPolicy.js » ('J')
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: chrome/content/ui/composer.js
===================================================================
--- a/chrome/content/ui/composer.js
+++ b/chrome/content/ui/composer.js
@@ -10,19 +10,19 @@
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with Adblock Plus. If not, see <http://www.gnu.org/licenses/>.
*/
-let nodes = null;
-let item = null;
-let advancedMode = false;
+var nodes = null;
+var item = null;
+var advancedMode = false;
Thomas Greiner 2015/11/02 18:54:36 How is this change related to the issue?
Wladimir Palant 2015/11/03 11:26:49 It is only related to testing here. We have an eve
Thomas Greiner 2015/11/03 11:54:54 I see. In that case fine to fix it separately.
Wladimir Palant 2015/11/04 09:30:41 Ok, I removed that change here and created https:/
function init()
{
[nodes, item] = window.arguments;
E("filterType").value = (!item.filter || item.filter.disabled || item.filter instanceof WhitelistFilter ? "filterlist" : "whitelist");
E("customPattern").value = item.location;
@@ -114,28 +114,19 @@ function init()
E("patternGroup").value = "";
}
if (Prefs.composer_default == 0)
E("customPattern").focus();
else
E("patternGroup").focus();
let types = [];
- for (let type in Policy.localizedDescr)
- {
- types.push(parseInt(type));
- }
- types.sort(function(a, b) {
- if (a < b)
- return -1;
- else if (a > b)
- return 1;
- else
- return 0;
- });
+ for (let type of Policy.localizedDescr.keys())
+ types.push(type);
Thomas Greiner 2015/11/02 18:54:36 Detail: What about writing `let types = Array.from
Wladimir Palant 2015/11/03 11:26:49 Nice one, I didn't know about Array.from() yet. Ho
Thomas Greiner 2015/11/03 11:54:54 I agree that, with that change in mind, it's not n
+ types.sort();
let docDomain = item.docDomain;
let thirdParty = item.thirdParty;
if (docDomain)
docDomain = docDomain.replace(/^www\./i, "").replace(/\.+$/, "");
if (docDomain)
E("domainRestriction").value = docDomain;
@@ -143,24 +134,24 @@ function init()
E("thirdParty").hidden = !thirdParty;
E("firstParty").hidden = thirdParty;
let typeGroup = E("typeGroup");
let defaultTypes = RegExpFilter.prototype.contentType & ~RegExpFilter.typeMap.DOCUMENT;
let isDefaultType = (RegExpFilter.typeMap[item.typeDescr] & defaultTypes) != 0;
for (let type of types)
{
- if (type == Policy.type.ELEMHIDE)
+ if (type == "ELEMHIDE")
continue;
let typeNode = document.createElement("checkbox");
- typeNode.setAttribute("value", Policy.typeDescr[type].toLowerCase().replace(/\_/g, "-"));
- typeNode.setAttribute("label", Policy.localizedDescr[type].toLowerCase());
+ typeNode.setAttribute("value", type.toLowerCase().replace(/\_/g, "-"));
+ typeNode.setAttribute("label", Policy.localizedDescr.get(type).toLowerCase());
- let typeMask = RegExpFilter.typeMap[Policy.typeDescr[type]];
+ let typeMask = RegExpFilter.typeMap[type];
typeNode._defaultType = (typeMask & defaultTypes) != 0;
if ((isDefaultType && typeNode._defaultType) || (!isDefaultType && item.type == type))
typeNode.setAttribute("checked", "true");
if (item.type == type)
typeNode.setAttribute("disabled", "true");
typeNode.addEventListener("command", () => checkboxUpdated(typeNode), false);
typeGroup.appendChild(typeNode);
« no previous file with comments | « no previous file | lib/contentPolicy.js » ('j') | lib/contentPolicy.js » ('J')

Powered by Google App Engine
This is Rietveld