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

Unified Diff: chrome/content/tests/filterClasses.js

Issue 29345397: Issue 4092 - Adapt unit tests for changes to InvalidFilter.reason (Closed)
Patch Set: Created May 31, 2016, 10:14 a.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: chrome/content/tests/filterClasses.js
===================================================================
--- a/chrome/content/tests/filterClasses.js
+++ b/chrome/content/tests/filterClasses.js
@@ -6,17 +6,17 @@
{
// Filter serialization only writes out essential properties, need to do a full serialization here
let result = [];
result.push("text=" + filter.text);
if (filter instanceof InvalidFilter)
{
result.push("type=invalid");
if (filter.reason)
- result.push("hasReason");
+ result.push("reason=" + filter.reason);
}
else if (filter instanceof CommentFilter)
{
result.push("type=comment");
}
else if (filter instanceof ActiveFilter)
{
result.push("disabled=" + filter.disabled);
@@ -177,36 +177,24 @@
{
compareFilter("!asdf", ["type=comment", "text=!asdf"]);
compareFilter("!foo#bar", ["type=comment", "text=!foo#bar"]);
compareFilter("!foo##bar", ["type=comment", "text=!foo##bar"]);
});
test("Invalid filters", function()
{
- compareFilter("/??/", ["type=invalid", "text=/??/", "hasReason"]);
-
- compareFilter("#dd(asd)(ddd)", ["type=invalid", "text=#dd(asd)(ddd)", "hasReason"]);
- {
- let result = Filter.fromText("#dd(asd)(ddd)").reason;
- equal(result, Utils.getString("filter_elemhide_duplicate_id"), "#dd(asd)(ddd).reason");
- }
-
- compareFilter("#*", ["type=invalid", "text=#*", "hasReason"]);
- {
- let result = Filter.fromText("#*").reason;
- equal(result, Utils.getString("filter_elemhide_nocriteria"), "#*.reason");
- }
+ compareFilter("/??/", ["type=invalid", "text=/??/", "reason=filter_invalid_regexp"]);
+ compareFilter("#dd(asd)(ddd)", ["type=invalid", "text=#dd(asd)(ddd)", "reason=filter_elemhide_duplicate_id"]);
+ compareFilter("#*", ["type=invalid", "text=#*", "reason=filter_elemhide_nocriteria"]);
function compareCSSRule(domains)
{
let filterText = domains + "##[-abp-properties='abc']";
- compareFilter(filterText, ["type=invalid", "text=" + filterText, "hasReason"]);
- let reason = Filter.fromText(filterText).reason;
- equal(reason, Utils.getString("filter_cssproperty_nodomain"), filterText + ".reason");
+ compareFilter(filterText, ["type=invalid", "text=" + filterText, "reason=filter_cssproperty_nodomain"]);
}
compareCSSRule("");
compareCSSRule("~foo.com");
compareCSSRule("~foo.com,~bar.com");
compareCSSRule("foo");
compareCSSRule("~foo.com,bar");
});
@@ -260,22 +248,22 @@
compareFilter("@@|ftp://bla$~script,~other", ["type=whitelist", "text=@@|ftp://bla$~script,~other", "regexp=^ftp\\:\\/\\/bla", "contentType=" + (defaultTypes & ~(t.SCRIPT | t.OTHER))]);
compareFilter("@@bla$~script,~other,document", ["type=whitelist", "text=@@bla$~script,~other,document", "regexp=bla", "contentType=" + (defaultTypes & ~(t.SCRIPT | t.OTHER) | t.DOCUMENT)]);
compareFilter("@@bla$~script,~other,~document", ["type=whitelist", "text=@@bla$~script,~other,~document", "regexp=bla", "contentType=" + (defaultTypes & ~(t.SCRIPT | t.OTHER))]);
compareFilter("@@bla$document", ["type=whitelist", "text=@@bla$document", "regexp=bla", "contentType=" + t.DOCUMENT]);
compareFilter("@@bla$~script,~other,elemhide", ["type=whitelist", "text=@@bla$~script,~other,elemhide", "regexp=bla", "contentType=" + (defaultTypes & ~(t.SCRIPT | t.OTHER) | t.ELEMHIDE)]);
compareFilter("@@bla$~script,~other,~elemhide", ["type=whitelist", "text=@@bla$~script,~other,~elemhide", "regexp=bla", "contentType=" + (defaultTypes & ~(t.SCRIPT | t.OTHER))]);
compareFilter("@@bla$elemhide", ["type=whitelist", "text=@@bla$elemhide", "regexp=bla", "contentType=" + t.ELEMHIDE]);
- compareFilter("@@bla$~script,~other,donottrack", ["type=invalid", "text=@@bla$~script,~other,donottrack", "hasReason"]);
- compareFilter("@@bla$~script,~other,~donottrack", ["type=invalid", "text=@@bla$~script,~other,~donottrack", "hasReason"]);
- compareFilter("@@bla$donottrack", ["type=invalid", "text=@@bla$donottrack", "hasReason"]);
- compareFilter("@@bla$foobar", ["type=invalid", "text=@@bla$foobar", "hasReason"]);
- compareFilter("@@bla$image,foobar", ["type=invalid", "text=@@bla$image,foobar", "hasReason"]);
- compareFilter("@@bla$foobar,image", ["type=invalid", "text=@@bla$foobar,image", "hasReason"]);
+ compareFilter("@@bla$~script,~other,donottrack", ["type=invalid", "text=@@bla$~script,~other,donottrack", "reason=filter_unknown_option"]);
+ compareFilter("@@bla$~script,~other,~donottrack", ["type=invalid", "text=@@bla$~script,~other,~donottrack", "reason=filter_unknown_option"]);
+ compareFilter("@@bla$donottrack", ["type=invalid", "text=@@bla$donottrack", "reason=filter_unknown_option"]);
+ compareFilter("@@bla$foobar", ["type=invalid", "text=@@bla$foobar", "reason=filter_unknown_option"]);
+ compareFilter("@@bla$image,foobar", ["type=invalid", "text=@@bla$image,foobar", "reason=filter_unknown_option"]);
+ compareFilter("@@bla$foobar,image", ["type=invalid", "text=@@bla$foobar,image", "reason=filter_unknown_option"]);
});
test("Element hiding rules", function()
{
compareFilter("#ddd", ["type=elemhide", "text=#ddd", "selector=ddd"]);
compareFilter("#ddd(fff)", ["type=elemhide", "text=#ddd(fff)", "selector=ddd.fff,ddd#fff"]);
compareFilter("#ddd(foo=bar)(foo2^=bar2)(foo3*=bar3)(foo4$=bar4)", ["type=elemhide", "text=#ddd(foo=bar)(foo2^=bar2)(foo3*=bar3)(foo4$=bar4)", 'selector=ddd[foo="bar"][foo2^="bar2"][foo3*="bar3"][foo4$="bar4"]']);
compareFilter("#ddd(fff)(foo=bar)", ["type=elemhide", "text=#ddd(fff)(foo=bar)", 'selector=ddd.fff[foo="bar"],ddd#fff[foo="bar"]']);
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld