-
Notifications
You must be signed in to change notification settings - Fork 0
fix(accessibility): harden editor metadata runtime contracts #230
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
seonghobae
merged 23 commits into
main
from
fix/accessibility-metadata-runtime-boundary-229
Aug 26, 2026
Merged
Changes from all commits
Commits
Show all changes
23 commits
Select commit
Hold shift + click to select a range
8b3d7d9
test(reliability): expose unbounded accessibility metadata
seonghobae 3b44239
fix(reliability): bound accessibility metadata normalization
seonghobae 75d0008
test(accessibility): reject malformed editor language tags
seonghobae d762601
fix(accessibility): validate editor language tags
seonghobae 64e46d7
test(accessibility): preserve RFC 5646 language-tag forms
seonghobae 6ba8555
fix(accessibility): validate full RFC 5646 tag syntax
seonghobae 7af1227
test(a11y): reject duplicate RFC 5646 subtags
seonghobae e4a7c04
fix(a11y): enforce RFC 5646 subtag uniqueness
seonghobae 210ca6a
test(a11y): cover RFC 5646 private-use suffix
seonghobae c9eb527
test(a11y): consolidate runtime accessibility contracts
seonghobae 04595d1
fix(a11y): consolidate accessibility runtime validation
seonghobae 0551ae3
test(accessibility): reject invalid extlang chains
seonghobae f21e923
fix(accessibility): reject invalid extlang chains
seonghobae fb70eb2
merge(main): synchronize accessibility metadata lane
seonghobae 61842ec
merge: synchronize accessibility metadata hardening with protected main
seonghobae cae7477
test(a11y): reject non-boolean editor accessibility state
seonghobae f5e51c3
fix(a11y): validate editor accessibility editability
seonghobae 9fb8889
chore(a11y): restore canonical metadata test scope
seonghobae 2cc4b5f
chore(a11y): restore canonical accessibility ownership
seonghobae f6aa305
test(accessibility): cover required fallback label boundary
seonghobae a9fc72c
fix(accessibility): bound required fallback label metadata
seonghobae d950d61
test(accessibility): expose finite-state getter TOCTOU
seonghobae 59d82f8
fix(accessibility): snapshot finite runtime metadata
seonghobae File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
169 changes: 169 additions & 0 deletions
169
src/components/editorAccessibility.resourceBoundary.test.ts
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,169 @@ | ||
| import { describe, expect, it } from 'vitest'; | ||
| import { | ||
| buildEditorAccessibilityAttributes, | ||
| type EditorAccessibilityOptions, | ||
| } from './editorAccessibility.js'; | ||
|
|
||
| const ACCESSIBILITY_METADATA_MAX_CODE_UNITS = 65_536; | ||
| const INVALID_ACCESSIBILITY_METADATA_MESSAGE = | ||
| 'Accessibility metadata must be a string within the supported length.'; | ||
| const INVALID_LANGUAGE_TAG_MESSAGE = | ||
| 'Accessibility language tag must be valid BCP 47 metadata.'; | ||
|
|
||
| function attributesWithAriaLabel(value: unknown): Record<string, string> { | ||
| return buildEditorAccessibilityAttributes({ | ||
| defaultLabel: 'Editor', | ||
| editable: true, | ||
| ariaLabel: value as EditorAccessibilityOptions['ariaLabel'], | ||
| }); | ||
| } | ||
|
|
||
| function attributesWithDefaultLabel(value: unknown): Record<string, string> { | ||
| return buildEditorAccessibilityAttributes({ | ||
| defaultLabel: value as EditorAccessibilityOptions['defaultLabel'], | ||
| editable: true, | ||
| }); | ||
| } | ||
|
|
||
| describe('editor accessibility metadata resource boundary', () => { | ||
| it('rejects non-string runtime metadata through one stable error contract', () => { | ||
| expect(() => attributesWithAriaLabel(42)).toThrowError( | ||
| new RangeError(INVALID_ACCESSIBILITY_METADATA_MESSAGE), | ||
| ); | ||
| }); | ||
|
|
||
| it('rejects oversized metadata without reflecting its payload', () => { | ||
| const privateMarker = 'private-accessibility-marker'; | ||
| const value = `${privateMarker}${'x'.repeat(ACCESSIBILITY_METADATA_MAX_CODE_UNITS)}`; | ||
| let failure: unknown; | ||
|
|
||
| try { | ||
| attributesWithAriaLabel(value); | ||
| } catch (error) { | ||
| failure = error; | ||
| } | ||
|
|
||
| expect(failure).toEqual( | ||
| new RangeError(INVALID_ACCESSIBILITY_METADATA_MESSAGE), | ||
| ); | ||
| expect(String(failure)).not.toContain(privateMarker); | ||
| }); | ||
|
|
||
| it('accepts metadata exactly at the local ceiling', () => { | ||
| const value = 'x'.repeat(ACCESSIBILITY_METADATA_MAX_CODE_UNITS); | ||
|
|
||
| expect(attributesWithAriaLabel(value)['aria-label']).toBe(value); | ||
| }); | ||
|
|
||
| it('rejects non-string required fallback labels through the stable metadata error contract', () => { | ||
| expect(() => attributesWithDefaultLabel(42)).toThrowError( | ||
| new RangeError(INVALID_ACCESSIBILITY_METADATA_MESSAGE), | ||
| ); | ||
| }); | ||
|
|
||
| it('rejects oversized required fallback labels without reflecting their payload', () => { | ||
| const privateMarker = 'private-default-label-marker'; | ||
| const value = `${privateMarker}${'x'.repeat(ACCESSIBILITY_METADATA_MAX_CODE_UNITS)}`; | ||
| let failure: unknown; | ||
|
|
||
| try { | ||
| attributesWithDefaultLabel(value); | ||
| } catch (error) { | ||
| failure = error; | ||
| } | ||
|
|
||
| expect(failure).toEqual( | ||
| new RangeError(INVALID_ACCESSIBILITY_METADATA_MESSAGE), | ||
| ); | ||
| expect(String(failure)).not.toContain(privateMarker); | ||
| }); | ||
|
|
||
| it('keeps blank optional metadata omitted after bounded normalization', () => { | ||
| expect( | ||
| buildEditorAccessibilityAttributes({ | ||
| defaultLabel: 'Editor', | ||
| editable: true, | ||
| placeholder: ' ', | ||
| languageTag: ' ', | ||
| ariaLabelledBy: ' ', | ||
| ariaDescribedBy: ' ', | ||
| ariaErrorMessage: ' ', | ||
| }), | ||
| ).toEqual({ | ||
| class: 'cwl-editor__content', | ||
| role: 'textbox', | ||
| 'aria-multiline': 'true', | ||
| 'aria-readonly': 'false', | ||
| 'aria-label': 'Editor', | ||
| }); | ||
| }); | ||
|
|
||
| it('rejects malformed editor language tags without reflecting the payload', () => { | ||
| const privateMarker = 'private-invalid-language-marker'; | ||
| let failure: unknown; | ||
|
|
||
| try { | ||
| buildEditorAccessibilityAttributes({ | ||
| defaultLabel: 'Editor', | ||
| editable: true, | ||
| languageTag: `${privateMarker} not-a-tag`, | ||
| }); | ||
| } catch (error) { | ||
| failure = error; | ||
| } | ||
|
|
||
| expect(failure).toEqual(new RangeError(INVALID_LANGUAGE_TAG_MESSAGE)); | ||
| expect(String(failure)).not.toContain(privateMarker); | ||
| }); | ||
|
|
||
| it('validates but does not canonicalize accepted language tag spelling', () => { | ||
| expect( | ||
| buildEditorAccessibilityAttributes({ | ||
| defaultLabel: 'Editor', | ||
| editable: true, | ||
| languageTag: ' EN-us ', | ||
| }).lang, | ||
| ).toBe('EN-us'); | ||
| }); | ||
|
|
||
| it.each([ | ||
| 'x-private', | ||
| 'i-klingon', | ||
| 'zh-cmn-Hans-CN', | ||
| 'en-US-x-private', | ||
| ])('preserves well-formed RFC 5646 language tag %s', (languageTag) => { | ||
| expect( | ||
| buildEditorAccessibilityAttributes({ | ||
| defaultLabel: 'Editor', | ||
| editable: true, | ||
| languageTag: ` ${languageTag} `, | ||
| }).lang, | ||
| ).toBe(languageTag); | ||
| }); | ||
|
|
||
| it.each(['zh-cmn-hak', 'zh-cmn-hak-yue'])( | ||
| 'rejects RFC 5646 tag with a permanently invalid extra extlang: %s', | ||
| (languageTag) => { | ||
| expect(() => | ||
| buildEditorAccessibilityAttributes({ | ||
| defaultLabel: 'Editor', | ||
| editable: true, | ||
| languageTag, | ||
| }), | ||
| ).toThrowError(new RangeError(INVALID_LANGUAGE_TAG_MESSAGE)); | ||
| }, | ||
| ); | ||
|
|
||
| it.each(['de-DE-1901-1901', 'en-a-bbb-a-ccc'])( | ||
| 'rejects RFC 5646 tag with repeated variant or extension singleton: %s', | ||
| (languageTag) => { | ||
| expect(() => | ||
| buildEditorAccessibilityAttributes({ | ||
| defaultLabel: 'Editor', | ||
| editable: true, | ||
| languageTag, | ||
| }), | ||
| ).toThrowError(new RangeError(INVALID_LANGUAGE_TAG_MESSAGE)); | ||
| }, | ||
| ); | ||
| }); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.