Playwright is a framework for Web Testing and Automation. It allows testing Chromium, Firefox and WebKit with a single API.
TypeScript automationchromechromiume2e-testingelectronend-to-end-testingfirefoxjavascriptplaywrighttesttest-automationtestingtesting-toolswebwebkit
chore(aria): always include iframe (#35527)
Simon Knott815938b065d5
diff --git a/packages/injected/src/ariaSnapshot.ts b/packages/injected/src/ariaSnapshot.tsindex dc7bc3d748..0a1bb08fef 100644--- a/packages/injected/src/ariaSnapshot.ts+++ b/packages/injected/src/ariaSnapshot.ts@@ -38,7 +38,7 @@ export type AriaSnapshot = {ids: Builtins.Map<Element, number>;};-export function generateAriaTree(builtins: Builtins, rootElement: Element, generation: number, includeIframe: boolean): AriaSnapshot {+export function generateAriaTree(builtins: Builtins, rootElement: Element, generation: number): AriaSnapshot {const visited = new builtins.Set<Node>();const snapshot: AriaSnapshot = {@@ -87,7 +87,7 @@ export function generateAriaTree(builtins: Builtins, rootElement: Element, gener}addElement(element);- const childAriaNode = toAriaNode(builtins, element, includeIframe);+ const childAriaNode = toAriaNode(builtins, element);if (childAriaNode)ariaNode.children.push(childAriaNode);processElement(childAriaNode || ariaNode, element, ariaChildren);@@ -144,8 +144,8 @@ export function generateAriaTree(builtins: Builtins, rootElement: Element, generreturn snapshot;}-function toAriaNode(builtins: Builtins, element: Element, includeIframe: boolean): AriaNode | null {- if (includeIframe && element.nodeName === 'IFRAME')+function toAriaNode(builtins: Builtins, element: Element): AriaNode | null {+ if (element.nodeName === 'IFRAME')return { role: 'iframe', name: '', children: [], props: {}, element };const role = roleUtils.getAriaRole(element);@@ -235,7 +235,7 @@ export type MatcherReceived = {};export function matchesAriaTree(builtins: Builtins, rootElement: Element, template: AriaTemplateNode): { matches: AriaNode[], received: MatcherReceived } {- const snapshot = generateAriaTree(builtins, rootElement, 0, false);+ const snapshot = generateAriaTree(builtins, rootElement, 0);const matches = matchesNodeDeep(snapshot.root, template, false, false);return {matches,@@ -247,7 +247,7 @@ export function matchesAriaTree(builtins: Builtins, rootElement: Element, templa}export function getAllByAria(builtins: Builtins, rootElement: Element, template: AriaTemplateNode): Element[] {- const root = generateAriaTree(builtins, rootElement, 0, false).root;+ const root = generateAriaTree(builtins, rootElement, 0).root;const matches = matchesNodeDeep(root, template, true, false);return matches.map(n => n.element);}diff --git a/packages/injected/src/injectedScript.ts b/packages/injected/src/injectedScript.tsindex e81aa642a6..ebb57cc23b 100644--- a/packages/injected/src/injectedScript.ts+++ b/packages/injected/src/injectedScript.ts@@ -284,7 +284,7 @@ export class InjectedScript {if (node.nodeType !== Node.ELEMENT_NODE)throw this.createStacklessError('Can only capture aria snapshot of Element nodes.');const generation = (this._lastAriaSnapshot?.generation || 0) + 1;- this._lastAriaSnapshot = generateAriaTree(this.builtins, node as Element, generation, options?.ref ?? false);+ this._lastAriaSnapshot = generateAriaTree(this.builtins, node as Element, generation);return renderAriaTree(this._lastAriaSnapshot, options);}diff --git a/tests/page/page-aria-snapshot.spec.ts b/tests/page/page-aria-snapshot.spec.tsindex c0498a1639..196402361f 100644--- a/tests/page/page-aria-snapshot.spec.ts+++ b/tests/page/page-aria-snapshot.spec.ts@@ -684,17 +684,17 @@ it('should generate refs', async ({ page }) => {expect(e.message).toContain('Error: Stale aria-ref, expected s2e{number}, got s1e3');});-it('ref mode should list iframes', async ({ page }) => {+it('should list iframes', async ({ page }) => {await page.setContent(`<h1>Hello</h1><iframe name="foo" src="data:text/html,<h1>World</h1>">`);const snapshot1 = await page.locator('body').ariaSnapshot({ ref: true });- expect(snapshot1).toContain('- iframe [ref=s1e4]');+ expect(snapshot1).toContain('- iframe');- const frameSnapshot = await page.frameLocator(`aria-ref=s1e4`).locator('body').ariaSnapshot({ ref: true });- expect(frameSnapshot).toEqual('- heading "World" [level=1] [ref=s1e3]');+ const frameSnapshot = await page.frameLocator(`iframe`).locator('body').ariaSnapshot();+ expect(frameSnapshot).toEqual('- heading "World" [level=1]');});it('ref mode can be used to stitch all frame snapshots', async ({ page, server }) => {