Skip to content

Commit 4aa4966

Browse files
Merge pull request #1283 from gemini-testing/TESTPLANE-1046.selectivity_alg
fix(selectivity): dont rely on source maps originalPositionFor mappings
2 parents f288cd0 + 3a0da09 commit 4aa4966

10 files changed

Lines changed: 399 additions & 351 deletions

File tree

package-lock.json

Lines changed: 36 additions & 36 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -76,6 +76,7 @@
7676
"dependencies": {
7777
"@babel/code-frame": "7.24.2",
7878
"@gemini-testing/commander": "2.15.4",
79+
"@jridgewell/trace-mapping": "0.3.31",
7980
"@jspm/core": "2.0.1",
8081
"@jsquash/png": "3.1.1",
8182
"@puppeteer/browsers": "3.0.4",
@@ -112,7 +113,6 @@
112113
"sizzle": "2.3.6",
113114
"socket.io": "4.7.5",
114115
"socket.io-client": "4.7.5",
115-
"source-map-js": "1.2.1",
116116
"strftime": "0.10.2",
117117
"strip-ansi": "6.0.1",
118118
"temp": "0.8.3",

src/browser/cdp/selectivity/css-selectivity.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -357,7 +357,7 @@ export class CSSSelectivity {
357357
rawSourceMap.sources.forEach(sourceFilePath => {
358358
// Ignore generated postcss styles:
359359
// https://github.com/postcss/postcss/blob/eae46db765d752cf8f40c4fa2b0b85030079c43d/lib/map-generator.js#L122
360-
if (sourceFilePath === "<no source>") {
360+
if (!sourceFilePath || sourceFilePath === "<no source>") {
361361
return;
362362
}
363363

src/browser/cdp/selectivity/fs-cache.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@ export const CacheType = {
1111
TestFile: "t",
1212
Asset: "a",
1313
CssSessionCache: "cs",
14+
SourceMapParseResult: "sm",
1415
} as const;
1516

1617
type CacheTypeValue = (typeof CacheType)[keyof typeof CacheType];

src/browser/cdp/selectivity/js-selectivity.ts

Lines changed: 12 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,13 @@
11
import { groupBy } from "lodash";
22
import { resolve as urlResolve } from "node:url";
33
import { JS_SOURCE_MAP_URL_COMMENT } from "../../../error-snippets/constants";
4-
import { extractSourceFilesDeps, fetchTextWithBrowserFallback, isCachedOnFs, isDataProtocol } from "./utils";
4+
import {
5+
extractSourceFilesDeps,
6+
fetchTextWithBrowserFallback,
7+
isCachedOnFs,
8+
isDataProtocol,
9+
parseSourceMapRanges,
10+
} from "./utils";
511
import { CacheType, getCachedSelectivityFile, hasCachedSelectivityFile, setCachedSelectivityFile } from "./fs-cache";
612
import { debugSelectivity } from "./debug";
713
import type { CDP } from "..";
@@ -328,11 +334,14 @@ export class JSSelectivity {
328334
throw new Error(`JS Selectivity: fs-cache is broken for ${sourceUrl}`);
329335
}
330336

331-
const dependingSourceFiles = extractSourceFilesDeps(
337+
const parsedSourceMapRanges = await parseSourceMapRanges(
332338
sourceString,
333339
sourceMapsString,
334-
grouppedByScriptCoverage[scriptId],
335340
this._sourceRoot,
341+
);
342+
const dependingSourceFiles = extractSourceFilesDeps(
343+
parsedSourceMapRanges,
344+
grouppedByScriptCoverage[scriptId],
336345
isSourceCodeFile,
337346
);
338347

0 commit comments

Comments
 (0)