Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
51 changes: 27 additions & 24 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

12 changes: 6 additions & 6 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -46,15 +46,15 @@
"eslint-plugin-react": "^7.32.2",
"eslint-plugin-vue": "^9.10.0",
"expect.js": "^0.3.1",
"mocha": "^10.2.0",
"prettier": "^2.8.3",
"selenium-webdriver": "^4.27.0",
"sinon": "^17.0.1",
"typescript": "^5.0.4",
"lws": "^4.2.0",
"lws-cors": "^4.2.1",
"lws-index": "^3.1.1",
"lws-log": "^3.0.0",
"lws-static": "^3.1.1"
"lws-static": "^3.1.1",
"mocha": "^10.2.0",
"prettier": "^2.8.3",
"selenium-webdriver": "^4.36.0",
"sinon": "^17.0.1",
"typescript": "^5.0.4"
}
}
2 changes: 1 addition & 1 deletion resources/newssite/news-next/dist/404.html
Original file line number Diff line number Diff line change
@@ -1 +1 @@
<!DOCTYPE html><html lang="en"><head><meta charSet="utf-8"/><meta name="viewport" content="width=device-width"/><meta name="next-head-count" content="2"/><link rel="preload" href="./_next/static/css/a0dca1379a01e5cf.css" as="style"/><link rel="stylesheet" href="./_next/static/css/a0dca1379a01e5cf.css" data-n-g=""/><noscript data-n-css=""></noscript><script defer="" nomodule="" src="./_next/static/chunks/polyfills-c67a75d1b6f99dc8.js"></script><script src="./_next/static/chunks/webpack-e50e9853db18b759.js" defer=""></script><script src="./_next/static/chunks/framework-2c79e2a64abdb08b.js" defer=""></script><script src="./_next/static/chunks/main-2ba37e62325cc71b.js" defer=""></script><script src="./_next/static/chunks/pages/_app-77983e68be50f72a.js" defer=""></script><script src="./_next/static/chunks/pages/_error-54de1933a164a1ff.js" defer=""></script><script src="./_next/static/tuwdCnX7HYK_fwpI0QvDm/_buildManifest.js" defer=""></script><script src="./_next/static/tuwdCnX7HYK_fwpI0QvDm/_ssgManifest.js" defer=""></script></head><body><div id="__next"></div><div id="settings-container"></div><div id="notifications-container"></div><script id="__NEXT_DATA__" type="application/json">{"props":{"pageProps":{"statusCode":404}},"page":"/_error","query":{},"buildId":"tuwdCnX7HYK_fwpI0QvDm","assetPrefix":".","nextExport":true,"isFallback":false,"gip":true,"scriptLoader":[]}</script></body></html>
<!DOCTYPE html><html lang="en"><head><meta charSet="utf-8"/><meta name="viewport" content="width=device-width"/><meta name="next-head-count" content="2"/><link rel="preload" href="./_next/static/css/a0dca1379a01e5cf.css" as="style"/><link rel="stylesheet" href="./_next/static/css/a0dca1379a01e5cf.css" data-n-g=""/><noscript data-n-css=""></noscript><script defer="" nomodule="" src="./_next/static/chunks/polyfills-c67a75d1b6f99dc8.js"></script><script src="./_next/static/chunks/webpack-e50e9853db18b759.js" defer=""></script><script src="./_next/static/chunks/framework-2c79e2a64abdb08b.js" defer=""></script><script src="./_next/static/chunks/main-2ba37e62325cc71b.js" defer=""></script><script src="./_next/static/chunks/pages/_app-77983e68be50f72a.js" defer=""></script><script src="./_next/static/chunks/pages/_error-54de1933a164a1ff.js" defer=""></script><script src="./_next/static/DNvNqkPygsUdy_NGkO_GT/_buildManifest.js" defer=""></script><script src="./_next/static/DNvNqkPygsUdy_NGkO_GT/_ssgManifest.js" defer=""></script></head><body><div id="__next"></div><div id="settings-container"></div><div id="notifications-container"></div><script id="__NEXT_DATA__" type="application/json">{"props":{"pageProps":{"statusCode":404}},"page":"/_error","query":{},"buildId":"DNvNqkPygsUdy_NGkO_GT","assetPrefix":".","nextExport":true,"isFallback":false,"gip":true,"scriptLoader":[]}</script></body></html>

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion resources/newssite/news-next/dist/index.html
Original file line number Diff line number Diff line change
@@ -1 +1 @@
<!DOCTYPE html><html lang="en"><head><meta charSet="utf-8"/><meta name="viewport" content="width=device-width"/><meta name="next-head-count" content="2"/><link rel="preload" href="./_next/static/css/a0dca1379a01e5cf.css" as="style"/><link rel="stylesheet" href="./_next/static/css/a0dca1379a01e5cf.css" data-n-g=""/><link rel="preload" href="./_next/static/css/2cf5163b53bb0adb.css" as="style"/><link rel="stylesheet" href="./_next/static/css/2cf5163b53bb0adb.css" data-n-p=""/><noscript data-n-css=""></noscript><script defer="" nomodule="" src="./_next/static/chunks/polyfills-c67a75d1b6f99dc8.js"></script><script src="./_next/static/chunks/webpack-e50e9853db18b759.js" defer=""></script><script src="./_next/static/chunks/framework-2c79e2a64abdb08b.js" defer=""></script><script src="./_next/static/chunks/main-2ba37e62325cc71b.js" defer=""></script><script src="./_next/static/chunks/pages/_app-77983e68be50f72a.js" defer=""></script><script src="./_next/static/chunks/743-fd706aeabb7828e3.js" defer=""></script><script src="./_next/static/chunks/pages/index-99c54b3ee91525b8.js" defer=""></script><script src="./_next/static/tuwdCnX7HYK_fwpI0QvDm/_buildManifest.js" defer=""></script><script src="./_next/static/tuwdCnX7HYK_fwpI0QvDm/_ssgManifest.js" defer=""></script></head><body><div id="__next"></div><div id="settings-container"></div><div id="notifications-container"></div><script id="__NEXT_DATA__" type="application/json">{"props":{"pageProps":{}},"page":"/","query":{},"buildId":"tuwdCnX7HYK_fwpI0QvDm","assetPrefix":".","nextExport":true,"autoExport":true,"isFallback":false,"scriptLoader":[]}</script></body></html>
<!DOCTYPE html><html lang="en"><head><meta charSet="utf-8"/><meta name="viewport" content="width=device-width"/><meta name="next-head-count" content="2"/><link rel="preload" href="./_next/static/css/a0dca1379a01e5cf.css" as="style"/><link rel="stylesheet" href="./_next/static/css/a0dca1379a01e5cf.css" data-n-g=""/><link rel="preload" href="./_next/static/css/2cf5163b53bb0adb.css" as="style"/><link rel="stylesheet" href="./_next/static/css/2cf5163b53bb0adb.css" data-n-p=""/><noscript data-n-css=""></noscript><script defer="" nomodule="" src="./_next/static/chunks/polyfills-c67a75d1b6f99dc8.js"></script><script src="./_next/static/chunks/webpack-e50e9853db18b759.js" defer=""></script><script src="./_next/static/chunks/framework-2c79e2a64abdb08b.js" defer=""></script><script src="./_next/static/chunks/main-2ba37e62325cc71b.js" defer=""></script><script src="./_next/static/chunks/pages/_app-77983e68be50f72a.js" defer=""></script><script src="./_next/static/chunks/743-fd706aeabb7828e3.js" defer=""></script><script src="./_next/static/chunks/pages/index-0115872f7cb55221.js" defer=""></script><script src="./_next/static/DNvNqkPygsUdy_NGkO_GT/_buildManifest.js" defer=""></script><script src="./_next/static/DNvNqkPygsUdy_NGkO_GT/_ssgManifest.js" defer=""></script></head><body><div id="__next"></div><div id="settings-container"></div><div id="notifications-container"></div><script id="__NEXT_DATA__" type="application/json">{"props":{"pageProps":{}},"page":"/","query":{},"buildId":"DNvNqkPygsUdy_NGkO_GT","assetPrefix":".","nextExport":true,"autoExport":true,"isFallback":false,"scriptLoader":[]}</script></body></html>
74 changes: 61 additions & 13 deletions resources/shared/benchmark.mjs
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/* eslint-disable no-case-declarations */
import { TestRunner } from "./test-runner.mjs";
import { TestRunner, AsyncTestRunner } from "./test-runner.mjs";
import { Params } from "./params.mjs";

/**
Expand All @@ -20,15 +20,31 @@ export class BenchmarkStep {
}
}

export class AsyncBenchmarkStep extends BenchmarkStep {
async runAndRecord(params, suite, test, callback) {
const testRunner = new AsyncTestRunner(null, null, params, suite, test, callback);
const result = await testRunner.runTest();
return result;
}
}

export const BENCHMARK_SUITE_TYPE = Object.freeze({
__proto__: null,
sync: "sync",
async: "async",
});

/**
* BenchmarkSuite
*
* A single test suite that contains one or more test steps.
*/
export class BenchmarkSuite {
constructor(name, steps) {
constructor(name, steps, type = BENCHMARK_SUITE_TYPE.sync) {
this.name = name;
this.steps = steps;
this.type = type;
console.assert(this.type in BENCHMARK_SUITE_TYPE);
}

record(_test, syncTime, asyncTime) {
Expand All @@ -54,6 +70,7 @@ export class BenchmarkSuite {

for (const step of this.steps) {
const result = await step.runAndRecordStep(params, this, step, this.record);
console.assert(result, "Missing test return value", step);
measuredValues.tests[step.name] = result;
measuredValues.total += result.total;
onProgress?.(step.name);
Expand All @@ -66,11 +83,31 @@ export class BenchmarkSuite {
type: "suite-tests-complete",
status: "success",
result: measuredValues,
suitename: this.name,
suiteName: this.name,
};
}
}

export class AsyncBenchmarkSuite extends BenchmarkSuite {
constructor(name, tests) {
super(name, tests, BENCHMARK_SUITE_TYPE.async);
}
}

export const MESSAGE_TYPE = Object.freeze({
__proto__: null,
appReady: "app-ready",
suiteStart: "suite-start",
stepComplete: "step-complete",
suiteComplete: "suite-complete",
});

export const MESSAGE_STATUS = Object.freeze({
__proto__: null,
success: "success",
error: "error",
});

/** **********************************************************************
* BenchmarkConnector
*
Expand All @@ -95,31 +132,42 @@ export class BenchmarkConnector {
}

async onMessage(event) {
if (event.data.id !== this.appId || event.data.key !== "benchmark-connector")
const message = event.data;
if (message.appId !== this.appId || message.key !== "benchmark-connector") {
console.warning("Invalid message", message);
return;
}

switch (event.data.type) {
case "benchmark-suite":
switch (message.type) {
case MESSAGE_TYPE.suiteStart:
const params = new Params(new URLSearchParams(window.location.search));
const suite = this.suites[event.data.name];
const { name } = message.payload;
const suite = this.suites[name];
if (!suite)
console.error(`Suite with the name of "${event.data.name}" not found!`);
const { result } = await suite.runAndRecordSuite(params, (test) => this.sendMessage({ type: "step-complete", status: "success", appId: this.appId, name: this.name, test }));
this.sendMessage({ type: "suite-complete", status: "success", appId: this.appId, result });
console.error(`Suite with the name of "${name}" not found!`);
const onProgress = (step) => this._sendMessage(MESSAGE_TYPE.stepComplete, { name: this.name, step });
const { result } = await suite.runAndRecordSuite(params, onProgress);
this._sendMessage(MESSAGE_TYPE.suiteComplete, { result });
this.disconnect();
break;
default:
console.error(`Message data type not supported: ${event.data.type}`);
console.error(`Message data type not supported: ${message.type}`);
}
}

sendMessage(message) {
_sendMessage(type, payload, status = MESSAGE_STATUS.success) {
const message = {
appId: this.appId,
type: type,
payload: payload,
status: status,
};
window.top.postMessage(message, "*");
}

connect() {
window.addEventListener("message", this.onMessage);
this.sendMessage({ type: "app-ready", status: "success", appId: this.appId });
this._sendMessage(MESSAGE_TYPE.appReady, { appId: this.appId });
}

disconnect() {
Expand Down
8 changes: 4 additions & 4 deletions resources/shared/test-invoker.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -44,8 +44,8 @@ class AsyncRAFTestInvoker extends TestInvoker {

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

Expand Down Expand Up @@ -77,8 +77,8 @@ class AsyncRAFTestInvoker extends TestInvoker {
}
}

export const TEST_INVOKER_LOOKUP = {
export const TEST_INVOKER_LOOKUP = Object.freeze({
__proto__: null,
raf: RAFTestInvoker,
async: AsyncRAFTestInvoker,
};
});
13 changes: 7 additions & 6 deletions resources/shared/test-runner.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -9,14 +9,15 @@ export class TestRunner {
#callback;
#type;

constructor(frame, page, params, suite, test, callback, type) {
constructor(frame, page, params, suite, test, callback, type = "default") {
this.#suite = suite;
this.#test = test;
this.#params = params;
this.#callback = callback;
this.#page = page;
this.#frame = frame;
this.#type = type;
console.assert(type in TEST_RUNNER_LOOKUP);
}

get page() {
Expand Down Expand Up @@ -69,7 +70,7 @@ export class TestRunner {
const measureAsync = () => {
// Some browsers don't immediately update the layout for paint.
// Force the layout here to ensure we're measuring the layout time.
this.page.layout();
this.page?.layout();

const asyncEndTime = performance.now();
performance.mark(asyncEndLabel);
Expand All @@ -92,18 +93,18 @@ export class TestRunner {
}

export class AsyncTestRunner extends TestRunner {
constructor(frame, page, params, suite, test, callback, type) {
super(frame, page, params, suite, test, callback, type);
constructor(frame, page, params, suite, test, callback) {
super(frame, page, params, suite, test, callback, "async");
}

async _runSyncStep(test, page) {
await test.run(page);
}
}

export const TEST_RUNNER_LOOKUP = {
export const TEST_RUNNER_LOOKUP = Object.freeze({
__proto__: null,
default: TestRunner,
async: AsyncTestRunner,
remote: TestRunner,
};
});
Loading
Loading