Skip to content

Commit

Permalink
Backed out changeset cc37d81df06c (bug 1870746) for causing failures …
Browse files Browse the repository at this point in the history
…on test_fetch.html
  • Loading branch information
Norisz Fay committed Jan 17, 2024
1 parent 06a0fb3 commit cec5b56
Show file tree
Hide file tree
Showing 5 changed files with 43 additions and 67 deletions.
4 changes: 0 additions & 4 deletions dom/serviceworkers/test/performance/perfutils.js
Original file line number Diff line number Diff line change
@@ -1,9 +1,5 @@
"use strict";

/*
* Perf test utilities.
*/

/**
* Given a map from test names to arrays of results, report perfherder metrics
* and log full results.
Expand Down
12 changes: 5 additions & 7 deletions dom/serviceworkers/test/performance/test_caching.html
Original file line number Diff line number Diff line change
Expand Up @@ -19,8 +19,7 @@
journal[CACHED] = [];
journal[NO_CACHE_AGAIN] = [];

const ITERATIONS = 11;
const SUB_ITERATIONS = 40;
const ITERATIONS = 10;

var perfMetadata = {
owner: "DOM LWS",
Expand Down Expand Up @@ -60,11 +59,10 @@

async function time_fetch(journal, iframe, filename) {
for (let i = 0; i < ITERATIONS; i++) {
let elapsed_ms = await iframe.contentWindow.time_fetch(filename,
SUB_ITERATIONS,
filename);
ok(elapsed_ms > 0, "time_fetch");
journal.push(elapsed_ms);
let result = await iframe.contentWindow.time_fetch(filename);
is(result.status, 200);
is(result.data, filename);
journal.push(result.elapsed_ms);
}
}

Expand Down
36 changes: 16 additions & 20 deletions dom/serviceworkers/test/performance/test_fetch.html
Original file line number Diff line number Diff line change
Expand Up @@ -27,8 +27,7 @@
journal[INTERCEPTED_XHR] = [];
journal[LIBERATED_XHR] = [];

const ITERATIONS = 11;
const SUB_ITERATIONS = 40;
const ITERATIONS = 10;

var perfMetadata = {
owner: "DOM LWS",
Expand Down Expand Up @@ -80,11 +79,12 @@

let iframe = await create_iframe("time_fetch.html");

let elapsed_ms = await iframe.contentWindow.time_fetch("target.txt", 1, "intercepted\n");
ok(elapsed_ms > 0, "cold time_fetch");
journal[COLD_FETCH].push(elapsed_ms);
let result = await iframe.contentWindow.time_fetch("target.txt");
is(result.status, 200);
is(result.data, "intercepted\n");
journal[COLD_FETCH].push(result.elapsed_ms);

ok(document.body.removeChild(iframe), "remove child iframe");
ok(document.body.removeChild(iframe), "Failed to remove child iframe");

await reg.unregister();
}
Expand All @@ -104,17 +104,15 @@
});

let iframe = await create_iframe("time_fetch.html");
let expected = sw_enabled ? "intercepted\n" : "target\n";

for (let i = 0; i < ITERATIONS; i++) {
let elapsed_ms = await iframe.contentWindow.time_fetch("target.txt",
SUB_ITERATIONS,
expected);
ok(elapsed_ms > 0, `time_fetch sw_enabled=${sw_enabled}`);
journal.push(elapsed_ms);
let result = await iframe.contentWindow.time_fetch("target.txt");
is(result.status, 200);
is(result.data, sw_enabled ? "intercepted\n" : "target\n");
journal.push(result.elapsed_ms);
}

ok(document.body.removeChild(iframe), "remove child iframe");
ok(document.body.removeChild(iframe), "Failed to remove child iframe");

await SpecialPowers.popPrefEnv();
}
Expand All @@ -140,17 +138,15 @@
});

let iframe = await create_iframe("time_fetch.html");
let expected = sw_enabled ? "intercepted\n" : "target\n";

for (let i = 0; i < ITERATIONS; i++) {
let elapsed_ms = await iframe.contentWindow.time_xhr("target.txt",
SUB_ITERATIONS,
expected);
ok(elapsed_ms > 0, `time_xhr sw_enabled=${sw_enabled}`);
journal.push(elapsed_ms);
let result = await iframe.contentWindow.time_xhr("target.txt");
is(result.status, 200);
is(result.data, sw_enabled ? "intercepted\n" : "target\n");
journal.push(result.elapsed_ms);
}

ok(document.body.removeChild(iframe), "remove child iframe");
ok(document.body.removeChild(iframe), "Failed to remove child iframe");

await SpecialPowers.popPrefEnv();
}
Expand Down
2 changes: 1 addition & 1 deletion dom/serviceworkers/test/performance/test_registration.html
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@
journal[ACTIVATION] = [];
journal[UNREGISTRATION] = [];

const ITERATIONS = 33;
const ITERATIONS = 10;

var perfMetadata = {
owner: "DOM LWS",
Expand Down
56 changes: 21 additions & 35 deletions dom/serviceworkers/test/performance/time_fetch.html
Original file line number Diff line number Diff line change
Expand Up @@ -5,44 +5,30 @@

"use strict";

function assert_is(a, b) {
// Throw if we fail to avoid repeated messages in the log
if (!Object.is(a, b)) {
throw new Error(`${a} != ${b}`);
}
}

async function time_fetch(url, num_fetches, expected) {
let elapsed_ms = 0;

while (num_fetches--) {
let start = performance.now();
let res = await fetch(url, {cache: "no-store"});
elapsed_ms += performance.now() - start;

assert_is(res.status, 200);
assert_is(await res.text(), expected);
}

return elapsed_ms;
async function time_fetch(url) {
let start = performance.now();
let res = await fetch(url);
let elapsed = performance.now() - start;

return {
elapsed_ms : elapsed,
status : res.status,
data : await res.text()
};
}

async function time_xhr(url, num_fetches, expected) {
url += "?" + new Date().getTime(); // cache-buster
let elapsed_ms = 0;

while (num_fetches--) {
let xhr = new XMLHttpRequest();
xhr.open("GET", url, false);
let start = performance.now();
xhr.send();
elapsed_ms += performance.now() - start;

assert_is(xhr.status, 200);
assert_is(xhr.responseText, expected);
async function time_xhr(url) {
let xhr = new XMLHttpRequest();
xhr.open("GET", url, false);
let start = performance.now();
xhr.send();
let elapsed = performance.now() - start;

return {
elapsed_ms : elapsed,
status : xhr.status,
data : xhr.responseText
}

return elapsed_ms;
}

</script>
Expand Down

0 comments on commit cec5b56

Please sign in to comment.