diff options
Diffstat (limited to 'js')
-rw-r--r-- | js/custom_event.ts | 4 | ||||
-rw-r--r-- | js/custom_event_test.ts | 6 | ||||
-rw-r--r-- | js/event_target.ts | 4 | ||||
-rw-r--r-- | js/event_target_test.ts | 5 | ||||
-rw-r--r-- | js/form_data.ts | 4 | ||||
-rw-r--r-- | js/form_data_test.ts | 5 | ||||
-rw-r--r-- | js/headers.ts | 4 | ||||
-rw-r--r-- | js/headers_test.ts | 5 |
8 files changed, 37 insertions, 0 deletions
diff --git a/js/custom_event.ts b/js/custom_event.ts index 713794e28..5f9e413fb 100644 --- a/js/custom_event.ts +++ b/js/custom_event.ts @@ -52,6 +52,10 @@ export class CustomEvent extends event.Event implements domTypes.CustomEvent { customEventAttributes.set(this, { detail }); } + + get [Symbol.toStringTag](): string { + return "CustomEvent"; + } } /** Built-in objects providing `get` methods for our diff --git a/js/custom_event_test.ts b/js/custom_event_test.ts index 20c901303..2f8f5c1a0 100644 --- a/js/custom_event_test.ts +++ b/js/custom_event_test.ts @@ -19,3 +19,9 @@ test(function customEventInitializedWithDetail() { assertEquals(event.target, null); assertEquals(event.type, type); }); + +test(function toStringShouldBeWebCompatibility() { + const type = "touchstart"; + const event = new CustomEvent(type, {}); + assertEquals(event.toString(), "[object CustomEvent]"); +}); diff --git a/js/event_target.ts b/js/event_target.ts index d6020ce7a..cc436865e 100644 --- a/js/event_target.ts +++ b/js/event_target.ts @@ -53,4 +53,8 @@ export class EventTarget implements domTypes.EventTarget { } return !event.defaultPrevented; } + + get [Symbol.toStringTag](): string { + return "EventTarget"; + } } diff --git a/js/event_target_test.ts b/js/event_target_test.ts index c1c9bb1f4..71c872dab 100644 --- a/js/event_target_test.ts +++ b/js/event_target_test.ts @@ -87,3 +87,8 @@ test(function constructedEventTargetUseObjectPrototype() { target.dispatchEvent(event); assertEquals(callCount, 2); }); + +test(function toStringShouldBeWebCompatibility() { + const target = new EventTarget(); + assertEquals(target.toString(), "[object EventTarget]"); +}); diff --git a/js/form_data.ts b/js/form_data.ts index 3b3096785..1a8a72826 100644 --- a/js/form_data.ts +++ b/js/form_data.ts @@ -136,6 +136,10 @@ class FormDataBase { } } } + + get [Symbol.toStringTag](): string { + return "FormData"; + } } export class FormData extends DomIterableMixin< diff --git a/js/form_data_test.ts b/js/form_data_test.ts index bdf1e7cda..c02811fbc 100644 --- a/js/form_data_test.ts +++ b/js/form_data_test.ts @@ -166,3 +166,8 @@ test(function formDataParamsArgumentsCheck() { ); }); }); + +test(function toStringShouldBeWebCompatibility() { + const formData = new FormData(); + assertEquals(formData.toString(), "[object FormData]"); +}); diff --git a/js/headers.ts b/js/headers.ts index dcb5f4c6a..2f15f14da 100644 --- a/js/headers.ts +++ b/js/headers.ts @@ -125,6 +125,10 @@ class HeadersBase { this._validateValue(newvalue); this[headerMap].set(newname, newvalue); } + + get [Symbol.toStringTag](): string { + return "Headers"; + } } // @internal diff --git a/js/headers_test.ts b/js/headers_test.ts index 4a911f9a5..2e6b48e88 100644 --- a/js/headers_test.ts +++ b/js/headers_test.ts @@ -316,3 +316,8 @@ test(function headerParamsArgumentsCheck() { ); }); }); + +test(function toStringShouldBeWebCompatibility() { + const headers = new Headers(); + assertEquals(headers.toString(), "[object Headers]"); +}); |