Skip to content

Commit

Permalink
initial refactor
Browse files Browse the repository at this point in the history
  • Loading branch information
flashdesignory committed Nov 20, 2024
1 parent ace8c3b commit 147c38f
Show file tree
Hide file tree
Showing 2 changed files with 46 additions and 49 deletions.
34 changes: 27 additions & 7 deletions resources/test-invoker.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -71,15 +71,35 @@ class AsyncRAFTestInvoker extends BaseRAFTestInvoker {
_scheduleCallbacks(resolve) {
requestAnimationFrame(async () => {
await this._syncCallback();
requestAnimationFrame(() => {
setTimeout(() => {
this._asyncCallback();
setTimeout(async () => {
await this._reportCallback();
resolve();
}, 0);

let gotTimer = false;
let gotMessage = false;

const tryTriggerAsyncCallback = () => {
if (!gotTimer || !gotMessage)
return;

this._asyncCallback();
setTimeout(async () => {
await this._reportCallback();
resolve();
}, 0);
};

setTimeout(() => {
gotTimer = true;
tryTriggerAsyncCallback();
});

const mc = new MessageChannel();
mc.port1.onmessage = () => {
mc.port1.close();
mc.port2.close();

gotMessage = true;
tryTriggerAsyncCallback();
};
mc.port2.postMessage("speedometer");
});
}
}
Expand Down
61 changes: 19 additions & 42 deletions resources/tests.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -125,6 +125,7 @@ Suites.push({
name: "TodoMVC-JavaScript-ES5",
url: "resources/todomvc/vanilla-examples/javascript-es5/dist/index.html",
tags: ["todomvc"],
type: "async",
async prepare(page) {
(await page.waitForElement(".new-todo")).focus();
},
Expand Down Expand Up @@ -215,6 +216,7 @@ Suites.push({
name: "TodoMVC-JavaScript-ES6-Webpack-Complex-DOM",
url: "resources/todomvc/vanilla-examples/javascript-es6-webpack-complex/dist/index.html",
tags: ["todomvc", "complex", "complex-default"],
type: "async",
async prepare(page) {
const element = await page.waitForElement(".new-todo");
element.focus();
Expand Down Expand Up @@ -245,6 +247,7 @@ Suites.push({
name: "TodoMVC-WebComponents",
url: "resources/todomvc/vanilla-examples/javascript-web-components/dist/index.html",
tags: ["todomvc", "webcomponents"],
type: "async",
async prepare(page) {
await page.waitForElement("todo-app");
},
Expand Down Expand Up @@ -343,6 +346,7 @@ Suites.push({
name: "TodoMVC-React-Complex-DOM",
url: "resources/todomvc/architecture-examples/react-complex/dist/index.html#/home",
tags: ["todomvc", "complex", "complex-default"],
type: "async",
async prepare(page) {
const element = await page.waitForElement(".new-todo");
element.focus();
Expand Down Expand Up @@ -373,6 +377,7 @@ Suites.push({
name: "TodoMVC-React-Redux",
url: "resources/todomvc/architecture-examples/react-redux/dist/index.html",
tags: ["todomvc"],
type: "async",
async prepare(page) {
const element = await page.waitForElement(".new-todo");
element.focus();
Expand Down Expand Up @@ -432,6 +437,7 @@ Suites.push({
name: "TodoMVC-Backbone",
url: "resources/todomvc/architecture-examples/backbone/dist/index.html",
tags: ["todomvc"],
type: "async",
async prepare(page) {
await page.waitForElement("#appIsReady");
const newTodo = page.querySelector(".new-todo");
Expand Down Expand Up @@ -526,6 +532,7 @@ Suites.push({
name: "TodoMVC-Angular-Complex-DOM",
url: "resources/todomvc/architecture-examples/angular-complex/dist/index.html",
tags: ["todomvc", "complex", "complex-default"],
type: "async",
async prepare(page) {
const element = await page.waitForElement(".new-todo");
element.focus();
Expand Down Expand Up @@ -556,6 +563,7 @@ Suites.push({
name: "TodoMVC-Vue",
url: "resources/todomvc/architecture-examples/vue/dist/index.html",
tags: ["todomvc"],
type: "async",
async prepare(page) {
const element = await page.waitForElement(".new-todo");
element.focus();
Expand Down Expand Up @@ -617,6 +625,7 @@ Suites.push({
name: "TodoMVC-jQuery",
url: "resources/todomvc/architecture-examples/jquery/dist/index.html",
tags: ["todomvc"],
type: "async",
async prepare(page) {
await page.waitForElement("#appIsReady");
const newTodo = page.getElementById("new-todo");
Expand Down Expand Up @@ -704,6 +713,7 @@ Suites.push({
name: "TodoMVC-Preact-Complex-DOM",
url: "resources/todomvc/architecture-examples/preact-complex/dist/index.html#/home",
tags: ["todomvc", "complex", "complex-default"],
type: "async",
async prepare(page) {
const element = await page.waitForElement(".new-todo");
element.focus();
Expand Down Expand Up @@ -763,6 +773,7 @@ Suites.push({
name: "TodoMVC-Svelte-Complex-DOM",
url: "resources/todomvc/architecture-examples/svelte-complex/dist/index.html",
tags: ["todomvc", "complex", "complex-default"],
type: "async",
async prepare(page) {
const element = await page.waitForElement(".new-todo");
element.focus();
Expand Down Expand Up @@ -825,6 +836,7 @@ Suites.push({
name: "TodoMVC-Lit-Complex-DOM",
url: "resources/todomvc/architecture-examples/lit-complex/dist/index.html",
tags: ["todomvc", "webcomponents", "complex", "complex-default"],
type: "async",
async prepare(page) {
await page.waitForElement("todo-app");
},
Expand Down Expand Up @@ -857,49 +869,7 @@ Suites.push({
name: "NewsSite-Next",
url: "resources/newssite/news-next/dist/index.html#/home",
tags: ["newssite", "language"],
async prepare(page) {
await page.waitForElement("#navbar-dropdown-toggle");
},
tests: [
new BenchmarkTestStep("NavigateToUS", (page) => {
for (let i = 0; i < 25; i++) {
page.querySelector("#navbar-dropdown-toggle").click();
page.layout();
page.querySelector("#navbar-dropdown-toggle").click();
page.layout();
}
page.querySelector("#navbar-navlist-us-link").click();
page.layout();
}),
new BenchmarkTestStep("NavigateToWorld", (page) => {
for (let i = 0; i < 25; i++) {
page.querySelector("#navbar-dropdown-toggle").click();
page.layout();
page.querySelector("#navbar-dropdown-toggle").click();
page.layout();
}
page.querySelector("#navbar-navlist-world-link").click();
page.layout();
}),
new BenchmarkTestStep("NavigateToPolitics", (page) => {
for (let i = 0; i < 25; i++) {
page.querySelector("#navbar-dropdown-toggle").click();
page.layout();
page.querySelector("#navbar-dropdown-toggle").click();
page.layout();
}
page.querySelector("#navbar-navlist-politics-link").click();
page.layout();
}),
],
});

Suites.push({
name: "NewsSite-Next-Async",
url: "resources/newssite/news-next/dist/index.html#/home",
tags: ["experimental", "newssite", "language"],
type: "async",
disabled: true,
async prepare(page) {
await page.waitForElement("#navbar-dropdown-toggle");
},
Expand Down Expand Up @@ -941,6 +911,7 @@ Suites.push({
name: "NewsSite-Nuxt",
url: "resources/newssite/news-nuxt/dist/index.html",
tags: ["newssite"],
type: "async",
async prepare(page) {
await page.waitForElement("#navbar-dropdown-toggle");
},
Expand Down Expand Up @@ -982,6 +953,7 @@ Suites.push({
name: "Editor-CodeMirror",
url: "resources/editors/dist/codemirror.html",
tags: ["editor"],
type: "async",
async prepare(page) {},
tests: [
new BenchmarkTestStep("Long", (page) => {
Expand All @@ -1001,6 +973,7 @@ Suites.push({
name: "Editor-TipTap",
url: "resources/editors/dist/tiptap.html",
tags: ["editor"],
type: "async",
async prepare(page) {},
tests: [
new BenchmarkTestStep("Long", (page) => {
Expand All @@ -1020,6 +993,7 @@ Suites.push({
name: "Charts-observable-plot",
url: "resources/charts/dist/observable-plot.html",
tags: ["chart"],
type: "async",
async prepare(page) {},
tests: [
new BenchmarkTestStep("Stacked by 6", (page) => {
Expand Down Expand Up @@ -1047,6 +1021,7 @@ Suites.push({
name: "Charts-chartjs",
url: "resources/charts/dist/chartjs.html",
tags: ["chart"],
type: "async",
async prepare(page) {},
tests: [
new BenchmarkTestStep("Draw scatter", (page) => {
Expand All @@ -1067,6 +1042,7 @@ Suites.push({
name: "React-Stockcharts-SVG",
url: "resources/react-stockcharts/build/index.html?type=svg",
tags: ["chart", "svg"],
type: "async",
async prepare(page) {
await page.waitForElement("#render");
},
Expand Down Expand Up @@ -1107,6 +1083,7 @@ Suites.push({
name: "Perf-Dashboard",
url: "resources/perf.webkit.org/public/v3/#/charts/?since=1678991819934&paneList=((55-1974-null-null-(5-2.5-500)))",
tags: ["chart", "webcomponents"],
type: "async",
async prepare(page) {
await page.waitForElement("#app-is-ready");
page.call("startTest");
Expand Down

0 comments on commit 147c38f

Please sign in to comment.