mirror of
https://github.com/zoriya/v10.git
synced 2026-08-16 02:45:09 +00:00
feat(core): add i18n foundation with English locale and UI wiring (#1589)
Co-authored-by: Cursor <cursoragent@cursor.com> Co-authored-by: Wesley Luyten <me@wesleyluyten.com>
This commit is contained in:
co-authored by
Cursor
Wesley Luyten
parent
fa768da757
commit
768bf09da0
@@ -49,7 +49,9 @@ export function NativeHlsMediaErrorsMixin<Base extends Constructor<NativeMediaHo
|
||||
const native = target.error;
|
||||
if (!native) return;
|
||||
|
||||
const error = new MediaError(native.message, native.code, true);
|
||||
const code = native.code;
|
||||
const useCanonicalMessage = code >= MediaError.MEDIA_ERR_ABORTED && code <= MediaError.MEDIA_ERR_ENCRYPTED;
|
||||
const error = new MediaError(useCanonicalMessage ? undefined : native.message, code, true);
|
||||
this.#error = error;
|
||||
|
||||
this.dispatchEvent(new ErrorEvent('error', { error, message: error.message }));
|
||||
|
||||
@@ -42,7 +42,20 @@ describe('NativeHlsMediaErrorsMixin', () => {
|
||||
expect(event.error).toBeInstanceOf(MediaError);
|
||||
expect(event.error.code).toBe(MediaError.MEDIA_ERR_NETWORK);
|
||||
expect(event.error.fatal).toBe(true);
|
||||
expect(event.error.message).toBe('network failure');
|
||||
expect(event.error.message).toBe(MediaError.defaultMessages[MediaError.MEDIA_ERR_NETWORK]);
|
||||
});
|
||||
|
||||
it('normalizes browser-specific messages for standard error codes', () => {
|
||||
const { host, video } = setup();
|
||||
|
||||
const handler = vi.fn();
|
||||
host.addEventListener('error', handler);
|
||||
|
||||
fireNativeError(video, MediaError.MEDIA_ERR_SRC_NOT_SUPPORTED, 'Failed to open media');
|
||||
|
||||
const event = handler.mock.calls[0]![0] as ErrorEvent;
|
||||
expect(event.error.code).toBe(MediaError.MEDIA_ERR_SRC_NOT_SUPPORTED);
|
||||
expect(event.error.message).toBe(MediaError.defaultMessages[MediaError.MEDIA_ERR_SRC_NOT_SUPPORTED]);
|
||||
});
|
||||
|
||||
it('uses default message when native error has no message', () => {
|
||||
@@ -63,10 +76,11 @@ describe('NativeHlsMediaErrorsMixin', () => {
|
||||
|
||||
expect(host.error).toBeNull();
|
||||
|
||||
fireNativeError(video, MediaError.MEDIA_ERR_SRC_NOT_SUPPORTED, 'unsupported');
|
||||
fireNativeError(video, MediaError.MEDIA_ERR_SRC_NOT_SUPPORTED, 'Failed to open media');
|
||||
|
||||
expect(host.error).toBeInstanceOf(MediaError);
|
||||
expect(host.error!.code).toBe(MediaError.MEDIA_ERR_SRC_NOT_SUPPORTED);
|
||||
expect(host.error!.message).toBe(MediaError.defaultMessages[MediaError.MEDIA_ERR_SRC_NOT_SUPPORTED]);
|
||||
});
|
||||
|
||||
it('stops propagation of the native error event', () => {
|
||||
|
||||
@@ -29,6 +29,6 @@ describe('NativeHlsMedia', () => {
|
||||
expect(event).toBeInstanceOf(ErrorEvent);
|
||||
expect(event.error).toBeInstanceOf(MediaError);
|
||||
expect(event.error.code).toBe(MediaError.MEDIA_ERR_NETWORK);
|
||||
expect(event.error.message).toBe('network failure');
|
||||
expect(event.error.message).toBe(MediaError.defaultMessages[MediaError.MEDIA_ERR_NETWORK]);
|
||||
});
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user