diff options
author | Daniel Baumann <daniel.baumann@progress-linux.org> | 2024-04-19 00:47:55 +0000 |
---|---|---|
committer | Daniel Baumann <daniel.baumann@progress-linux.org> | 2024-04-19 00:47:55 +0000 |
commit | 26a029d407be480d791972afb5975cf62c9360a6 (patch) | |
tree | f435a8308119effd964b339f76abb83a57c29483 /dom/serviceworkers/test/performance/test_registration.html | |
parent | Initial commit. (diff) | |
download | firefox-26a029d407be480d791972afb5975cf62c9360a6.tar.xz firefox-26a029d407be480d791972afb5975cf62c9360a6.zip |
Adding upstream version 124.0.1.upstream/124.0.1
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to 'dom/serviceworkers/test/performance/test_registration.html')
-rw-r--r-- | dom/serviceworkers/test/performance/test_registration.html | 89 |
1 files changed, 89 insertions, 0 deletions
diff --git a/dom/serviceworkers/test/performance/test_registration.html b/dom/serviceworkers/test/performance/test_registration.html new file mode 100644 index 0000000000..d5abbf6775 --- /dev/null +++ b/dom/serviceworkers/test/performance/test_registration.html @@ -0,0 +1,89 @@ +<!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"; + + const REGISTRATION = "Registration"; + const ACTIVATION = "Activation"; + const UNREGISTRATION = "Unregistration"; + + var journal = []; + journal[REGISTRATION] = []; + journal[ACTIVATION] = []; + journal[UNREGISTRATION] = []; + + const ITERATIONS = 10; + + 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: "Activation", unit: "ms", shouldAlert: true }, + { name: "Unregistration", unit: "ms", shouldAlert: true }, + ], + verbose: true, + manifest: "perftest.toml", + manifest_flavor: "plain", + }, + }, + }; + + function create_iframe(url) { + return new Promise(function(res) { + let iframe = document.createElement("iframe"); + iframe.src = url; + iframe.onload = function() { res(iframe) } + document.body.appendChild(iframe); + }); + } + + add_task(async () => { + await SpecialPowers.pushPrefEnv({ + set: [["dom.serviceWorkers.testing.enabled", true]] + }); + + async function measure() { + 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(); + + journal[REGISTRATION].push(reg_ts - begin_ts); + 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> |