Bug 1753703 - P1: Loosen the HTTP activity check, r=necko-reviewers,dragana

The origin test assumes a very particular ordering of HTTP activities, which causes some interimentent failures.
The failed case shows that it's possible that a speculative connection completes before we dispatch the real transaction, so we got 6 http activites.

Differential Revision: https://phabricator.services.mozilla.com/D138892
This commit is contained in:
Kershaw Chang 2022-02-17 13:28:18 +00:00
Родитель 2fd5af8ef4
Коммит 3f8d21f6fa
1 изменённых файлов: 32 добавлений и 17 удалений

Просмотреть файл

@ -113,6 +113,37 @@ ActivityObserver.prototype = {
},
};
function checkHttpActivities(activites) {
let foundDNSAndSocket = false;
let foundSettingECH = false;
let foundConnectionCreated = false;
for (let activity of activites) {
switch (activity.subType) {
case Ci.nsIHttpActivityObserver.ACTIVITY_SUBTYPE_DNSANDSOCKET_CREATED:
case Ci.nsIHttpActivityObserver
.ACTIVITY_SUBTYPE_SPECULATIVE_DNSANDSOCKET_CREATED:
foundDNSAndSocket = true;
break;
case Ci.nsIHttpActivityDistributor.ACTIVITY_SUBTYPE_ECH_SET:
foundSettingECH = true;
break;
case Ci.nsIHttpActivityDistributor.ACTIVITY_SUBTYPE_CONNECTION_CREATED:
foundConnectionCreated = true;
break;
default:
break;
}
}
Assert.equal(foundDNSAndSocket, true, "Should have one DnsAndSock created");
Assert.equal(foundSettingECH, true, "Should have echConfig");
Assert.equal(
foundConnectionCreated,
true,
"Should have one connection created"
);
}
add_task(async function testConnectWithECH() {
const ECH_CONFIG_FIXED =
"AEn+DQBFTQAgACCKB1Y5SfrGIyk27W82xPpzWTDs3q72c04xSurDWlb9CgAEAAEAA2QWZWNoLXB1YmxpYy5leGFtcGxlLmNvbQAA";
@ -187,23 +218,7 @@ add_task(async function testConnectWithECH() {
let filtered = observer.activites.filter(
activity => activity.host === "ech-private.example.com"
);
Assert.equal(filtered.length, 3);
Assert.equal(
filtered[0].subType,
Ci.nsIHttpActivityObserver
.ACTIVITY_SUBTYPE_SPECULATIVE_DNSANDSOCKET_CREATED,
"Should have only one speculative DnsAndSock created"
);
Assert.equal(
filtered[1].subType,
Ci.nsIHttpActivityObserver.ACTIVITY_SUBTYPE_ECH_SET,
"Should have echConfig"
);
Assert.equal(
filtered[2].subType,
Ci.nsIHttpActivityObserver.ACTIVITY_SUBTYPE_CONNECTION_CREATED,
"Should have one connection created"
);
checkHttpActivities(filtered);
});
add_task(async function testEchRetry() {