Skip to content

Commit

Permalink
build: update TS target and fix website css (#3070)
Browse files Browse the repository at this point in the history
Update TypeScript to target newer versions of ECMAScript - we run it in
the browser so almost all feature are there.
Made use of these new things to remove the `[...Iterator]` syntax as the
new one should have better performence.
Replaced the `divider` div from the template as there were small issue
around hiding things using border-top does the same thing.
  • Loading branch information
Lightning00Blade authored Feb 4, 2025
1 parent ec3df40 commit bdc806a
Show file tree
Hide file tree
Showing 6 changed files with 25 additions and 30 deletions.
2 changes: 1 addition & 1 deletion src/bidiMapper/modules/network/NetworkProcessor.ts
Original file line number Diff line number Diff line change
Expand Up @@ -211,7 +211,7 @@ export class NetworkProcessor {
const cacheDisabled = params.cacheBehavior === 'bypass';

await Promise.all(
[...contexts.values()].map((context) => {
contexts.values().map((context) => {
return context.cdpTarget.toggleSetCacheDisabled(cacheDisabled);
}),
);
Expand Down
24 changes: 16 additions & 8 deletions src/bidiMapper/modules/session/SubscriptionManager.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -664,9 +664,13 @@ describe('SubscriptionManager', () => {
});

describe('unroll events', () => {
function unrollEventsToArray(args: any[]) {
return [...unrollEvents(args)];
}

it('all Browsing Context events', () => {
expect(
unrollEvents([ChromiumBidi.BiDiModule.BrowsingContext]),
unrollEventsToArray([ChromiumBidi.BiDiModule.BrowsingContext]),
).to.have.members([
ChromiumBidi.BrowsingContext.EventNames.ContextCreated,
ChromiumBidi.BrowsingContext.EventNames.ContextDestroyed,
Expand All @@ -685,13 +689,15 @@ describe('SubscriptionManager', () => {
});

it('all Log events', () => {
expect(unrollEvents([ChromiumBidi.BiDiModule.Log])).to.have.members([
ChromiumBidi.Log.EventNames.LogEntryAdded,
]);
expect(
unrollEventsToArray([ChromiumBidi.BiDiModule.Log]),
).to.have.members([ChromiumBidi.Log.EventNames.LogEntryAdded]);
});

it('all Network events', () => {
expect(unrollEvents([ChromiumBidi.BiDiModule.Network])).to.have.members([
expect(
unrollEventsToArray([ChromiumBidi.BiDiModule.Network]),
).to.have.members([
ChromiumBidi.Network.EventNames.AuthRequired,
ChromiumBidi.Network.EventNames.BeforeRequestSent,
ChromiumBidi.Network.EventNames.FetchError,
Expand All @@ -701,7 +707,9 @@ describe('SubscriptionManager', () => {
});

it('all Script events', () => {
expect(unrollEvents([ChromiumBidi.BiDiModule.Script])).to.have.members([
expect(
unrollEventsToArray([ChromiumBidi.BiDiModule.Script]),
).to.have.members([
ChromiumBidi.Script.EventNames.Message,
ChromiumBidi.Script.EventNames.RealmCreated,
ChromiumBidi.Script.EventNames.RealmDestroyed,
Expand All @@ -710,7 +718,7 @@ describe('SubscriptionManager', () => {

it('discrete events', () => {
expect(
unrollEvents([
unrollEventsToArray([
ChromiumBidi.Script.EventNames.RealmCreated,
ChromiumBidi.Log.EventNames.LogEntryAdded,
]),
Expand All @@ -722,7 +730,7 @@ describe('SubscriptionManager', () => {

it('all and discrete events', () => {
expect(
unrollEvents([
unrollEventsToArray([
ChromiumBidi.BiDiModule.Log,
ChromiumBidi.Log.EventNames.LogEntryAdded,
]),
Expand Down
4 changes: 2 additions & 2 deletions src/bidiMapper/modules/session/SubscriptionManager.ts
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ export function cartesianProduct(...a: any[][]) {
/** Expands "AllEvents" events into atomic events. */
export function unrollEvents(
events: ChromiumBidi.EventNames[],
): ChromiumBidi.EventNames[] {
): Iterable<ChromiumBidi.EventNames> {
const allEvents = new Set<ChromiumBidi.EventNames>();

function addEvents(events: ChromiumBidi.EventNames[]) {
Expand Down Expand Up @@ -72,7 +72,7 @@ export function unrollEvents(
}
}

return [...allEvents.values()];
return allEvents.values();
}

export interface Subscription {
Expand Down
3 changes: 1 addition & 2 deletions tools/wpt-report-builder/formatter.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -242,7 +242,6 @@ function generateTestReport(map, parent) {
}

return `
<div class="divider"></div>
<div class="test-card">
<details>
<summary class="path ${
Expand Down Expand Up @@ -270,7 +269,7 @@ function generateSubtestReport(subtest) {
const name =
subtest.name ?? removeWebDriverBiDiPrefix(subtest.path).split('/').at(-1);

return `<div class="divider"></div>
return `
<div class="test-card test-card-subtest ${
subtest.status === 'PASS' ? 'pass' : 'fail'
}">
Expand Down
18 changes: 3 additions & 15 deletions tools/wpt-report-builder/template.html
Original file line number Diff line number Diff line change
Expand Up @@ -32,13 +32,13 @@
max-width: 1200px;
}

.top > div > .test-card,
.top > div > .divider {
.top > div > .test-card {
margin-left: 0;
}
.test-card {
margin-left: 20px;
max-width: 1200px;
border: 1px solid #a0a0a0;
}
.test-card-subtest {
display: flex;
Expand All @@ -49,11 +49,6 @@
.test-name {
word-break: break-all;
}
.divider {
margin-left: 20px;
height: 1px;
background: #a0a0a0;
}
.non-collapsible-item {
padding-left: 27px;
padding-right: 15px;
Expand Down Expand Up @@ -165,9 +160,7 @@
const failures = document.querySelector('.failures');
let failureState = 'all';
const summaryQuery = '.test-card:has(> details > .path.pass)';
const summaryDividerQuery = `${summaryQuery} + .divider`;
const passingTestQuery = '.test-card.test-card-subtest.pass';
const passingTestDividerQuery = `${passingTestQuery} + .divider`;
failures.addEventListener('click', () => {
failures.innerText =
failureState.charAt(0).toUpperCase() + failureState.slice(1);
Expand All @@ -176,12 +169,7 @@
} else {
failureState = 'all';
}
for (const query of [
summaryQuery,
summaryDividerQuery,
passingTestQuery,
passingTestDividerQuery,
]) {
for (const query of [summaryQuery, passingTestQuery]) {
document
.querySelectorAll(query)
.forEach(
Expand Down
4 changes: 2 additions & 2 deletions tsconfig.base.json
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
"declaration": true,
"esModuleInterop": true,
"incremental": true,
"module": "ES2022",
"module": "ESNext",
"moduleResolution": "node",
"noFallthroughCasesInSwitch": true,
"noImplicitAny": true,
Expand All @@ -23,7 +23,7 @@
"strictFunctionTypes": true,
"strictNullChecks": true,
"strictPropertyInitialization": true,
"target": "ES2022",
"target": "ESNext",
"useUnknownInCatchVariables": true
}
}

0 comments on commit bdc806a

Please sign in to comment.