-
Notifications
You must be signed in to change notification settings - Fork 27
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* Support modifying cookies * Add test for path
- Loading branch information
1 parent
d302d8d
commit 399ce49
Showing
7 changed files
with
140 additions
and
206 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
55 changes: 55 additions & 0 deletions
55
injected/integration-test/test-pages/webcompat/config/modify-cookies.json
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,55 @@ | ||
{ | ||
"unprotectedTemporary": [], | ||
"features": { | ||
"webCompat": { | ||
"exceptions": [], | ||
"state": "enabled", | ||
"settings": { | ||
"modifyCookies": { | ||
"state": "enabled", | ||
"changes": [] | ||
}, | ||
"domains": [ | ||
{ | ||
"domain": ["localhost", "privacy-test-pages.site"], | ||
"patchSettings": [ | ||
{ | ||
"op": "add", | ||
"path": "/modifyCookies/changes/-", | ||
"value": { | ||
"key": "keyToBeDeleted", | ||
"action": "delete" | ||
} | ||
}, | ||
{ | ||
"op": "add", | ||
"path": "/modifyCookies/changes/-", | ||
"value": { | ||
"key": "pathCookie", | ||
"action": "delete" | ||
} | ||
}, | ||
{ | ||
"op": "add", | ||
"path": "/modifyCookies/changes/-", | ||
"value": { | ||
"key": "pathCookieWithPath", | ||
"path": "/webcompat/pages/", | ||
"action": "delete" | ||
} | ||
}, | ||
{ | ||
"op": "add", | ||
"path": "/modifyCookies/changes/-", | ||
"value": { | ||
"key": "nonexistentKey", | ||
"action": "delete" | ||
} | ||
} | ||
] | ||
} | ||
] | ||
} | ||
} | ||
} | ||
} |
53 changes: 53 additions & 0 deletions
53
injected/integration-test/test-pages/webcompat/pages/modify-cookies.html
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,53 @@ | ||
<!DOCTYPE html> | ||
<html> | ||
<head> | ||
<meta charset="utf-8"> | ||
<meta name="viewport" content="width=device-width"> | ||
<title>Modify Cookies</title> | ||
<link rel="stylesheet" href="../../shared/style.css"> | ||
<script> | ||
// Current file path | ||
let path = '/webcompat/pages/' | ||
document.cookie = 'keyToBeDeleted="valueToBeDeleted"' | ||
document.cookie = 'pathCookie="valueToBeDeleted"; path=' + path | ||
document.cookie = 'pathCookieWithPath="valueToBeDeleted"; path=' + path | ||
document.cookie = 'otherKey="valueToRemain"' | ||
</script> | ||
</head> | ||
<body> | ||
<script src="../../shared/utils.js"></script> | ||
<p><a href="../index.html">[WebCompat]</a></p> | ||
|
||
<p>This page verifies that cookie modifications work properly given the <a href="../config/modify-cookies.json">config</a>. At this time, only deletion is supported.</p> | ||
|
||
<script> | ||
// Copy from: https://stackoverflow.com/a/2144404 | ||
function hasCookie(name){ | ||
return document.cookie.split(';').some(c => { | ||
return c.trim().startsWith(name + '='); | ||
}); | ||
} | ||
|
||
// eslint-disable-next-line no-undef | ||
test('Only specified cookies should be removed', async () => { | ||
const specifiedKey = hasCookie('keyToBeDeleted') | ||
const pathKey = hasCookie('pathCookie') | ||
const pathKey2 = hasCookie('pathCookie2') | ||
const pathKey3 = hasCookie('pathCookieWithPath') | ||
const nonexistentKey = hasCookie('nonexistentKey') | ||
const otherKey = hasCookie('otherKey') | ||
|
||
return [ | ||
{ name: 'specified cookie entry deleted', result: specifiedKey, expected: false }, | ||
{ name: 'specified cookie entry with path not deleted', result: pathKey, expected: true }, | ||
{ name: `specified cookie entry with correct path (${path}) deleted`, result: pathKey3, expected: false }, | ||
{ name: 'specified cookie entry that is not present on page load', result: nonexistentKey, expected: false }, | ||
{ name: 'other cookie entry untouched', result: otherKey, expected: true } | ||
]; | ||
}); | ||
|
||
// eslint-disable-next-line no-undef | ||
renderResults(); | ||
</script> | ||
</body> | ||
</html> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters