diff --git a/components/script_bindings/webidls/TextDecoder.webidl b/components/script_bindings/webidls/TextDecoder.webidl index cc9cf5506db..0cf8694efde 100644 --- a/components/script_bindings/webidls/TextDecoder.webidl +++ b/components/script_bindings/webidls/TextDecoder.webidl @@ -12,12 +12,11 @@ dictionary TextDecodeOptions { boolean stream = false; }; -[Exposed=(Window,Worker)] +[Exposed=*] interface TextDecoder { [Throws] constructor(optional DOMString label = "utf-8", optional TextDecoderOptions options = {}); - readonly attribute DOMString encoding; - readonly attribute boolean fatal; - readonly attribute boolean ignoreBOM; + [Throws] USVString decode(optional BufferSource input, optional TextDecodeOptions options = {}); }; +TextDecoder includes TextDecoderCommon; diff --git a/components/script_bindings/webidls/TextDecoderCommon.webidl b/components/script_bindings/webidls/TextDecoderCommon.webidl new file mode 100644 index 00000000000..a23fb0be3f9 --- /dev/null +++ b/components/script_bindings/webidls/TextDecoderCommon.webidl @@ -0,0 +1,11 @@ +/* This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at https://mozilla.org/MPL/2.0/. */ + +// https://encoding.spec.whatwg.org/#textdecodercommon + +interface mixin TextDecoderCommon { + readonly attribute DOMString encoding; + readonly attribute boolean fatal; + readonly attribute boolean ignoreBOM; +}; diff --git a/components/script_bindings/webidls/TextEncoder.webidl b/components/script_bindings/webidls/TextEncoder.webidl index 7028bb19172..44dad409969 100644 --- a/components/script_bindings/webidls/TextEncoder.webidl +++ b/components/script_bindings/webidls/TextEncoder.webidl @@ -9,11 +9,12 @@ dictionary TextEncoderEncodeIntoResult { unsigned long long written; }; -[Exposed=(Window,Worker)] +[Exposed=*] interface TextEncoder { [Throws] constructor(); - readonly attribute DOMString encoding; + [NewObject] Uint8Array encode(optional USVString input = ""); TextEncoderEncodeIntoResult encodeInto(USVString source, [AllowShared] Uint8Array destination); }; +TextEncoder includes TextEncoderCommon; diff --git a/components/script_bindings/webidls/TextEncoderCommon.webidl b/components/script_bindings/webidls/TextEncoderCommon.webidl new file mode 100644 index 00000000000..de39fa3ba1b --- /dev/null +++ b/components/script_bindings/webidls/TextEncoderCommon.webidl @@ -0,0 +1,9 @@ +/* This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at https://mozilla.org/MPL/2.0/. */ + +// https://encoding.spec.whatwg.org/#textencodercommon + +interface mixin TextEncoderCommon { + readonly attribute DOMString encoding; +};