Skip to content

Commit

Permalink
pr feedback
Browse files Browse the repository at this point in the history
  • Loading branch information
flashdesignory committed Dec 2, 2024
1 parent 99c148a commit 67820e8
Show file tree
Hide file tree
Showing 9 changed files with 34 additions and 15 deletions.
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/F8-ZIe6VJKI1KKZB0Fk1z/_buildManifest.js" defer=""></script><script src="./_next/static/F8-ZIe6VJKI1KKZB0Fk1z/_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":"F8-ZIe6VJKI1KKZB0Fk1z","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/xV4i7k9i3yoQALjLQdnM1/_buildManifest.js" defer=""></script><script src="./_next/static/xV4i7k9i3yoQALjLQdnM1/_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":"xV4i7k9i3yoQALjLQdnM1","assetPrefix":".","nextExport":true,"isFallback":false,"gip":true,"scriptLoader":[]}</script></body></html>

Large diffs are not rendered by default.

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

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-78a7c0310f4fc6ae.js" defer=""></script><script src="./_next/static/F8-ZIe6VJKI1KKZB0Fk1z/_buildManifest.js" defer=""></script><script src="./_next/static/F8-ZIe6VJKI1KKZB0Fk1z/_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":"F8-ZIe6VJKI1KKZB0Fk1z","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-ba74014129e5f103.js" defer=""></script><script src="./_next/static/xV4i7k9i3yoQALjLQdnM1/_buildManifest.js" defer=""></script><script src="./_next/static/xV4i7k9i3yoQALjLQdnM1/_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":"xV4i7k9i3yoQALjLQdnM1","assetPrefix":".","nextExport":true,"autoExport":true,"isFallback":false,"scriptLoader":[]}</script></body></html>
5 changes: 4 additions & 1 deletion resources/newssite/news-next/src/pages/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,11 @@ import { connectToBenchmark } from "speedometer-utils/workload-testing-utils.mjs
import { getBenchmarkSuitesManager } from "@/workload-test.mjs";

export default function App() {
// Using 'useLayoutEffect' here, since this will connect the workload after all DOM mutations happened.
// This ensures that all elemetns are in the DOM, prior to signaling to the Benchmark that the workload is ready to run a test suite.
useLayoutEffect(() => {
connectToBenchmark(getBenchmarkSuitesManager(), "news-next", 1);
const disconnect = connectToBenchmark(getBenchmarkSuitesManager(), "news-next", 1);
return disconnect;
}, []);

return (
Expand Down
3 changes: 3 additions & 0 deletions resources/shared/params.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -150,10 +150,13 @@ export class Params {
const rawParams = { ...this };
rawParams["viewport"] = `${this.viewport.width}x${this.viewport.height}`;

// Only returning params that are useful for the workload.
// Both, 'suites' and 'tags', are specific to the debug menu.
if (forRemote) {
delete rawParams["suites"];
delete rawParams["tags"];
}

return new URLSearchParams(rawParams).toString();
}
}
Expand Down
13 changes: 10 additions & 3 deletions resources/shared/workload-testing-utils.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -126,14 +126,15 @@ export function forceLayout() {
* The appId is build by appending name-version
* It's used as an additional safe-guard to ensure the correct app responds to a message.
*************************************************************************/

export function connectToBenchmark(benchmarkSuitesManager, name, version) {
const appId = name && version ? `${name}-${version}` : -1;

function sendMessage(message) {
window.top.postMessage(message, "*");
}

window.onmessage = async (event) => {
async function onMessage(event) {
// ensure we only let legit functions run...
if (event.data.id !== appId || event.data.key !== "benchmark-connector")
return;
Expand All @@ -145,10 +146,16 @@ export function connectToBenchmark(benchmarkSuitesManager, name, version) {
// eslint-disable-next-line no-case-declarations
const { result } = await benchmarkSuitesManager.getSuiteByName(event.data.name).runAndRecord(params, (test) => sendMessage({ type: "step-complete", status: "success", appId, name, test }));
sendMessage({ type: "suite-complete", status: "success", appId, result });
disconnect();
break;
}
};
}

function disconnect() {
window.removeEventListener("message", onMessage);
}

window.addEventListener("message", onMessage);
sendMessage({ type: "app-ready", status: "success", appId });
console.log(`Hello, benchmark connector for ${appId} is ready!`);
return disconnect;
}
20 changes: 13 additions & 7 deletions resources/suite-runner.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -137,10 +137,12 @@ export class RemoteSuiteRunner extends SuiteRunner {
window.addEventListener("message", handler);

// FIXME: use this._suite in all SuiteRunner methods directly.
await this._prepareSuite();
await this._runSuite();

window.removeEventListener("message", handler);
try {
await this._prepareSuite();
await this._runSuite();
} finally {
window.removeEventListener("message", handler);
}
}

async _prepareSuite() {
Expand All @@ -151,9 +153,9 @@ export class RemoteSuiteRunner extends SuiteRunner {
performance.mark(suitePrepareStartLabel);

// Wait for the app-ready message from the workload.
const promise = this._subscribeOnce("app-ready");
const appReadyPromise = this._subscribeOnce("app-ready");
await this._loadFrame(this.suite);
const response = await promise;
const response = await appReadyPromise;
await this.suite.prepare(this.page);
// Capture appId to pass along with messages.
this.appId = response?.appId;
Expand All @@ -172,7 +174,11 @@ export class RemoteSuiteRunner extends SuiteRunner {
const response = await this._subscribeOnce("suite-complete");
this._stopSubscription("step-complete");

this.suiteResults.tests = response.result.tests;
this.suiteResults.tests = {
...this.suiteResults.tests,
...response.result.tests
};

this.suiteResults.total += response.result.total;

this._validateSuiteTotal();
Expand Down

0 comments on commit 67820e8

Please sign in to comment.