Skip to content
This repository has been archived by the owner on May 12, 2020. It is now read-only.

Commit

Permalink
Fix some lint errors
Browse files Browse the repository at this point in the history
  • Loading branch information
bbondy committed Mar 12, 2019
1 parent 262e989 commit ba76cab
Show file tree
Hide file tree
Showing 3 changed files with 40 additions and 40 deletions.
4 changes: 2 additions & 2 deletions scripts/check.js
Original file line number Diff line number Diff line change
Expand Up @@ -49,10 +49,10 @@ let p = Promise.reject(new Error('Usage: node check.js --location <location> --h

const ruleDiscovery = commander.discover && !commander.dat
const parseOptions = {
keepRuleText: !!ruleDiscovery,
keepRuleText: !!ruleDiscovery
}

if (commander.host && (commander.location || commander.list) || commander.stats) {
if ((commander.host && (commander.location || commander.list)) || commander.stats) {
p.catch(() => {})
if (commander.uuid) {
p = makeAdBlockClientFromListUUID(commander.uuid, parseOptions)
Expand Down
64 changes: 32 additions & 32 deletions test/js/matchingTest.js
Original file line number Diff line number Diff line change
Expand Up @@ -207,7 +207,7 @@ describe('matching', function () {
})
})

describe("Filters with unknown options are ignored", function () {
describe('Filters with unknown options are ignored', function () {
it('known unsupported options are not blocked', function () {
const client = new AdBlockClient()
client.parse('adv$ping')
Expand Down Expand Up @@ -317,145 +317,145 @@ describe('matching', function () {
})
})
describe('domain filtered rules', function () {
describe('All exclude domain rules', function() {
describe('All exclude domain rules', function () {
before(function () {
this.client = new AdBlockClient()
this.client.parse('wp-content/$domain=~aaaaa.com|~bbbbb.com|~ccccc.com')
})

it('filter has all anti domains but with different input domain should block', function () {
assert(this.client.matches('https://www.sportsnet.ca/wp-content/plugins',
FilterOptions.image, 'www.brianbondy.com'))
FilterOptions.image, 'www.brianbondy.com'))
})
it('filter has all anti domains and with a same input domain should not block', function () {
assert(!this.client.matches('https://www.sportsnet.ca/wp-content/plugins',
FilterOptions.image, 'aaaaa.com'))
FilterOptions.image, 'aaaaa.com'))
})
})
describe('All include domain rules', function() {
describe('All include domain rules', function () {
before(function () {
this.client = new AdBlockClient()
this.client.parse('wp-content/$domain=aaaaa.com|bbbbb.com|ccccc.com')
})
it('filter has all anti=false domains but with different input domain should not block', function () {
assert(!this.client.matches('https://www.sportsnet.ca/wp-content/plugins',
FilterOptions.image, 'www.brianbondy.com'))
FilterOptions.image, 'www.brianbondy.com'))
})
it('filter has all anti=false domains and with a same domain should not block', function () {
assert(this.client.matches('https://www.sportsnet.ca/wp-content/plugins',
FilterOptions.image, 'aaaaa.com'))
FilterOptions.image, 'aaaaa.com'))
})
})
describe('Rule with blocking parent domain and subdomain which is allowed', function() {
describe('Rule with blocking parent domain and subdomain which is allowed', function () {
before(function () {
this.client = new AdBlockClient()
this.client.parse('wp-content/$domain=example.com|~foo.example.com|x.com|y.com|z.com')
})
it('for test URL of unrelated domain should not match', function () {
assert(!this.client.matches('https://www.sportsnet.ca/wp-content/plugins',
FilterOptions.image, 'brianbondy.com'))
FilterOptions.image, 'brianbondy.com'))
})
it('for test URL of parent should block', function () {
assert(this.client.matches('https://www.sportsnet.ca/wp-content/plugins',
FilterOptions.image, 'example.com'))
FilterOptions.image, 'example.com'))
})
it('for test URL of subdomain should allow', function () {
assert(!this.client.matches('https://www.sportsnet.ca/wp-content/plugins',
FilterOptions.image, 'foo.example.com'))
FilterOptions.image, 'foo.example.com'))
})
it('for test URL of deeper subdomain should allow', function () {
assert(!this.client.matches('https://www.sportsnet.ca/wp-content/plugins',
FilterOptions.image, 'boo.foo.example.com'))
FilterOptions.image, 'boo.foo.example.com'))
})
it('for test URL of subdomain of top level rule should block', function () {
assert(this.client.matches('https://www.sportsnet.ca/wp-content/plugins',
FilterOptions.image, 'boo.example.com'))
FilterOptions.image, 'boo.example.com'))
})
})
describe('Rule with anti-block parent domain and subdomain which is blocked', function() {
describe('Rule with anti-block parent domain and subdomain which is blocked', function () {
before(function () {
this.client = new AdBlockClient()
this.client.parse('wp-content/$domain=~example.com|foo.example.com|x.com|z.com|y.com')
})
it('for test URL of unrelated domain should not match', function () {
assert(!this.client.matches('https://www.sportsnet.ca/wp-content/plugins',
FilterOptions.image, 'brianbondy.com'))
FilterOptions.image, 'brianbondy.com'))
})
it('for test URL of parent should not block', function () {
assert(!this.client.matches('https://www.sportsnet.ca/wp-content/plugins',
FilterOptions.image, 'example.com'))
FilterOptions.image, 'example.com'))
})
it('for test URL of subdomain should block', function () {
assert(this.client.matches('https://www.sportsnet.ca/wp-content/plugins',
FilterOptions.image, 'foo.example.com'))
FilterOptions.image, 'foo.example.com'))
})
it('for test URL of deeper subdomain should block', function () {
assert(this.client.matches('https://www.sportsnet.ca/wp-content/plugins',
FilterOptions.image, 'boo.foo.example.com'))
FilterOptions.image, 'boo.foo.example.com'))
})
it('for test URL of subdomain of top level rule should allow', function () {
assert(!this.client.matches('https://www.sportsnet.ca/wp-content/plugins',
FilterOptions.image, 'boo.example.com'))
FilterOptions.image, 'boo.example.com'))
})
})

describe('Three level deep rules', function() {
describe('Three level deep rules', function () {
before(function () {
this.client = new AdBlockClient()
this.client.parse('wp-content/$domain=example.com|~brave.example.com|foo.brave.example.com')
})
it('for test URL of unrelated domain should not match', function () {
assert(!this.client.matches('https://www.sportsnet.ca/wp-content/plugins',
FilterOptions.image, 'brianbondy.com'))
FilterOptions.image, 'brianbondy.com'))
})
it('for test URL of parent should block', function () {
assert(this.client.matches('https://www.sportsnet.ca/wp-content/plugins',
FilterOptions.image, 'example.com'))
FilterOptions.image, 'example.com'))
})
it('for test URL of exception subdomain should allow', function () {
assert(!this.client.matches('https://www.sportsnet.ca/wp-content/plugins',
FilterOptions.image, 'brave.example.com'))
FilterOptions.image, 'brave.example.com'))
})
it('for test URL of deeper subdomain should block', function () {
assert(this.client.matches('https://www.sportsnet.ca/wp-content/plugins',
FilterOptions.image, 'foo.brave.example.com'))
FilterOptions.image, 'foo.brave.example.com'))
})
})
describe('Three level deep rules reversed', function() {
describe('Three level deep rules reversed', function () {
before(function () {
this.client = new AdBlockClient()
this.client.parse('wp-content/$domain=~example.com|brave.example.com|~foo.brave.example.com')
})
it('for test URL of unrelated domain should not match since there is a blocking domain', function () {
assert(!this.client.matches('https://www.sportsnet.ca/wp-content/plugins',
FilterOptions.image, 'brianbondy.com'))
FilterOptions.image, 'brianbondy.com'))
})
it('for test URL of parent should allow', function () {
assert(!this.client.matches('https://www.sportsnet.ca/wp-content/plugins',
FilterOptions.image, 'example.com'))
FilterOptions.image, 'example.com'))
})
it('for test URL of exception subdomain should block', function () {
assert(this.client.matches('https://www.sportsnet.ca/wp-content/plugins',
FilterOptions.image, 'brave.example.com'))
FilterOptions.image, 'brave.example.com'))
})
it('for test URL of deeper subdomain should allow', function () {
assert(!this.client.matches('https://www.sportsnet.ca/wp-content/plugins',
FilterOptions.image, 'foo.brave.example.com'))
FilterOptions.image, 'foo.brave.example.com'))
})
})

describe('first-party host', function() {
describe('first-party host', function () {
before(function () {
this.client = new AdBlockClient()
this.client.parse('analytics.brave.com^\n@@https://analytics.*/piwik.$~third-party')
})
it('for same host finds exception', function () {
assert(!this.client.matches('https://analytics.brave.com/piwik.js',
FilterOptions.image, 'analytics.brave.com'))
FilterOptions.image, 'analytics.brave.com'))
})
it('for same diff host does not find exception', function () {
assert(this.client.matches('https://analytics.brave.com/piwik.js',
FilterOptions.image, 'batcommunity.org'))
FilterOptions.image, 'batcommunity.org'))
})
it('findMatchingFilters for same host finds exception', function () {
const queryResult = this.client.findMatchingFilters('https://analytics.brave.com/piwik.js', FilterOptions.script, 'analytics.brave.com')
Expand Down
12 changes: 6 additions & 6 deletions test/js/serializationTest.js
Original file line number Diff line number Diff line change
Expand Up @@ -54,14 +54,14 @@ describe('serialization', function () {
assert(!this.data.toString().includes('Adblock Plus'))
})

describe("deserializing input", function () {
describe('deserializing input', function () {
it('does not throw on valid input', function () {
const client = new AdBlockClient()
client.deserialize(this.data)
})

it('throws on invalid input', function () {
const badInput = "not-good-data"
const badInput = 'not-good-data'
let caughtError = false
const newClient = new AdBlockClient()
// Check to make sure the below doesn't throw
Expand All @@ -73,22 +73,22 @@ describe('serialization', function () {
assert(caughtError)
})
})
describe("tags", function () {
describe('tags', function () {
it('preserves filter tags', function () {
const client = new AdBlockClient()
client.parse("testfilter$third-party,tag=blah");
client.parse('testfilter$third-party,tag=blah')
const filters1 = client.getFilters('filters')
console.log('filters1', filters1)
assert.equal(filters1.length, 1)
assert.equal(filters1[0].tag, "blah")
assert.equal(filters1[0].tag, 'blah')

const data = client.serialize()
const client2 = new AdBlockClient()
client2.deserialize(data)
const filters2 = client2.getFilters('filters')
console.log('filters2', filters2)
assert.equal(filters2.length, 1)
assert.equal(filters2[0].tag, "blah")
assert.equal(filters2[0].tag, 'blah')
})
})
})

0 comments on commit ba76cab

Please sign in to comment.