Skip to content
Merged
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
42 changes: 2 additions & 40 deletions package-lock.json

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

1 change: 0 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -84,7 +84,6 @@
"@eslint/js": "9.39.4",
"@jest/expect-utils": "30.4.1",
"@modelcontextprotocol/sdk": "1.29.0",
"@octokit/graphql-schema": "15.26.1",
"@stylistic/eslint-plugin": "5.10.0",
"@types/babel__code-frame": "7.27.0",
"@types/babel__core": "7.20.5",
Expand Down
4 changes: 4 additions & 0 deletions packages/injected/src/injectedScript.ts
Original file line number Diff line number Diff line change
Expand Up @@ -78,6 +78,7 @@ interface WebKitLegacyDeviceMotionEvent extends DeviceMotionEvent {
export type InjectedScriptOptions = {
isUnderTest: boolean;
sdkLanguage: Language;
frameSeq: number;
// For strict error and codegen
testIdAttributeName: string;
stableRafCount: number;
Expand All @@ -99,6 +100,7 @@ export class InjectedScript {
private _highlight: Highlight | undefined;
readonly isUnderTest: boolean;
private _sdkLanguage: Language;
private _frameSeq: number;
private _testIdAttributeNameForStrictErrorAndConsoleCodegen: string = 'data-testid';
readonly window: Window & typeof globalThis;
readonly document: Document;
Expand Down Expand Up @@ -141,6 +143,7 @@ export class InjectedScript {
// inside a trace viewer snapshot, where "window" differs from "globalThis".
this.utils.builtins = new UtilityScript(window, options.isUnderTest).builtins;
this._sdkLanguage = options.sdkLanguage;
this._frameSeq = options.frameSeq;
this._testIdAttributeNameForStrictErrorAndConsoleCodegen = options.testIdAttributeName;
this._evaluator = new SelectorEvaluatorImpl();
this.consoleApi = new ConsoleAPI(this);
Expand Down Expand Up @@ -318,6 +321,7 @@ export class InjectedScript {
ariaSnapshotWithRefs(node: Node, options: AriaTreeOptions & { depth?: number }): { text: string, iframeRefs: string[], iframeDepths: Record<string, number> } {
if (node.nodeType !== Node.ELEMENT_NODE)
throw this.createStacklessError('Can only capture aria snapshot of Element nodes.');
options = { ...options, refPrefix: this._frameSeq && options.mode === 'ai' ? 'f' + this._frameSeq : '' };
const ariaSnapshot = generateAriaTree(node as Element, options);
const rendered = renderAriaTree(ariaSnapshot, options);
this._lastAriaSnapshotForQuery = ariaSnapshot;
Expand Down
1 change: 1 addition & 0 deletions packages/playwright-core/src/server/dom.ts
Original file line number Diff line number Diff line change
Expand Up @@ -91,6 +91,7 @@ export class FrameExecutionContext extends js.ExecutionContext {
const options: InjectedScriptOptions = {
isUnderTest: isUnderTest(),
sdkLanguage,
frameSeq: this.frame.seq,
testIdAttributeName: selectorsRegistry.testIdAttributeName(),
stableRafCount: this.frame._page.delegate.rafCountForStablePosition(),
browserName: this.frame._page.browserContext._browser.options.name,
Expand Down
1 change: 0 additions & 1 deletion packages/playwright-core/src/server/page.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1121,7 +1121,6 @@ export async function ariaSnapshotForFrame(progress: Progress, frame: frames.Fra
return injected.ariaSnapshotWithRefs(element, options);
}, {
mode: options.mode ?? 'default',
refPrefix: resolvedFrame.seq ? 'f' + resolvedFrame.seq : '',
doNotRenderActive: options.doNotRenderActive,
info: resolved.info,
depth: options.depth,
Expand Down
4 changes: 2 additions & 2 deletions packages/trace-viewer/src/ui/snapshotTab.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -86,7 +86,7 @@ export const SnapshotTabsView: React.FunctionComponent<{
<ToolbarButton icon='link-external' title='Open snapshot in a new tab' disabled={!snapshotUrls?.popoutUrl} onClick={() => {
const win = window.open(snapshotUrls?.popoutUrl || '', '_blank');
win?.addEventListener('DOMContentLoaded', () => {
const injectedScript = new InjectedScript(win as any, { isUnderTest, sdkLanguage, testIdAttributeName, stableRafCount: 1, browserName: 'chromium', customEngines: [] });
const injectedScript = new InjectedScript(win as any, { isUnderTest, frameSeq: 0, sdkLanguage, testIdAttributeName, stableRafCount: 1, browserName: 'chromium', customEngines: [] });
injectedScript.consoleApi.install();
});
}} />
Expand Down Expand Up @@ -311,7 +311,7 @@ function createRecorders(recorders: { recorder: Recorder, frameSelector: string
return;
const win = frameWindow as any;
if (!win._recorder && force) {
const injectedScript = new InjectedScript(frameWindow as any, { isUnderTest, sdkLanguage, testIdAttributeName, stableRafCount: 1, browserName: 'chromium', customEngines: [] });
const injectedScript = new InjectedScript(frameWindow as any, { isUnderTest, frameSeq: 0, sdkLanguage, testIdAttributeName, stableRafCount: 1, browserName: 'chromium', customEngines: [] });
const recorder = new Recorder(injectedScript);
win._injectedScript = injectedScript;
win._recorder = { recorder, frameSelector: parentFrameSelector };
Expand Down
4 changes: 2 additions & 2 deletions tests/page/page-evaluate.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -377,12 +377,12 @@ it('should properly serialize PerformanceMeasure object', async ({ page }) => {
window.builtins.performance.mark('end');
window.builtins.performance.measure('my-measure', 'start', 'end');
return window.builtins.performance.getEntriesByType('measure');
})).toEqual([{
})).toEqual([expect.objectContaining({
duration: expect.any(Number),
entryType: 'measure',
name: 'my-measure',
startTime: expect.any(Number),
}]);
})]);
});

it('should properly serialize window.performance object', async ({ page }) => {
Expand Down
3 changes: 2 additions & 1 deletion tests/page/page-network-response.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -451,8 +451,9 @@ it('Response.formData() should parse multipart/form-data in page context', async
expect(result.fileContent).toBe('hello');
});

it('should give a readable error when response.body() races with navigation', async ({ page, server, browserName }) => {
it('should give a readable error when response.body() races with navigation', async ({ page, server, browserName, trace }) => {
it.skip(browserName === 'firefox', 'Firefox keeps the response body available after navigating away, so it never throws');
it.skip(trace === 'on', 'Tracing fetches response bodies eagerly, so the body is already cached before navigation');
it.info().annotations.push({ type: 'issue', description: 'https://github.com/microsoft/playwright/issues/41512' });
const [response] = await Promise.all([
page.waitForResponse(server.PREFIX + '/title.html'),
Expand Down
Loading