Bug 1839918 - Update tests for nsICookieNotification. r=cookie-reviewers,sessionstore-reviewers,bvandersloot,valentin

Depends on D185301

Differential Revision: https://phabricator.services.mozilla.com/D185302
This commit is contained in:
Paul Zuehlcke
2023-09-18 11:55:09 +00:00
parent 6f511ac960
commit 2bfd7c338f
9 changed files with 53 additions and 45 deletions

View File

@@ -28,12 +28,13 @@ function waitForNewCookie({ host, name, value }) {
info(`waiting for cookie ${name}=${value} from ${host}...`);
return new Promise(resolve => {
Services.obs.addObserver(function observer(subj, topic, data) {
if (data != "added") {
Services.obs.addObserver(function observer(subj, topic) {
let notification = subj.QueryInterface(Ci.nsICookieNotification);
if (notification.action != Ci.nsICookieNotification.COOKIE_ADDED) {
return;
}
let cookie = subj.QueryInterface(Ci.nsICookie);
let cookie = notification.cookie.QueryInterface(Ci.nsICookie);
if (cookie.host == host && cookie.name == name && cookie.value == value) {
ok(true, "cookie added by the cookie service");
Services.obs.removeObserver(observer, topic);

View File

@@ -113,8 +113,9 @@ async function openTabInUserContext(userContextId) {
function waitForNewCookie() {
return new Promise(resolve => {
Services.obs.addObserver(function observer(subj, topic, data) {
if (data == "added") {
Services.obs.addObserver(function observer(subj, topic) {
let notification = subj.QueryInterface(Ci.nsICookieNotification);
if (notification.action == Ci.nsICookieNotification.COOKIE_ADDED) {
Services.obs.removeObserver(observer, topic);
resolve();
}