Skip to content

Commit

Permalink
Add support for ad cookie checking (#158)
Browse files Browse the repository at this point in the history
  • Loading branch information
jonathanKingston authored Apr 27, 2023
1 parent a511abe commit 77da1f2
Show file tree
Hide file tree
Showing 4 changed files with 11 additions and 4 deletions.
4 changes: 3 additions & 1 deletion privacy-protections/storage-blocking/helpers/commonTests.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/* exported commonTests */
/* global cookieStore, THIRD_PARTY_TRACKER_ORIGIN, THIRD_PARTY_ORIGIN */
/* global cookieStore, THIRD_PARTY_TRACKER_ORIGIN, THIRD_PARTY_ORIGIN, THIRD_PARTY_AD_ORIGIN */

function generateCookieHeaderTest (namePrefix, origin, cookiename) {
return {
Expand Down Expand Up @@ -29,6 +29,8 @@ if (window.top === window.self) {
context = 'top';
} else if (document.location.origin === THIRD_PARTY_ORIGIN) {
context = 'thirdparty';
} else if (document.location.origin === THIRD_PARTY_AD_ORIGIN) {
context = 'thirdpartyAd';
} else if (document.location.origin === THIRD_PARTY_TRACKER_ORIGIN) {
context = 'thirdpartytracker';
}
Expand Down
3 changes: 2 additions & 1 deletion privacy-protections/storage-blocking/helpers/globals.js
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
/* exported THIRD_PARTY_ORIGIN,THIRD_PARTY_TRACKER_ORIGIN */
/* exported THIRD_PARTY_ORIGIN,THIRD_PARTY_TRACKER_ORIGIN,THIRD_PARTY_AD_ORIGIN */
const THIRD_PARTY_ORIGIN = 'https://good.third-party.site';
const THIRD_PARTY_TRACKER_ORIGIN = 'https://broken.third-party.site';
const THIRD_PARTY_AD_ORIGIN = 'https://convert.ad-company.site';
3 changes: 2 additions & 1 deletion privacy-protections/storage-blocking/main.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
/* globals commonTests,THIRD_PARTY_ORIGIN,THIRD_PARTY_TRACKER_ORIGIN */
/* globals commonTests,THIRD_PARTY_ORIGIN,THIRD_PARTY_TRACKER_ORIGIN,THIRD_PARTY_AD_ORIGIN */

const storeButton = document.querySelector('#store');
const retriveButton = document.querySelector('#retrive');
Expand Down Expand Up @@ -82,6 +82,7 @@ function create3pIframeTest (name, origin) {
const tests = [
create3pIframeTest('safe', THIRD_PARTY_ORIGIN),
create3pIframeTest('tracking', THIRD_PARTY_TRACKER_ORIGIN),
create3pIframeTest('ad', THIRD_PARTY_AD_ORIGIN),
{
id: 'browser cache',
store: (data) => {
Expand Down
5 changes: 4 additions & 1 deletion server.js
Original file line number Diff line number Diff line change
Expand Up @@ -73,11 +73,14 @@ function isPayHostname (req) {
// Handle internal redirects to adClickFlow directories
app.all('*', (req, res, next) => {
const AD_FLOW = '/adClickFlow';
const PRIVACY_PROTECTIONS = '/privacy-protections';
if (
// If we're not a ad click flow domain ignore.
!(isSearchHostname(req) || isAdHostname(req) || isPubHostname(req) || isPayHostname(req)) ||
// If we've already passed to the ad dir then ignore.
req.path.startsWith(AD_FLOW)
req.path.startsWith(AD_FLOW) ||
// If we're a privacy protection dir then ignore.
req.path.startsWith(PRIVACY_PROTECTIONS)
) {
next();
return;
Expand Down

0 comments on commit 77da1f2

Please sign in to comment.