Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Various fixes for recent release #185

Merged
merged 6 commits into from
Jul 18, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
17 changes: 13 additions & 4 deletions selenium/integration_tests.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,15 +6,26 @@ const {newDriver, startApp, stopApp, firstPartyHost} = require('./utils'),
{cookieApp, fpcookie} = require("./cookies"),
{etagApp} = require('./etags');

async function sleep(ms) {
return new Promise(resolve => setTimeout(resolve, ms));
}

beforeEach(async function() {
this.driver = await newDriver();
await sleep(250);
});

afterEach(async function() {
await this.driver.quit();
});

describe('etag tests', function() {
beforeEach(async function() {
this.app = etagApp();
this.driver = await newDriver();
startApp(this.app);
});
afterEach(function() {
stopApp(this.app);
this.driver.quit();
});
it('blocks etags', async function() {
let {app, driver} = this;
Expand All @@ -31,12 +42,10 @@ describe('etag tests', function() {
describe('cookie tests', function() {
beforeEach(async function() {
this.app = cookieApp();
this.driver = await newDriver();
startApp(this.app);
});
afterEach(function() {
stopApp(this.app);
this.driver.quit();
});

it('blocks cookies', async function() {
Expand Down
7 changes: 5 additions & 2 deletions src/js/tabs.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
[(function(exports) {

const shim = require('./shim'), {URL, tabsGet, tabsQuery, tabsExecuteScript} = shim,
{REMOVE_ACTION, CONTENTSCRIPTS} = require('./constants'),
{TYPES, REMOVE_ACTION, CONTENTSCRIPTS} = require('./constants'),
{errorOccurred, Counter, listenerMixin, setTabIconActive, safeSetBadgeText, log} = require('./utils'),
{isThirdParty} = require('./domains/parties');

Expand Down Expand Up @@ -246,7 +246,10 @@ class Tabs {
return this.getTab(tabId).get(frameId);
}

isRequestThirdParty({tabId, initiator, urlObj: {hostname} = {}}) {
isRequestThirdParty({tabId, initiator, type, urlObj: {hostname} = {}}) {
if (type === TYPES.main_frame) {
return false;
}
if (typeof initiator !== 'undefined') {
return isThirdParty((new URL(initiator)).hostname, hostname);
}
Expand Down
4 changes: 4 additions & 0 deletions src/js/test/tabs_test.js
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,10 @@ describe('tabs.js', function() {
});
});
describe('#isRequestThirdParty', function() {
it('is first party if main_frame', function() {
let details = {type: 'main_frame'};
assert.isFalse(this.tabs.isRequestThirdParty(details));
});
it('no initiator', function() {
let details = {tabId: 1, urlObj: new URL(thirdParty)};
assert.isTrue(this.tabs.isRequestThirdParty(details));
Expand Down
13 changes: 10 additions & 3 deletions src/js/test/webrequest_test.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

const assert = require('chai').assert,
{WebRequest} = require('../webrequest'),
{NO_ACTION} = require('../constants'),
{Tabs} = require('../tabs'),
{Store} = require('../store'),
{details, clone, cookie, notCookie} = require('./testing_utils');
Expand Down Expand Up @@ -54,7 +55,8 @@ describe('webrequest.js', function() {
describe('#onBeforeSendHeaders', function() {
beforeEach(function() {
this.wr.onBeforeRequest(details.main_frame);
this.third_party = clone(details.main_frame);
this.main_frame = clone(details.main_frame);
this.third_party = clone(details.third_party);
this.third_party.url = 'https://third-party.com/';
})
it('removes cookies from thirdparty requests', function() {
Expand All @@ -64,7 +66,7 @@ describe('webrequest.js', function() {
it('does not effect first party cookies', function() {
let first_party = clone(details.main_frame);
first_party.requestHeaders = [cookie, notCookie];
assert.deepEqual(this.wr.onBeforeSendHeaders(first_party), {});
assert.deepEqual(this.wr.onBeforeSendHeaders(first_party), NO_ACTION);
})
it('does not effect thirdparty requests with no cookies', function() {
this.third_party.requestHeaders = [notCookie, notCookie];
Expand All @@ -76,9 +78,14 @@ describe('webrequest.js', function() {
describe('#onHeadersReceived', function() {
beforeEach(function() {
this.wr.onBeforeRequest(details.main_frame);
this.third_party = clone(details.main_frame);
this.first_party = clone(details.main_frame);
this.third_party = clone(details.third_party);
this.third_party.url = 'https://third-party.com/';
})
it('does not effect cookies on main_frame requests', function() {
this.first_party.responseHeaders = [cookie, notCookie];
assert.deepEqual(this.wr.onHeadersReceived(this.first_party), NO_ACTION);
});
it('removes cookies from thirdparty requests', function() {
this.third_party.responseHeaders = [cookie, notCookie];
assert.deepEqual(this.wr.onHeadersReceived(this.third_party), {responseHeaders: [notCookie]});
Expand Down
3 changes: 1 addition & 2 deletions src/manifest.json
Original file line number Diff line number Diff line change
Expand Up @@ -18,8 +18,7 @@
"webRequestBlocking",
"webNavigation",
"storage",
"cookies",
"privacy"
"cookies"
],
"icons": {
"48": "media/icon48.png",
Expand Down