Hacktoberfest 2026:メンテナが10月に向けて印を付けた、オープンで初心者向けの issue。 Hacktoberfest の issue を見る

[Bug]: ariaSnapshot() emits \uXXXX / \b escapes in role names that toMatchAriaSnapshot() parses back incorrectly

クローズ
#43,489 コメント 0 件 リアクション 0 件 担当者 0 名 GitHub で見る

メンテナーはふだん 1 日以内に返信

まだ誰も着手していません。

  • #43490 @alok-108 による — マージされずにクローズ
  • #43522 @yury-s による — マージされずにクローズ

評価

難易度
3/5
見積もり時間
半日
初心者へのやさしさ
22/100
issue の種類
バグ
明瞭さ
明確に書かれている
活発さ
活発
技術スタック
typescript
領域
testing

調査の方向性

Start with createKey() in packages/isomorphic/ariaSnapshotRenderer.ts, which quotes role names with JSON.stringify, and with KeyParser._readString() in packages/isomorphic/ariaSnapshot.ts, which drops the backslash from escapes like \u001f and \b. Run the four-case round-trip spec from the report. Done when those cases pass and the emitted YAML matches its source element. Open PR #43490 already targets this, so check it before starting.

索引モデルが issue の本文から書いたものです。

説明

Version

1.64.1 (the relevant code is unchanged on current main)

Steps to reproduce
  1. Add tests/aria-name-escape.spec.ts to any project with @playwright/test 1.64.1:
import { test, expect } from '@playwright/test';

for (const label of ['a\u0001b', 'a\u001fb', 'a\u0008b', '\ud83d'])
  test(`round trip ${JSON.stringify(label)}`, async ({ page }) => {
    await page.setContent('<button id="b"></button>');
    await page.evaluate(l => document.getElementById('b')!.setAttribute('aria-label', l), label);
    const snapshot = await page.locator('button').ariaSnapshot();
    console.log(JSON.stringify(snapshot));
    // A snapshot generated from an element should match that same element.
    await expect(page.locator('button')).toMatchAriaSnapshot(snapshot);
  });
  1. npx playwright test aria-name-escape
Expected behavior

All four tests pass: the YAML emitted by ariaSnapshot() should match the element it was generated from.

Actual behavior

All four fail. Emitted snapshots:

- button "a\u0001b"
- button "a\u001fb"
- button "a\bb"
- button "\ud83d"

Error:

Error: expect(locator).toMatchAriaSnapshot(expected) failed
Received: serializes to the same string

For comparison, names containing " or \ round-trip fine.

Additional context

createKey() in packages/isomorphic/ariaSnapshotRenderer.ts quotes the role name with JSON.stringify(name), which writes control characters as \uXXXX (and \b for backspace) and lone surrogates as \udXXX.

KeyParser._readString() in packages/isomorphic/ariaSnapshot.ts treats \X as plain X, so \u001f is read back as u001f and \b as b, and the name no longer matches.

Only role names are affected. text: values and listitem content go through the yaml quoting (\x1f), which round-trips correctly.

A possible fix is to decode \uXXXX, \xXX, \b, \t, \n, \r and \f in _readString(), or to make the renderer use the same \xXX escaping as the yaml code. Happy to send a PR for whichever approach the team prefers.

This is a different problem from #43451 (unquoted ~/.inf/.nan scalars) and #43346 (quotes in names, closed).

Environment
System:
  OS: Windows 11 10.0.26200
Binaries:
  Node: 22.14.0
npmPackages:
  @playwright/test: 1.64.1
Browser: Chromium (bundled with 1.64.1)
主要言語
TypeScript
スター
98k
フォーク
6.6k
平均マージ
15時間 28分
マージ済み PR(30日)
279

環境構築

はじめの一歩

  1. issue を最後まで読み、次にプロジェクトのコントリビューションガイドを読みます。
  2. 着手することを issue にコメントします — 二人が同じ作業をするのを防げます。
  3. リポジトリをフォークし、ブランチを切って変更します。
  4. issue 番号を参照したプルリクエストを送ります。

microsoft/playwright のほかの issue

microsoft/playwright の issue をすべて見る

似ている issue

TypeScript の issue をもっと見る

新しい issue をメールで受け取る

初心者向けの GitHub issue を短くまとめたダイジェスト。