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

Unified Diff: test/domainRestrictions.js

Issue 29333474: Issue 4125 - [emscripten] Convert filter classes to C++ (Closed)
Patch Set: Almost complete implementation, missing CSS property filters Created Jan. 20, 2016, 12:04 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 | « test.js ('k') | test/filterClasses.js » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: test/domainRestrictions.js
===================================================================
new file mode 100644
--- /dev/null
+++ b/test/domainRestrictions.js
@@ -0,0 +1,183 @@
+"use strict";
+
+let {Filter} = require("../lib/filterClassesNew");
+
+function testActive(test, text, domain, expectedActive, expectedOnlyDomain)
+{
+ let filter = Filter.fromText(text);
+ test.equal(filter.isActiveOnDomain(domain), expectedActive, text + " active on " + domain);
+ test.equal(filter.isActiveOnlyOnDomain(domain), expectedOnlyDomain, text + " only active on " + domain);
+ filter.delete();
+}
+
+exports.testUnrestrictedBlocking = function(test)
+{
+ testActive(test, "foo", null, true, false);
+ testActive(test, "foo", "com", true, false);
+ testActive(test, "foo", "example.com", true, false);
+ testActive(test, "foo", "example.com.", true, false);
+ testActive(test, "foo", "foo.example.com", true, false);
+ testActive(test, "foo", "mple.com", true, false);
+
+ test.done();
+};
+
+exports.unrestrictedHiding = function(test)
+{
+ testActive(test, "##foo", null, true, false);
+ testActive(test, "##foo", "com", true, false);
+ testActive(test, "##foo", "example.com", true, false);
+ testActive(test, "##foo", "example.com.", true, false);
+ testActive(test, "##foo", "foo.example.com", true, false);
+ testActive(test, "##foo", "mple.com", true, false);
+
+ test.done();
+};
+
+exports.testDomainRestrictedBlocking = function(test)
+{
+ testActive(test, "foo$domain=example.com", null, false, false);
+ testActive(test, "foo$domain=example.com", "com", false, true);
+ testActive(test, "foo$domain=example.com", "example.com", true, true);
+ testActive(test, "foo$domain=example.com", "example.com.", true, true);
+ testActive(test, "foo$domain=example.com.", "example.com", true, true);
+ testActive(test, "foo$domain=example.com.", "example.com.", true, true);
+ testActive(test, "foo$domain=example.com", "foo.example.com", true, false);
+ testActive(test, "foo$domain=example.com", "mple.com", false, false);
+
+ test.done();
+};
+
+exports.testDomainRestrictedHiding = function(test)
+{
+ testActive(test, "example.com##foo", null, false, false);
+ testActive(test, "example.com##foo", "com", false, true);
+ testActive(test, "example.com##foo", "example.com", true, true);
+ testActive(test, "example.com##foo", "example.com.", false, false);
+ testActive(test, "example.com.##foo", "example.com", false, false);
+ testActive(test, "example.com.##foo", "example.com.", true, true);
+ testActive(test, "example.com##foo", "foo.example.com", true, false);
+ testActive(test, "example.com##foo", "mple.com", false, false);
+
+ test.done();
+};
+
+exports.testDomainSubdomainBlocking = function(test)
+{
+ testActive(test, "foo$domain=example.com|foo.example.com", null, false, false);
+ testActive(test, "foo$domain=example.com|foo.example.com", "com", false, true);
+ testActive(test, "foo$domain=example.com|foo.example.com", "example.com", true, true);
+ testActive(test, "foo$domain=example.com|foo.example.com", "example.com.", true, true);
+ testActive(test, "foo$domain=example.com|foo.example.com", "foo.example.com", true, false);
+ testActive(test, "foo$domain=example.com|foo.example.com", "mple.com", false, false);
+
+ test.done();
+};
+
+exports.testDomainSubdomainHiding = function(test)
+{
+ testActive(test, "example.com,foo.example.com##foo", null, false, false);
+ testActive(test, "example.com,foo.example.com##foo", "com", false, true);
+ testActive(test, "example.com,foo.example.com##foo", "example.com", true, true);
+ testActive(test, "example.com,foo.example.com##foo", "example.com.", false, false);
+ testActive(test, "example.com,foo.example.com##foo", "foo.example.com", true, false);
+ testActive(test, "example.com,foo.example.com##foo", "mple.com", false, false);
+
+ test.done();
+};
+
+exports.testSubdomainExceptionBlocking = function(test)
+{
+ testActive(test, "foo$domain=~foo.example.com", null, true, false);
+ testActive(test, "foo$domain=~foo.example.com", "com", true, false);
+ testActive(test, "foo$domain=~foo.example.com", "example.com", true, false);
+ testActive(test, "foo$domain=~foo.example.com", "example.com.", true, false);
+ testActive(test, "foo$domain=~foo.example.com", "foo.example.com", false, false);
+ testActive(test, "foo$domain=~foo.example.com", "mple.com", true, false);
+
+ test.done();
+};
+
+exports.testSubdomainExceptionHiding = function(test)
+{
+ testActive(test, "~foo.example.com##foo", null, true, false);
+ testActive(test, "~foo.example.com##foo", "com", true, false);
+ testActive(test, "~foo.example.com##foo", "example.com", true, false);
+ testActive(test, "~foo.example.com##foo", "example.com.", true, false);
+ testActive(test, "~foo.example.com##foo", "foo.example.com", false, false);
+ testActive(test, "~foo.example.com##foo", "mple.com", true, false);
+
+ test.done();
+};
+
+exports.testDomainSubdomainExceptionBlocking = function(test)
+{
+ testActive(test, "foo$domain=example.com|~foo.example.com", null, false, false);
+ testActive(test, "foo$domain=example.com|~foo.example.com", "com", false, true);
+ testActive(test, "foo$domain=example.com|~foo.example.com", "example.com", true, true);
+ testActive(test, "foo$domain=example.com|~foo.example.com", "example.com.", true, true);
+ testActive(test, "foo$domain=example.com|~foo.example.com", "foo.example.com", false, false);
+ testActive(test, "foo$domain=example.com|~foo.example.com", "mple.com", false, false);
+
+ test.done();
+};
+
+exports.testDomainSubdomainExceptionHiding = function(test)
+{
+ testActive(test, "example.com,~foo.example.com##foo", null, false, false);
+ testActive(test, "example.com,~foo.example.com##foo", "com", false, true);
+ testActive(test, "example.com,~foo.example.com##foo", "example.com", true, true);
+ testActive(test, "example.com,~foo.example.com##foo", "example.com.", false, false);
+ testActive(test, "example.com,~foo.example.com##foo", "foo.example.com", false, false);
+ testActive(test, "example.com,~foo.example.com##foo", "mple.com", false, false);
+
+ test.done();
+};
+
+exports.testDomainTLDExceptionBlocking = function(test)
+{
+ testActive(test, "foo$domain=example.com|~com", null, false, false);
+ testActive(test, "foo$domain=example.com|~com", "com", false, true);
+ testActive(test, "foo$domain=example.com|~com", "example.com", true, true);
+ testActive(test, "foo$domain=example.com|~com", "example.com.", true, true);
+ testActive(test, "foo$domain=example.com|~com", "foo.example.com", true, false);
+ testActive(test, "foo$domain=example.com|~com", "mple.com", false, false);
+
+ test.done();
+};
+
+exports.testDomainTLDExceptionHiding = function(test)
+{
+ testActive(test, "example.com,~com##foo", null, false, false);
+ testActive(test, "example.com,~com##foo", "com", false, true);
+ testActive(test, "example.com,~com##foo", "example.com", true, true);
+ testActive(test, "example.com,~com##foo", "example.com.", false, false);
+ testActive(test, "example.com,~com##foo", "foo.example.com", true, false);
+ testActive(test, "example.com,~com##foo", "mple.com", false, false);
+
+ test.done();
+};
+
+exports.testUnrelatedDomainBlocking = function(test)
+{
+ testActive(test, "foo$domain=nnnnnnn.nnn", null, false, false);
+ testActive(test, "foo$domain=nnnnnnn.nnn", "com", false, false);
+ testActive(test, "foo$domain=nnnnnnn.nnn", "example.com", false, false);
+ testActive(test, "foo$domain=nnnnnnn.nnn", "example.com.", false, false);
+ testActive(test, "foo$domain=nnnnnnn.nnn", "foo.example.com", false, false);
+ testActive(test, "foo$domain=nnnnnnn.nnn", "mple.com", false, false);
+
+ test.done();
+};
+
+exports.testUnrelatedDomainHiding = function(test)
+{
+ testActive(test, "nnnnnnn.nnn##foo", null, false, false);
+ testActive(test, "nnnnnnn.nnn##foo", "com", false, false);
+ testActive(test, "nnnnnnn.nnn##foo", "example.com", false, false);
+ testActive(test, "nnnnnnn.nnn##foo", "example.com.", false, false);
+ testActive(test, "nnnnnnn.nnn##foo", "foo.example.com", false, false);
+ testActive(test, "nnnnnnn.nnn##foo", "mple.com", false, false);
+
+ test.done();
+};
« no previous file with comments | « test.js ('k') | test/filterClasses.js » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld