Skip to content

Commit e0e9657

Browse files
committed
Bug 1972830 - [marionette] Add support to interact with CHIPS cookies - r=anti-tracking-reviewers,webdriver-reviewers,timhuang,Sasha
Differential Revision: https://phabricator.services.mozilla.com/D254249 UltraBlame original commit: 38d3dab5d8c8f0b3adfea3cc94a8cf7567da2071
1 parent f9143a5 commit e0e9657

File tree

5 files changed

+26
-19
lines changed

5 files changed

+26
-19
lines changed

remote/marionette/cookie.sys.mjs

Lines changed: 15 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -274,14 +274,17 @@ cookie.remove = function (toDelete) {
274274
*
275275
* @param {string} host
276276
* Hostname to retrieve cookies for.
277+
* @param {BrowsingContext=} [browsingContext=undefined] browsingContext
278+
* The BrowsingContext that is reading these cookies.
279+
* Used to get the correct partitioned cookies.
277280
* @param {string=} [currentPath="/"] currentPath
278281
* Optionally filter the cookies for ``host`` for the specific path.
279282
* Defaults to ``/``, meaning all cookies for ``host`` are included.
280283
*
281284
* @returns {Iterable.<Cookie>}
282285
* Iterator.
283286
*/
284-
cookie.iter = function* (host, currentPath = "/") {
287+
cookie.iter = function* (host, browsingContext = undefined, currentPath = "/") {
285288
lazy.assert.string(
286289
host,
287290
lazy.pprint`Expected "host" to be a string, got ${host}`
@@ -294,6 +297,17 @@ cookie.iter = function* (host, currentPath = "/") {
294297
const isForCurrentPath = path => currentPath.includes(path);
295298

296299
let cookies = cookie.manager.getCookiesFromHost(host, {});
300+
if (browsingContext) {
301+
let partitionedOriginAttributes = {
302+
partitionKey:
303+
browsingContext.currentWindowGlobal?.cookieJarSettings?.partitionKey,
304+
};
305+
let cookiesPartitioned = cookie.manager.getCookiesFromHost(
306+
host,
307+
partitionedOriginAttributes
308+
);
309+
cookies.push(...cookiesPartitioned);
310+
}
297311
for (let cookie of cookies) {
298312
// take the hostname and progressively shorten
299313
let hostname = host;

remote/marionette/driver.sys.mjs

Lines changed: 11 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2458,7 +2458,7 @@ GeckoDriver.prototype.getCookies = async function () {
24582458
await this._handleUserPrompts();
24592459

24602460
let { hostname, pathname } = this._getCurrentURL({ top: false });
2461-
return [...lazy.cookie.iter(hostname, pathname)];
2461+
return [...lazy.cookie.iter(hostname, this.getBrowsingContext(), pathname)];
24622462
};
24632463

24642464
/**
@@ -2477,7 +2477,11 @@ GeckoDriver.prototype.deleteAllCookies = async function () {
24772477
await this._handleUserPrompts();
24782478

24792479
let { hostname, pathname } = this._getCurrentURL({ top: false });
2480-
for (let toDelete of lazy.cookie.iter(hostname, pathname)) {
2480+
for (let toDelete of lazy.cookie.iter(
2481+
hostname,
2482+
this.getBrowsingContext(),
2483+
pathname
2484+
)) {
24812485
lazy.cookie.remove(toDelete);
24822486
}
24832487
};
@@ -2502,7 +2506,11 @@ GeckoDriver.prototype.deleteCookie = async function (cmd) {
25022506
cmd.parameters.name,
25032507
lazy.pprint`Expected "name" to be a string, got ${cmd.parameters.name}`
25042508
);
2505-
for (let c of lazy.cookie.iter(hostname, pathname)) {
2509+
for (let c of lazy.cookie.iter(
2510+
hostname,
2511+
this.getBrowsingContext(),
2512+
pathname
2513+
)) {
25062514
if (c.name === name) {
25072515
lazy.cookie.remove(c);
25082516
}
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,3 @@
11
[partitioned-cookies-samesite-attribute.https.html]
2-
[In top-level contexts, partitioned cookies default to the same SameSite attribute as unpartitioned cookies.]
3-
expected:
4-
if nightly_build: FAIL
5-
6-
[In top-level contexts, partitioned cookies can be set with all SameSite attributes.]
7-
expected:
8-
if nightly_build: FAIL
9-
102
[In embedded cross-site contexts, partitioned cookies can only be set with explicit SameSite=None]
113
expected: FAIL

testing/web-platform/meta/infrastructure/testdriver/get_all_cookies.sub.https.html.ini

Lines changed: 0 additions & 4 deletions
This file was deleted.
Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,3 @@
11
[get_named_cookie.sub.https.html]
22
expected:
33
if (os == "android") and fission: [OK, TIMEOUT]
4-
[Get Named HTTPS cookie]
5-
expected:
6-
if nightly_build: FAIL

0 commit comments

Comments
 (0)