/* This Source Code Form is subject to the terms of the Mozilla Public * License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
async function waitForH3(maxRetries, browser, url, commands, context) {
let attempt = 0; while (attempt < maxRetries) {
await commands.navigate(url);
// Get performance entries to check the protocol
let protocolInfo = await commands.js.run(
` // Get all performance entries const entries = performance.getEntries();
// Create an array to store the results const protocolInfo = entries.map(entry => ({
name: entry.name,
protocol: entry.nextHopProtocol,
}));
return protocolInfo;
`
);
// Log the protocol information
context.log.info("protocolInfo: " + JSON.stringify(protocolInfo));
// Check if the main document is using h3 protocol const normalizeUrl = url => url.replace(/\/+$/, ""); const isH3 = protocolInfo.some(
entry =>
normalizeUrl(entry.name) === normalizeUrl(url) &&
entry.protocol === "h3"
);
if (isH3) {
context.log.info("Protocol h3 detected!"); return; // Exit the function if h3 is found
}
// Increment the attempt counter and retry
attempt++;
context.log.info(
`Retry attempt ${attempt} - Protocol is not h3. Retrying...`
); if (browser === "firefox") { const script = `
Services.obs.notifyObservers(null, "net:cancel-all-connections");
Services.obs.notifyObservers(null, "network:reset-http3-excluded-list");
`;
commands.js.runPrivileged(script);
}
context.log.info("Waiting 3s to close connection...");
await commands.wait.byTime(3000);
}
}
async function waitForComplete(timeout, commands, context, id) {
let starttime = await commands.js.run(`return performance.now();`);
let status = "";
while (
(await commands.js.run(`return performance.now();`)) - starttime <
timeout &&
status != "error" &&
status != "success"
) {
await commands.wait.byTime(10);
status = await commands.js.run(
`return document.getElementById('${id}').innerHTML;`
);
if (status.startsWith("success")) {
status = "success";
}
// Start the test and wait for the upload to complete
let results = await waitForComplete(
1200000,
commands,
context, "upload_status"
);
let uploadTime = results.end - results.start;
// Store result in megabit/seconds
let uploadBandwidth = (file_size * 8) / ((uploadTime / 1000) * 1e6);
context.log.info( "upload results: " +
results.status + " duration: " +
uploadTime + "ms, uploadBandwidth: " +
uploadBandwidth + "Mbit/s"
);
accumulatedResults.push(uploadBandwidth);
} else {
context.log.error("Unsupported test type:" + testType);
}
});
if (browserName === "firefox") { const script = `
Services.obs.notifyObservers(null, "net:cancel-all-connections");
`;
commands.js.runPrivileged(script);
context.log.info("Waiting 3s to close connection...");
await commands.wait.byTime(3000);
} else {
context.log.info("Waiting 35s to close connection...");
await commands.wait.byTime(35000);
}
}
Die Informationen auf dieser Webseite wurden
nach bestem Wissen sorgfältig zusammengestellt. Es wird jedoch weder Vollständigkeit, noch Richtigkeit,
noch Qualität der bereit gestellten Informationen zugesichert.
Bemerkung:
Die farbliche Syntaxdarstellung ist noch experimentell.