Skip to content
Open
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
Original file line number Diff line number Diff line change
Expand Up @@ -239,7 +239,7 @@
function runTest() {
setEnableFeature(true, function () {
testRunner.setStatisticsExpiredStatistic(originUnderTest,
30, // numberOfOperatingDaysPassed
400, // numberOfOperatingDaysPassed
true, // hasUserInteraction
false, // isScheduledForAllButCookieDataRemoval,
true, // isPrevalent
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@
testRunner.setStatisticsShouldClassifyResourcesBeforeDataRecordsRemoval(false);
testRunner.setStatisticsMinimumTimeBetweenDataRecordsRemoval(0);
await testRunner.statisticsProcessStatisticsAndDataRecords();
setTimeout("finishTest()", 1000);
setTimeout("finishTest()", 2000);
});
});
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,12 +7,12 @@ Check that script-writeable website data gets removed after a navigation with fi
1 day(s): LocalStorage entry does exist.
1 day(s): IDB entry does exist.

30 day(s): Client-side cookie does not exist.
30 day(s): Client-side persistent cookie does not exist.
30 day(s): HttpOnly cookie exists.
30 day(s): Regular server-side cookie exists.
30 day(s): LocalStorage entry does not exist.
30 day(s): IDB entry does not exist.
400 day(s): Client-side cookie does not exist.
400 day(s): Client-side persistent cookie does not exist.
400 day(s): HttpOnly cookie exists.
400 day(s): Regular server-side cookie exists.
400 day(s): LocalStorage entry does not exist.
400 day(s): IDB entry does not exist.


Resource load statistics:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
const serverSideCookieName = "server-side-cookie";
const clientSideCookieName = "client-side-cookie";
const clientSidePersistentCookieName = "client-side-persistent-cookie";
const targetOperationalDays = 30;
const targetOperationalDays = 400;

let currentOperationalDays = 1;

Expand All @@ -44,7 +44,7 @@
let cookies = internals.getCookies();
let potentialCookies = { "http-only-cookie": 1, "server-side-cookie": 1, "client-side-cookie": 1, "client-side-persistent-cookie": 1 };
if (!cookies.length)
testFailed(`${currentOperationalDays} day(s): script-accessible deletion: No cookies found.`);
addOutput(`${currentOperationalDays} day(s): script-accessible deletion: No cookies found.`);

for (let cookie of cookies) {
let cookieType;
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
Check that script-writeable website data does not get removed after a navigation with filtered link decoration from a prevalent resource but before the Long data removal period.

1 day(s): Client-side cookie exists.
1 day(s): Client-side persistent cookie exists.
1 day(s): HttpOnly cookie exists.
1 day(s): Regular server-side cookie exists.
1 day(s): LocalStorage entry does exist.
1 day(s): IDB entry does exist.

399 day(s): Client-side cookie exists.
399 day(s): Client-side persistent cookie exists.
399 day(s): HttpOnly cookie exists.
399 day(s): Regular server-side cookie exists.
399 day(s): LocalStorage entry does exist.
399 day(s): IDB entry does exist.


Resource load statistics:

Registrable domain: 127.0.0.1
hadUserInteraction: Yes
mostRecentUserInteraction: -1
grandfathered: No
TopFrameLinkDecorationsFrom:
localhost
DataRemovalFrequency: Long
isPrevalentResource: No
isVeryPrevalentResource: No
dataRecordsRemoved: 0
Registrable domain: localhost
hadUserInteraction: No
mostRecentUserInteraction: -1
grandfathered: No
DataRemovalFrequency: Never
isPrevalentResource: Yes
isVeryPrevalentResource: No
dataRecordsRemoved: 0
Original file line number Diff line number Diff line change
@@ -0,0 +1,301 @@
<!DOCTYPE html>
<html>
<head>
<script src="/cookies/resources/cookie-utilities.js"></script>
<script src="resources/util.js"></script>
</head>
<body onload="setTimeout('runTest()', 0)">
<div id="description">Check that script-writeable website data does not get removed after a navigation with filtered link decoration from a prevalent resource but before the Long data removal period.</div>
<br>
<div id="output"></div>
<br>
<script>
testRunner.waitUntilDone();
testRunner.dumpAsText();

const httpOnlyCookieName = "http-only-cookie";
const serverSideCookieName = "server-side-cookie";
const clientSideCookieName = "client-side-cookie";
const clientSidePersistentCookieName = "client-side-persistent-cookie";
const targetOperationalDays = 399;

let currentOperationalDays = 1;

function sortStringArray(a, b) {
a = a.toLowerCase();
b = b.toLowerCase();

return a > b ? 1 : b > a ? -1 : 0;
}

function addLinebreakToOutput() {
let element = document.createElement("br");
output.appendChild(element);
}

function addOutput(message) {
let element = document.createElement("div");
element.innerText = message;
output.appendChild(element);
}

function checkCookies() {
let unsortedTestPassedMessages = [];
let cookies = internals.getCookies();
let potentialCookies = { "http-only-cookie": 1, "server-side-cookie": 1, "client-side-cookie": 1, "client-side-persistent-cookie": 1 };
if (!cookies.length)
addOutput(`${currentOperationalDays} day(s): script-accessible deletion: No cookies found.`);

for (let cookie of cookies) {
let cookieType;
switch (cookie.name) {
case httpOnlyCookieName:
delete potentialCookies[httpOnlyCookieName];
cookieType = "HttpOnly";
break;
case serverSideCookieName:
delete potentialCookies[serverSideCookieName];
cookieType = "Regular server-side";
break;
case clientSideCookieName:
delete potentialCookies[clientSideCookieName];
cookieType = "Client-side";
break;
case clientSidePersistentCookieName:
delete potentialCookies[clientSidePersistentCookieName];
cookieType = "Client-side persistent";
break;
}
if (cookieType)
unsortedTestPassedMessages.push(`${currentOperationalDays} day(s): ${cookieType} cookie exists.`);
}

for (let missingCookie in potentialCookies) {
let cookieType;
switch (missingCookie) {
case httpOnlyCookieName:
cookieType = "HttpOnly";
break;
case serverSideCookieName:
cookieType = "Regular server-side";
break;
case clientSideCookieName:
cookieType = "Client-side";
break;
case clientSidePersistentCookieName:
cookieType = "Client-side persistent";
break;
}
if (cookieType)
unsortedTestPassedMessages.push(`${currentOperationalDays} day(s): ${cookieType} cookie does not exist.`);
}

let sortedTestPassedMessages = unsortedTestPassedMessages.sort(sortStringArray);
for (let testPassedMessage of sortedTestPassedMessages) {
addOutput(testPassedMessage);
}
}

const dbName = "TestDatabase";

function createIDBDataStore(callback) {
let request = indexedDB.open(dbName);
request.onerror = function() {
addOutput("Couldn't create indexedDB.");
finishTest();
};
request.onupgradeneeded = function(event) {
let db = event.target.result;
let objStore = db.createObjectStore("test", {autoIncrement: true});
objStore.add("value");
callback();
}
}

const maxIntervals = 20;

let intervalCounterIDB;
let checkIDBCallback;
let checkIDBIntervalID;
let semaphoreIDBCheck = false;
function checkIDBDataStoreExists(shouldBeDeleted, callback) {
let request;
intervalCounterIDB = 0;
checkIDBCallback = callback;
if (!shouldBeDeleted) {
// Check until there is a IDB.
checkIDBIntervalID = setInterval(function() {
if (semaphoreIDBCheck)
return;
semaphoreIDBCheck = true;

if (++intervalCounterIDB >= maxIntervals) {
clearInterval(checkIDBIntervalID);
addOutput(`${currentOperationalDays} day(s): IDB entry does not exist (expected created).`);
semaphoreIDBCheck = false;
checkIDBCallback();
} else {
request = indexedDB.open(dbName);
request.onerror = function () {
clearInterval(checkIDBIntervalID);
addOutput("Couldn't open indexedDB.");
semaphoreIDBCheck = false;
finishTest();
};
request.onupgradeneeded = function () {
// Let the next interval check again.
semaphoreIDBCheck = false;
};
request.onsuccess = function () {
clearInterval(checkIDBIntervalID);
addOutput(`${currentOperationalDays} day(s): IDB entry does exist.`);
semaphoreIDBCheck = false;
checkIDBCallback();
};
}
}, 200);
} else {
// Check until there is no IDB.
checkIDBIntervalID = setInterval(function () {
if (semaphoreIDBCheck)
return;
semaphoreIDBCheck = true;

if (++intervalCounterIDB >= maxIntervals) {
clearInterval(checkIDBIntervalID);
addOutput(`${currentOperationalDays} day(s): IDB entry checks exhausted (expected deleted).`);
semaphoreIDBCheck = false;
checkIDBCallback();
} else {
request = indexedDB.open(dbName);
request.onerror = function () {
clearInterval(checkIDBIntervalID);
addOutput("Couldn't open indexedDB.");
semaphoreIDBCheck = false;
finishTest();
};
request.onupgradeneeded = function () {
clearInterval(checkIDBIntervalID);
addOutput(`${currentOperationalDays} day(s): IDB entry does not exist.`);
semaphoreIDBCheck = false;
checkIDBCallback();
};
request.onsuccess = function () {
// Let the next interval check again.
semaphoreIDBCheck = false;
};
}
}, 200);
}
}

let intervalCounterLocalStorage;
let checkLocalStorageCallback;
let checkLocalStorageIntervalID;
const localStorageName = "test";
const localStorageValue = "value";
function checkLocalStorageExists(shouldBeDeleted, callback) {
intervalCounterLocalStorage = 0;
checkLocalStorageCallback = callback;
if (!shouldBeDeleted) {
// Check until there is LocalStorage.
checkLocalStorageIntervalID = setInterval(function() {
if (++intervalCounterLocalStorage >= maxIntervals) {
clearInterval(checkLocalStorageIntervalID);
let value = localStorage.getItem(localStorageName);
addOutput(`${currentOperationalDays} day(s): LocalStorage entry ${value === localStorageValue ? "does" : "does not"} exist (timed out).`);
checkLocalStorageCallback();
} else if (testRunner.isStatisticsHasLocalStorage(destinationOrigin)) {
clearInterval(checkLocalStorageIntervalID);
let value = localStorage.getItem(localStorageName);
addOutput(`${currentOperationalDays} day(s): LocalStorage entry ${value === localStorageValue ? "does" : "does not"} exist.`);
checkLocalStorageCallback();
}
}, 100);
} else {
// Check until there is no LocalStorage.
checkLocalStorageIntervalID = setInterval(function() {
if (++intervalCounterLocalStorage >= maxIntervals) {
clearInterval(checkLocalStorageIntervalID);
let value = localStorage.getItem(localStorageName);
addOutput(`${currentOperationalDays} day(s): LocalStorage entry ${value === localStorageValue ? "does" : "does not"} exist (timed out).`);
checkLocalStorageCallback();
} else if (!testRunner.isStatisticsHasLocalStorage(destinationOrigin)) {
clearInterval(checkLocalStorageIntervalID);
let value = localStorage.getItem(localStorageName);
addOutput(`${currentOperationalDays} day(s): LocalStorage entry ${value === localStorageValue ? "does" : "does not"} exist.`);
checkLocalStorageCallback();
}
}, 100);
}
}

async function writeWebsiteDataAndContinue() {
// Write cookies.
await fetch("/cookies/resources/set-http-only-cookie.py?cookieName=" + httpOnlyCookieName, { credentials: "same-origin" });
await fetch("/cookies/resources/setCookies.cgi", { headers: { "X-Set-Cookie": serverSideCookieName + "=1; path=/;" }, credentials: "same-origin" });
document.cookie = clientSideCookieName + "=1";
document.cookie = clientSidePersistentCookieName + "=1; max-age=18000";

// Write LocalStorage
localStorage.setItem(localStorageName, localStorageValue);

// Write IndexedDB.
createIDBDataStore(function () {
processWebsiteDataAndContinue();
});
}


async function processWebsiteDataAndContinue() {
await testRunner.statisticsProcessStatisticsAndDataRecords();
checkWebsiteDataAndContinue();
}

function setStatisticsForDomain(callback) {
testRunner.setStatisticsPrevalentResource(prevalentResourceOrigin, true, function() {
testRunner.setStatisticsCrossSiteLoadWithLinkDecoration(prevalentResourceOrigin, destinationOrigin, /* wasFiltered */ true);
callback();
});
}

let shouldBeDeleted = false;
function checkWebsiteDataAndContinue() {
checkCookies();
checkLocalStorageExists(shouldBeDeleted, function () {
checkIDBDataStoreExists(shouldBeDeleted, () => {
if (currentOperationalDays != targetOperationalDays) {
testRunner.clearStatisticsDataForDomain("127.0.0.1");
addLinebreakToOutput();
currentOperationalDays = targetOperationalDays;
testRunner.setStatisticsExpiredStatistic(destinationOrigin, currentOperationalDays, true, false, false, () => {
setStatisticsForDomain(() => {
processWebsiteDataAndContinue();
});
});
} else
finishTest();
});
});
}

async function finishTest() {
await resetCookiesITP();
testRunner.dumpResourceLoadStatistics();
setEnableFeature(false, function() {
testRunner.notifyDone();
});
}

const prevalentResourceOrigin = "http://localhost:8000";
const destinationOrigin = "http://127.0.0.1:8000";
function runTest() {
setEnableFeature(true, function () {
testRunner.setStatisticsHasHadUserInteraction(destinationOrigin, true, function() {
setStatisticsForDomain(writeWebsiteDataAndContinue);
});
});
}
</script>
</body>
</html>
Loading