Source code

Revision control

Copy as Markdown

Other Tools

Test Info: Errors

<!DOCTYPE HTML>
<html>
<head>
<title>Service worker performance test: registration</title>
</head>
<script src="/tests/SimpleTest/SimpleTest.js"></script>
<script src="../utils.js"></script>
<script src="perfutils.js"></script>
<script>
"use strict";
// "Total" register() time, including process startup. We don't cause it all,
// but we're affected by it.
const REGISTRATION = "Registration";
// Targeted timing of regristration machinery.
const REGISTRATION_INTERNALS = "Registration Internals";
const ACTIVATION = "Activation";
const UNREGISTRATION = "Unregistration";
var journal = {};
journal[REGISTRATION] = [];
journal[REGISTRATION_INTERNALS] = [];
journal[ACTIVATION] = [];
journal[UNREGISTRATION] = [];
const ITERATIONS = 11;
var perfMetadata = {
owner: "DOM LWS",
name: "Service Worker Registration",
description: "Test registration, activation, and unregistration.",
options: {
default: {
perfherder: true,
perfherder_metrics: [
// Here, we can't use the constants defined above because perfherder
// grabs data from the parse tree.
{ name: "Registration", unit: "ms", shouldAlert: true },
{ name: "Registration Internals", unit: "ms", shouldAlert: true },
{ name: "Activation", unit: "ms", shouldAlert: true },
{ name: "Unregistration", unit: "ms", shouldAlert: true },
],
verbose: true,
manifest: "perftest.toml",
manifest_flavor: "plain",
},
},
};
add_task(async () => {
await SpecialPowers.pushPrefEnv({
set: [["dom.serviceWorkers.testing.enabled", true]]
});
async function measure() {
await startProfiler();
let begin_ts = performance.now();
let reg = await navigator.serviceWorker.register("sw_empty.js");
let reg_ts = performance.now();
await waitForState(reg.installing, "activated");
let act_ts = performance.now();
await reg.unregister();
let unreg_ts = performance.now();
let pdata = await stopProfiler();
let duration_ms = inspectProfile(pdata, [
"SWM Register",
"SWRJ AsyncExecute",
"InitServiceWorkerRegistrationParent",
"SWC Register",
"SWC Register (inner)"
]);
journal[REGISTRATION].push(reg_ts - begin_ts);
journal[REGISTRATION_INTERNALS].push(duration_ms);
journal[ACTIVATION].push(act_ts - reg_ts);
journal[UNREGISTRATION].push(unreg_ts - act_ts);
}
for (let i = 0; i < ITERATIONS; i++) {
await measure();
}
await SpecialPowers.popPrefEnv();
ok(true);
});
add_task(() => {
reportMetrics(journal);
});
</script>
<body>
</body>
</html>