Skip to content

Commit 96e4c5d

Browse files
authored
Merge branch 'main' into depfu/update/yarn/espree-11.0.0
2 parents 9f8ebeb + ffc9f82 commit 96e4c5d

File tree

13 files changed

+841
-256
lines changed

13 files changed

+841
-256
lines changed

.github/workflows/ci.yml

Lines changed: 29 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,10 @@ on:
99

1010
jobs:
1111
lint:
12-
runs-on: ubuntu-latest
12+
runs-on: ${{ matrix.os }}
13+
strategy:
14+
matrix:
15+
os: [ubuntu-latest, windows-latest]
1316
steps:
1417
- name: Checkout code
1518
uses: actions/checkout@v5
@@ -21,7 +24,10 @@ jobs:
2124
run: yarn lint
2225

2326
tests:
24-
runs-on: ubuntu-latest
27+
runs-on: ${{ matrix.os }}
28+
strategy:
29+
matrix:
30+
os: [ubuntu-latest, windows-latest]
2531
steps:
2632
- name: Checkout code
2733
uses: actions/checkout@v5
@@ -35,12 +41,16 @@ jobs:
3541
run: yarn test --coverage --logHeapUsage -w=4 --workerIdleMemoryLimit=1.5G
3642

3743
- name: Upload coverage to Codecov
44+
if: matrix.os == 'ubuntu-latest'
3845
uses: codecov/codecov-action@v5
3946
with:
4047
fail_ci_if_error: false
4148

4249
build-prod:
43-
runs-on: ubuntu-latest
50+
runs-on: ${{ matrix.os }}
51+
strategy:
52+
matrix:
53+
os: [ubuntu-latest, windows-latest]
4454
steps:
4555
- name: Checkout code
4656
uses: actions/checkout@v5
@@ -55,7 +65,10 @@ jobs:
5565
run: yarn build-symbolicator-cli:quiet
5666

5767
licence-check:
58-
runs-on: ubuntu-latest
68+
runs-on: ${{ matrix.os }}
69+
strategy:
70+
matrix:
71+
os: [ubuntu-latest, windows-latest]
5972
steps:
6073
- name: Checkout code
6174
uses: actions/checkout@v5
@@ -67,7 +80,10 @@ jobs:
6780
run: yarn license-check
6881

6982
typecheck:
70-
runs-on: ubuntu-latest
83+
runs-on: ${{ matrix.os }}
84+
strategy:
85+
matrix:
86+
os: [ubuntu-latest, windows-latest]
7187
steps:
7288
- name: Checkout code
7389
uses: actions/checkout@v5
@@ -79,7 +95,10 @@ jobs:
7995
run: yarn ts
8096

8197
alex:
82-
runs-on: ubuntu-latest
98+
runs-on: ${{ matrix.os }}
99+
strategy:
100+
matrix:
101+
os: [ubuntu-latest, windows-latest]
83102
steps:
84103
- name: Checkout code
85104
uses: actions/checkout@v5
@@ -91,7 +110,10 @@ jobs:
91110
run: yarn test-alex
92111

93112
yarn-lock:
94-
runs-on: ubuntu-latest
113+
runs-on: ${{ matrix.os }}
114+
strategy:
115+
matrix:
116+
os: [ubuntu-latest, windows-latest]
95117
steps:
96118
- name: Checkout code
97119
uses: actions/checkout@v5

appveyor.yml

Lines changed: 0 additions & 37 deletions
This file was deleted.

jest.config.js

Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,40 @@
1+
/* This Source Code Form is subject to the terms of the Mozilla Public
2+
* License, v. 2.0. If a copy of the MPL was not distributed with this
3+
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
4+
5+
module.exports = {
6+
testMatch: ['<rootDir>/src/**/*.test.{js,jsx,ts,tsx}'],
7+
moduleFileExtensions: ['js', 'jsx', 'ts', 'tsx'],
8+
9+
testEnvironment: './src/test/custom-environment',
10+
setupFilesAfterEnv: ['jest-extended/all', './src/test/setup.ts'],
11+
12+
collectCoverageFrom: [
13+
'src/**/*.{js,jsx,ts,tsx}',
14+
'!**/node_modules/**',
15+
'!src/types/libdef/**',
16+
],
17+
18+
// Transform ESM modules to CommonJS for Jest
19+
// These packages ship as pure ESM and need to be transformed by Babel
20+
transformIgnorePatterns: [
21+
'/node_modules/(?!(query-string|decode-uri-component|iongraph-web|split-on-first|filter-obj|fetch-mock)/)',
22+
],
23+
24+
// Mock static assets (images, CSS, etc.)
25+
moduleNameMapper: {
26+
'\\.(jpg|jpeg|png|gif|eot|otf|webp|svg|ttf|woff|woff2|mp4|webm|wav|mp3|m4a|aac|oga|ftl)$':
27+
'<rootDir>/src/test/fixtures/mocks/file-mock.ts',
28+
'\\.(css|less)$': '<rootDir>/src/test/fixtures/mocks/style-mock.ts',
29+
},
30+
31+
globals: {
32+
AVAILABLE_STAGING_LOCALES: null,
33+
},
34+
35+
snapshotFormat: {
36+
escapeString: true,
37+
printBasicPrototype: true,
38+
},
39+
verbose: false,
40+
};

package.json

Lines changed: 7 additions & 39 deletions
Original file line numberDiff line numberDiff line change
@@ -13,12 +13,13 @@
1313
"build:clean": "rimraf dist && mkdirp dist",
1414
"build:quiet": "yarn build:clean && cross-env NODE_ENV=development webpack",
1515
"build": "yarn build:quiet --progress",
16-
"build-prod:quiet": "yarn build:clean && yarn build-photon && cross-env NODE_ENV=production webpack",
17-
"build-prod": "yarn build-prod:quiet --progress",
16+
"build-prod:quiet": "yarn build:clean && yarn build-photon && cross-env NODE_ENV=production webpack && yarn build-sw",
17+
"build-prod": "yarn build:clean && yarn build-photon && cross-env NODE_ENV=production webpack --progress && yarn build-sw",
1818
"build-l10n": "yarn build:clean && cross-env NODE_ENV=development L10N=1 webpack --progress",
19-
"build-l10n-prod:quiet": "yarn build:clean && yarn build-photon && cross-env NODE_ENV=production L10N=1 webpack",
20-
"build-l10n-prod": "yarn build-l10n-prod:quiet --progress",
19+
"build-l10n-prod:quiet": "yarn build:clean && yarn build-photon && cross-env NODE_ENV=production L10N=1 webpack && yarn build-sw",
20+
"build-l10n-prod": "yarn build:clean && yarn build-photon && cross-env NODE_ENV=production L10N=1 webpack --progress && yarn build-sw",
2121
"build-photon": "webpack --config res/photon/webpack.config.js",
22+
"build-sw": "workbox generateSW workbox-config.js",
2223
"build-symbolicator-cli": "yarn build-symbolicator-cli:quiet --progress",
2324
"build-symbolicator-cli:quiet": "yarn build:clean && cross-env NODE_ENV=production webpack --config src/symbolicator-cli/webpack.config.js",
2425
"lint": "node bin/output-fixing-commands.js run-p lint-js lint-css prettier-run",
@@ -159,7 +160,7 @@
159160
"fake-indexeddb": "^6.2.4",
160161
"fetch-mock": "^12.5.5",
161162
"file-loader": "^6.2.0",
162-
"glob": "^11.0.3",
163+
"glob": "^12.0.0",
163164
"globals": "^16.5.0",
164165
"html-webpack-plugin": "^5.6.4",
165166
"husky": "^4.3.8",
@@ -187,46 +188,13 @@
187188
"webpack": "^5.102.1",
188189
"webpack-cli": "^6.0.1",
189190
"webpack-dev-server": "^5.2.2",
190-
"workbox-webpack-plugin": "^7.3.0",
191+
"workbox-cli": "^7.3.0",
191192
"yargs": "^18.0.0"
192193
},
193194
"resolutions": {
194195
"@types/react-splitter-layout/@types/react": "^18.3.26",
195196
"@types/trusted-types": "^2.0.7"
196197
},
197-
"jest": {
198-
"collectCoverageFrom": [
199-
"src/**/*.{js,jsx,ts,tsx}",
200-
"!**/node_modules/**",
201-
"!src/types/libdef/**"
202-
],
203-
"moduleFileExtensions": [
204-
"js",
205-
"jsx",
206-
"ts",
207-
"tsx"
208-
],
209-
"transformIgnorePatterns": [
210-
"/node_modules/(?!(query-string|decode-uri-component|iongraph-web|split-on-first|filter-obj|fetch-mock)/)"
211-
],
212-
"moduleNameMapper": {
213-
"\\.(jpg|jpeg|png|gif|eot|otf|webp|svg|ttf|woff|woff2|mp4|webm|wav|mp3|m4a|aac|oga|ftl)$": "<rootDir>/src/test/fixtures/mocks/file-mock.ts",
214-
"\\.(css|less)$": "<rootDir>/src/test/fixtures/mocks/style-mock.ts"
215-
},
216-
"setupFilesAfterEnv": [
217-
"jest-extended/all",
218-
"./src/test/setup.ts"
219-
],
220-
"globals": {
221-
"AVAILABLE_STAGING_LOCALES": null
222-
},
223-
"snapshotFormat": {
224-
"escapeString": true,
225-
"printBasicPrototype": true
226-
},
227-
"testEnvironment": "./src/test/custom-environment",
228-
"verbose": false
229-
},
230198
"husky": {
231199
"hooks": {
232200
"post-checkout": "node bin/post-checkout.js",

src/profile-logic/import/art-trace.ts

Lines changed: 11 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -194,12 +194,12 @@ type ArtTrace = {
194194
};
195195

196196
function detectArtTraceFormat(
197-
traceBuffer: ArrayBufferLike
197+
traceBuffer: Uint8Array
198198
): 'regular' | 'streaming' | 'unrecognized' {
199199
try {
200200
const lengthOfExpectedFirstTwoLinesOfSummarySection = '*version\nX\n'
201201
.length;
202-
const firstTwoLinesBuffer = traceBuffer.slice(
202+
const firstTwoLinesBuffer = traceBuffer.subarray(
203203
0,
204204
lengthOfExpectedFirstTwoLinesOfSummarySection
205205
);
@@ -213,7 +213,11 @@ function detectArtTraceFormat(
213213
}
214214

215215
try {
216-
const dataView = new DataView(traceBuffer);
216+
const dataView = new DataView(
217+
traceBuffer.buffer,
218+
traceBuffer.byteOffset,
219+
traceBuffer.byteLength
220+
);
217221
const magic = dataView.getUint32(0, true);
218222
if (magic === TRACE_MAGIC) {
219223
return 'streaming';
@@ -523,9 +527,9 @@ function parseStreamingFormat(reader: ByteReader) {
523527
};
524528
}
525529

526-
function parseArtTrace(buffer: ArrayBufferLike): ArtTrace {
530+
function parseArtTrace(buffer: Uint8Array): ArtTrace {
527531
try {
528-
const reader = new ByteReader(new Uint8Array(buffer));
532+
const reader = new ByteReader(buffer);
529533
switch (detectArtTraceFormat(buffer)) {
530534
case 'regular':
531535
return parseRegularFormat(reader);
@@ -915,13 +919,13 @@ class ThreadBuilder {
915919
}
916920
}
917921

918-
export function isArtTraceFormat(traceBuffer: ArrayBufferLike) {
922+
export function isArtTraceFormat(traceBuffer: Uint8Array) {
919923
return detectArtTraceFormat(traceBuffer) !== 'unrecognized';
920924
}
921925

922926
// Convert an ART trace to the Gecko profile format.
923927
export function convertArtTraceProfile(
924-
traceBuffer: ArrayBufferLike
928+
traceBuffer: Uint8Array
925929
): GeckoProfileVersion11 {
926930
const trace = parseArtTrace(traceBuffer);
927931
const originalIntervalInUsec = procureSamplingInterval(trace);

src/profile-logic/import/simpleperf.ts

Lines changed: 9 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -474,13 +474,17 @@ class FirefoxProfile {
474474
}
475475

476476
export class SimpleperfReportConverter {
477-
buffer: ArrayBufferLike;
477+
buffer: Uint8Array;
478478
bufferView: DataView;
479479
bufferOffset: number = 0;
480480

481-
constructor(buffer: ArrayBufferLike) {
481+
constructor(buffer: Uint8Array) {
482482
this.buffer = buffer;
483-
this.bufferView = new DataView(buffer);
483+
this.bufferView = new DataView(
484+
buffer.buffer,
485+
buffer.byteOffset,
486+
buffer.byteLength
487+
);
484488
}
485489

486490
readUint16LE() {
@@ -509,11 +513,10 @@ export class SimpleperfReportConverter {
509513
}
510514

511515
readRecord(recordSize: number): report.Record {
512-
const recordBuffer = this.buffer.slice(
516+
const recordArray = this.buffer.subarray(
513517
this.bufferOffset,
514518
this.bufferOffset + recordSize
515519
);
516-
const recordArray = new Uint8Array(recordBuffer);
517520
this.bufferOffset += recordSize;
518521

519522
return report.Record.decode(recordArray);
@@ -577,7 +580,7 @@ export class SimpleperfReportConverter {
577580
}
578581

579582
export function convertSimpleperfTraceProfile(
580-
traceBuffer: ArrayBufferLike
583+
traceBuffer: Uint8Array
581584
): Profile {
582585
return new SimpleperfReportConverter(traceBuffer).process();
583586
}

src/profile-logic/process-profile.ts

Lines changed: 15 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1965,27 +1965,33 @@ export async function unserializeProfileOfArbitraryFormat(
19651965
// object is constructed from an ArrayBuffer in a different context... which
19661966
// happens in our tests.
19671967
if (String(arbitraryFormat) === '[object ArrayBuffer]') {
1968-
let arrayBuffer = arbitraryFormat as ArrayBuffer;
1968+
const arrayBuffer = arbitraryFormat as ArrayBuffer;
1969+
arbitraryFormat = new Uint8Array(arrayBuffer);
1970+
}
19691971

1972+
// Handle binary formats.
1973+
if (
1974+
arbitraryFormat instanceof Uint8Array ||
1975+
(globalThis.Buffer && arbitraryFormat instanceof globalThis.Buffer)
1976+
) {
19701977
// Check for the gzip magic number in the header. If we find it, decompress
19711978
// the data first.
1972-
const profileBytes = new Uint8Array(arrayBuffer);
1979+
let profileBytes = arbitraryFormat as Uint8Array<ArrayBuffer>;
19731980
if (isGzip(profileBytes)) {
1974-
const decompressedProfile = await decompress(profileBytes);
1975-
arrayBuffer = decompressedProfile.buffer;
1981+
profileBytes = await decompress(profileBytes);
19761982
}
19771983

1978-
if (isArtTraceFormat(arrayBuffer)) {
1979-
arbitraryFormat = convertArtTraceProfile(arrayBuffer);
1980-
} else if (verifyMagic(SIMPLEPERF_MAGIC, arrayBuffer)) {
1984+
if (isArtTraceFormat(profileBytes)) {
1985+
arbitraryFormat = convertArtTraceProfile(profileBytes);
1986+
} else if (verifyMagic(SIMPLEPERF_MAGIC, profileBytes)) {
19811987
const { convertSimpleperfTraceProfile } = await import(
19821988
'./import/simpleperf'
19831989
);
1984-
arbitraryFormat = convertSimpleperfTraceProfile(arrayBuffer);
1990+
arbitraryFormat = convertSimpleperfTraceProfile(profileBytes);
19851991
} else {
19861992
try {
19871993
const textDecoder = new TextDecoder(undefined, { fatal: true });
1988-
arbitraryFormat = await textDecoder.decode(arrayBuffer);
1994+
arbitraryFormat = await textDecoder.decode(profileBytes);
19891995
} catch (e) {
19901996
console.error('Source exception:', e);
19911997
throw new Error(

0 commit comments

Comments
 (0)