Merge branch 'main' into sw-server-relative

This commit is contained in:
Simon Knott 2024-11-19 13:09:15 +00:00
commit 9f13f795ce
4 changed files with 20 additions and 6 deletions

View file

@ -383,7 +383,11 @@ export function getAriaLabelledByElements(element: Element): Element[] | null {
const ref = element.getAttribute('aria-labelledby'); const ref = element.getAttribute('aria-labelledby');
if (ref === null) if (ref === null)
return null; return null;
return getIdRefs(element, ref); const refs = getIdRefs(element, ref);
// step 2b:
// "if the current node has an aria-labelledby attribute that contains at least one valid IDREF"
// Therefore, if none of the refs match an element, we consider aria-labelledby to be missing.
return refs.length ? refs : null;
} }
function allowsNameFromContent(role: string, targetDescendant: boolean) { function allowsNameFromContent(role: string, targetDescendant: boolean) {

View file

@ -43,12 +43,12 @@ export async function launchApp(browserType: BrowserType, options: {
} }
const context = await browserType.launchPersistentContext(serverSideCallMetadata(), '', { const context = await browserType.launchPersistentContext(serverSideCallMetadata(), '', {
channel: !options.persistentContextOptions?.executablePath ? findChromiumChannel(options.sdkLanguage) : undefined,
noDefaultViewport: true,
ignoreDefaultArgs: ['--enable-automation'], ignoreDefaultArgs: ['--enable-automation'],
colorScheme: 'no-override',
acceptDownloads: isUnderTest() ? 'accept' : 'internal-browser-default',
...options?.persistentContextOptions, ...options?.persistentContextOptions,
channel: options.persistentContextOptions?.channel ?? (!options.persistentContextOptions?.executablePath ? findChromiumChannel(options.sdkLanguage) : undefined),
noDefaultViewport: options.persistentContextOptions?.noDefaultViewport ?? true,
acceptDownloads: options?.persistentContextOptions?.acceptDownloads ?? (isUnderTest() ? 'accept' : 'internal-browser-default'),
colorScheme: options?.persistentContextOptions?.colorScheme ?? 'no-override',
args, args,
}); });
const [page] = context.pages(); const [page] = context.pages();

View file

@ -495,6 +495,16 @@ test('should not include hidden pseudo into accessible name', async ({ page }) =
expect.soft(await getNameAndRole(page, 'a')).toEqual({ role: 'link', name: 'hello hello' }); expect.soft(await getNameAndRole(page, 'a')).toEqual({ role: 'link', name: 'hello hello' });
}); });
test('should ignore invalid aria-labelledby', async ({ page }) => {
await page.setContent(`
<label>
<span>Text here</span>
<input type=text aria-labelledby="does-not-exist">
</label>
`);
expect.soft(await getNameAndRole(page, 'input')).toEqual({ role: 'textbox', name: 'Text here' });
});
function toArray(x: any): any[] { function toArray(x: any): any[] {
return Array.isArray(x) ? x : [x]; return Array.isArray(x) ? x : [x];
} }

View file

@ -301,7 +301,7 @@ if (watchMode) {
args: [ args: [
'vite', '--config', 'vite.sw.config.ts', 'vite', '--config', 'vite.sw.config.ts',
'build', '--watch', '--minify=false', 'build', '--watch', '--minify=false',
'--outDir', path.join(__dirname, '..', '..', 'packages', 'playwright-core', 'lib', 'vite', 'trace-viewer'), '--outDir', path.join(__dirname, '..', '..', 'packages', 'playwright-core', 'lib', 'vite', 'traceViewer'),
'--emptyOutDir=false' '--emptyOutDir=false'
], ],
shell: true, shell: true,