Skip to content

Commit

Permalink
Showing 7 changed files with 67 additions and 17 deletions.
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -8,7 +8,7 @@
"build-sign": "rm -rf web-ext-artifacts && cp README.md LICENSE src && node build-sign.js && npm run lint && npm test && web-ext sign --channel unlisted -s src && git checkout -- src/manifest.json && ncu",
"lint": "eslint src",
"test": "nyc --reporter=html --reporter=text mocha --reporter=dot ./test/setup.js test/*.test.js --timeout 60000",
"test-watch": "mocha ./test/setup.js test/*.test.js --watch --tmp-debug",
"test-watch": "mocha ./test/setup.js test/*.test.js --watch --inspect --tmp-debug",
"test-functional": "mocha ./test/functional/*.test.js --timeout 10000",
"check-dependencies": "ncu"
},
2 changes: 1 addition & 1 deletion src/background/log.js
Original file line number Diff line number Diff line change
@@ -24,4 +24,4 @@ class Log {

window.log = new Log;
// eslint-disable-next-line
window.debug = log.debug;
window.debug = log.debug;
24 changes: 19 additions & 5 deletions src/background/request.js
Original file line number Diff line number Diff line change
@@ -440,21 +440,35 @@ class Request {

for (let domainPattern in this.storage.local.preferences.isolation.domain) {
if (!this.isolation.matchDomainPattern(tab.url, domainPattern)) {
debug('[shouldIsolate] pattern not matching', tab.url, domainPattern);
continue;
}
const preferences = this.storage.local.preferences.isolation.domain[domainPattern].navigation;
if (!preferences) {

const patternPreferences = this.storage.local.preferences.isolation.domain[domainPattern];
if (patternPreferences.excluded) {
for (const excludedDomainPattern of Object.keys(patternPreferences.excluded)) {
if (!this.isolation.matchDomainPattern(request.url, excludedDomainPattern)) {
debug('[shouldIsolate] excluded domain pattern not matching', request.url, excludedDomainPattern);
continue;
}
debug('[shouldIsolate] not isolating because excluded domain pattern matches', request.url, excludedDomainPattern);
return false;
}
}

const navigationPreferences = patternPreferences.navigation;
if (!navigationPreferences) {
continue;
}
debug('[shouldIsolate] found pattern', domainPattern, preferences);
debug('[shouldIsolate] found pattern', domainPattern, navigationPreferences);

if (preferences.action === 'global') {
if (navigationPreferences.action === 'global') {
debug('[shouldIsolate] breaking because "global"');
break;
}

return await this.checkIsolationPreferenceAgainstUrl(
preferences.action, parsedTabURL.hostname, parsedRequestURL.hostname, tab
navigationPreferences.action, parsedTabURL.hostname, parsedRequestURL.hostname, tab
);
}

5 changes: 3 additions & 2 deletions src/background/storage.js
Original file line number Diff line number Diff line change
@@ -37,7 +37,8 @@ class Storage {
action: 'never',
container: 'default'
}
}
},
excluded: {}
},
domain: {},
mac: {
@@ -211,4 +212,4 @@ class Storage {
}
}

window.Storage = Storage;
window.Storage = Storage;
2 changes: 1 addition & 1 deletion src/ui/options.html
Original file line number Diff line number Diff line change
@@ -212,7 +212,7 @@ <h4><i class="dropdown icon"></i>
</div>
<div class="title">
<h4><i class="dropdown icon"></i>
Exclude Target Domains
Exclude Target/Link Domains
</h4>
</div>
<div class="ui segment content">
15 changes: 8 additions & 7 deletions src/ui/shared.js
Original file line number Diff line number Diff line change
@@ -116,7 +116,8 @@ const isolationDomainAddRule = async () => {
left: {
action: document.querySelector('#isolationDomainMouseClickLeft').value
}
}
},
excluded: isolationDomainExcludeDomains
};

await savePreferences();
@@ -165,12 +166,12 @@ window.updateIsolationDomains = () => {
'<strong>Mouse Clicks</strong><br>' +
`Middle: ${preferences.isolation.domain[domainPattern].mouseClick.middle.action} <br>` +
`Ctrl+Left: ${preferences.isolation.domain[domainPattern].mouseClick.ctrlleft.action} <br>` +
`Left: ${preferences.isolation.domain[domainPattern].mouseClick.left.action}</div> <br><br>`;
// '<strong>Excluded Target Domains</strong>:<br>' +
// (preferences.isolation.domain[domainPattern].excluded &&
// preferences.isolation.domain[domainPattern].excluded.length) ?
// `${preferences.isolation.domain[domainPattern].excluded.join('<br>')}` :
// 'No Target Domains excluded';
`Left: ${preferences.isolation.domain[domainPattern].mouseClick.left.action}</div><br>` +
'<strong>Excluded Target/Link Domains</strong>:<br>' +
(preferences.isolation.domain[domainPattern].excluded &&
Object.keys(preferences.isolation.domain[domainPattern].excluded).length > 0 ?
`${Object.keys(preferences.isolation.domain[domainPattern].excluded).join('<br>')}` :
'No Target/Link Domains excluded');
el.find('#infoDomainRule').popup({
html: domainRuleTooltip,
inline: true
34 changes: 34 additions & 0 deletions test/background.isolation.test.js
Original file line number Diff line number Diff line change
@@ -151,6 +151,40 @@ preferencesTestSet.map(preferences => { describe(`preferences: ${JSON.stringify(
browser.tabs.create.should.have.been.calledOnce;
});
});

describe('if the target domain is excluded', () => {
beforeEach(async () => {
switch (navigatingIn) {
case 'sametab.global':
case 'newtab.global':
background.storage.local.preferences.isolation.global.excluded['excluded.com'] = {};
break;

case 'sametab.perdomain':
case 'newtab.perdomain':
background.storage.local.preferences.isolation.domain['example.com'] = defaultIsolationDomainPreferences;
background.storage.local.preferences.isolation.domain['example.com'].excluded['excluded.com'] = {};
break;
}

await navigateTo('https://excluded.com');
});

it('should not open a new Temporary Container', async () => {
switch (navigatingIn) {
case 'sametab.global':
case 'newtab.global':
// TODO: implement me
expect(true).to.be.true;
break;

case 'sametab.perdomain':
case 'newtab.perdomain':
browser.tabs.create.should.not.have.been.called;
break;
}
});
});
});

describe('navigating with preference "notsamedomain"', () => {

0 comments on commit 1d282b5

Please sign in to comment.