Bug 1811347 - Remove useless parameter from TextEncoder constructor r=emk,webdriver-reviewers,extension-reviewers,credential-management-reviewers,dimi,jdescottes,willdurand

Differential Revision: https://phabricator.services.mozilla.com/D167488
This commit is contained in:
Gregory Pappas 2023-01-23 15:41:49 +00:00
Родитель 9e889916c5
Коммит 5d44f7a543
45 изменённых файлов: 67 добавлений и 83 удалений

Просмотреть файл

@ -46,7 +46,7 @@ function getUint8Memory0() {
return cachedUint8Memory0;
}
const cachedTextEncoder = new TextEncoder('utf-8');
const cachedTextEncoder = new TextEncoder();
const encodeString = (typeof cachedTextEncoder.encodeInto === 'function'
? function (arg, view) {

Просмотреть файл

@ -74,7 +74,7 @@ function test_base64URLEncode() {
testEncode(decoded, encoded);
}
let textEncoder = new TextEncoder("utf-8");
let textEncoder = new TextEncoder();
for (let decoded of Object.keys(textTests)) {
let input = textEncoder.encode(decoded);
testEncode(input, textTests[decoded]);
@ -132,7 +132,7 @@ function test_base64URLDecode() {
testDecode(encoded, decoded);
}
let textEncoder = new TextEncoder("utf-8");
let textEncoder = new TextEncoder();
for (let decoded of Object.keys(textTests)) {
let expectedBuffer = textEncoder.encode(decoded);
testDecode(textTests[decoded], expectedBuffer);

Просмотреть файл

@ -695,10 +695,8 @@ let tv = {
// RFC 6070 <http://tools.ietf.org/html/rfc6070>
pbkdf2_sha1: {
password: new TextEncoder("utf-8").encode("passwordPASSWORDpassword"),
salt: new TextEncoder("utf-8").encode(
"saltSALTsaltSALTsaltSALTsaltSALTsalt"
),
password: new TextEncoder().encode("passwordPASSWORDpassword"),
salt: new TextEncoder().encode("saltSALTsaltSALTsaltSALTsaltSALTsalt"),
iterations: 4096,
length: 25 * 8,
@ -712,10 +710,8 @@ let tv = {
// https://stackoverflow.com/questions/5130513/pbkdf2-hmac-sha2-test-vectors
pbkdf2_sha256: {
password: new TextEncoder("utf-8").encode("passwordPASSWORDpassword"),
salt: new TextEncoder("utf-8").encode(
"saltSALTsaltSALTsaltSALTsaltSALTsalt"
),
password: new TextEncoder().encode("passwordPASSWORDpassword"),
salt: new TextEncoder().encode("saltSALTsaltSALTsaltSALTsaltSALTsalt"),
iterations: 4096,
length: 40 * 8,
@ -739,9 +735,7 @@ let tv = {
pbkdf2_sha256_no_pwd: {
password: new Uint8Array(),
salt: new TextEncoder("utf-8").encode(
"saltSALTsaltSALTsaltSALTsaltSALTsalt"
),
salt: new TextEncoder().encode("saltSALTsaltSALTsaltSALTsaltSALTsalt"),
length: 32 * 8,
iterations: 1,

Просмотреть файл

@ -28,7 +28,7 @@ TestArray.addTest(
function() {
var that = this;
var alg = "PBKDF2";
var key = new TextEncoder("utf-8").encode("password");
var key = new TextEncoder().encode("password");
crypto.subtle.importKey("raw", key, alg, false, ["deriveKey"]).then(
complete(that, hasKeyFields),
@ -42,7 +42,7 @@ TestArray.addTest(
"Unwrapping a PBKDF2 key in PKCS8 format should fail",
function() {
var that = this;
var pbkdf2Key = new TextEncoder("utf-8").encode("password");
var pbkdf2Key = new TextEncoder().encode("password");
var alg = {name: "AES-GCM", length: 256, iv: new Uint8Array(16)};
var wrappingKey;

Просмотреть файл

@ -107,7 +107,7 @@ TestArray.addTest(
"Structured Cloning: PBKDF2",
function() {
var that = this;
var key = new TextEncoder("utf-8").encode("password");
var key = new TextEncoder().encode("password");
var alg = {
name: "PBKDF2",
@ -128,7 +128,7 @@ TestArray.addTest(
"Structured Cloning: HKDF",
function() {
var that = this;
var key = new TextEncoder("utf-8").encode("password");
var key = new TextEncoder().encode("password");
var alg = {
name: "HKDF",

Просмотреть файл

@ -385,7 +385,7 @@ TestArray.addTest(
var wrapKey;
function doBogusWrap() {
var abv = new TextEncoder("utf-8").encode("I am so not JSON");
var abv = new TextEncoder().encode("I am so not JSON");
return crypto.subtle.encrypt(wrapAlg, wrapKey, abv);
}
function doUnwrap(wrappedKey) {

Просмотреть файл

@ -11,7 +11,7 @@ test(function() {
];
badStrings.forEach(function(t) {
var encoded = new TextEncoder("utf-8").encode(t.input);
var encoded = new TextEncoder().encode(t.input);
var decoded = new TextDecoder("utf-8").decode(encoded);
assert_equals(t.expected, decoded);
});
@ -323,7 +323,7 @@ test(function() {
0xff,
],
};
var encoded = octets[encoding] || new TextEncoder(encoding).encode(string);
var encoded = octets[encoding] || new TextEncoder().encode(string);
for (var len = 1; len <= 5; ++len) {
var out = "",
@ -406,13 +406,13 @@ test(function() {
string += String.fromCharCode(i);
bytes.push(i);
}
var ascii_encoded = new TextEncoder("utf-8").encode(string);
var ascii_encoded = new TextEncoder().encode(string);
assert_equals(
new TextDecoder(encoding).decode(ascii_encoded),
string,
encoding
);
//assert_array_equals(new TextEncoder(encoding).encode(string), bytes, encoding);
//assert_array_equals(new TextEncoder().encode(string), bytes, encoding);
});
}, "Supersets of ASCII decode ASCII correctly");

Просмотреть файл

@ -1678,7 +1678,7 @@ class RTCPeerConnection {
// At least 65536/2 UTF-16 characters. UTF-8 might be too long.
// Spec says to check how long |protocol| and |label| are in _bytes_. This
// is a little ambiguous. For now, examine the length of the utf-8 encoding.
const byteCounter = new TextEncoder("utf-8");
const byteCounter = new TextEncoder();
if (byteCounter.encode(protocol).length > 65535) {
throw new this._win.TypeError(
@ -1688,7 +1688,7 @@ class RTCPeerConnection {
}
if (label.length > 32767) {
const byteCounter = new TextEncoder("utf-8");
const byteCounter = new TextEncoder();
if (byteCounter.encode(label).length > 65535) {
throw new this._win.TypeError(
"label cannot be longer than 65535 bytes"

Просмотреть файл

@ -287,7 +287,7 @@ PeerConnectionTest.prototype.send = async function(data, options) {
} else if (d instanceof ArrayBuffer) {
return d.byteLength;
} else if (d instanceof String || typeof d === "string") {
return new TextEncoder("utf-8").encode(d).length;
return new TextEncoder().encode(d).length;
} else {
ok(false);
}

Просмотреть файл

@ -11,7 +11,7 @@ XPCOMUtils.defineLazyGetter(lazy, "gDOMBundle", () =>
);
// getCryptoParamsFromHeaders is exported for test purposes.
const UTF8 = new TextEncoder("utf-8");
const UTF8 = new TextEncoder();
const ECDH_KEY = { name: "ECDH", namedCurve: "P-256" };
const ECDSA_KEY = { name: "ECDSA", namedCurve: "P-256" };

Просмотреть файл

@ -54,7 +54,7 @@ http://creativecommons.org/licenses/publicdomain/
var idCounter = 1;
function waitForDeliveryError(request) {
return new Promise(resolve => {
var data = new TextEncoder("utf-8").encode(JSON.stringify(request));
var data = new TextEncoder().encode(JSON.stringify(request));
var principal = SpecialPowers.wrap(window).clientPrincipal;
let messageId = "message-" + (idCounter++);

Просмотреть файл

@ -20,10 +20,8 @@
namedCurve: "P-256",
};
var webCrypto = g.crypto.subtle;
var ENCRYPT_INFO = new TextEncoder("utf-8").encode(
"Content-Encoding: aesgcm128"
);
var NONCE_INFO = new TextEncoder("utf-8").encode("Content-Encoding: nonce");
var ENCRYPT_INFO = new TextEncoder().encode("Content-Encoding: aesgcm128");
var NONCE_INFO = new TextEncoder().encode("Content-Encoding: nonce");
function chunkArray(array, size) {
var start = array.byteOffset || 0;
@ -86,7 +84,7 @@
/* Coerces data into a Uint8Array */
function ensureView(data) {
if (typeof data === "string") {
return new TextEncoder("utf-8").encode(data);
return new TextEncoder().encode(data);
}
if (data instanceof ArrayBuffer) {
return new Uint8Array(data);

Просмотреть файл

@ -52,7 +52,7 @@ add_task(async function static_aes128gcm() {
ciphertext: from64(`DGv6ra1nlYgDCS1FRnbzlwAAEABBBP4z9KsN6nGRTbVYI_c7VJSPQTBtkgcy27ml
mlMoZIIgDll6e3vCYLocInmYWAmS6TlzAC8wEqKK6PBru3jl7A_yl95bQpu6cVPT
pK4Mqgkf1CXztLVBSt2Ks3oZwbuwXPXLWyouBWLVWGNWQexSgSxsj_Qulcy4a-fN`),
plaintext: new TextEncoder("utf-8").encode(
plaintext: new TextEncoder().encode(
"When I grow up, I want to be a watermelon"
),
authSecret: from64("BTBZMqHH6r4Tts7J_aSIgg"),
@ -107,7 +107,7 @@ add_task(async function static_aes128gcm() {
add_task(async function aes128gcm_simple() {
let [recvPublicKey, recvPrivateKey] = await PushCrypto.generateKeys();
let message = new TextEncoder("utf-8").encode("Fast for good.");
let message = new TextEncoder().encode("Fast for good.");
let authSecret = crypto.getRandomValues(new Uint8Array(16));
let { ciphertext, encoding } = await PushCrypto.encrypt(
message,
@ -133,7 +133,7 @@ add_task(async function aes128gcm_rs() {
for (let rs of [-1, 0, 1, 17]) {
let payload = "x".repeat(1024);
info(`testing expected failure with rs=${rs}`);
let message = new TextEncoder("utf-8").encode(payload);
let message = new TextEncoder().encode(payload);
let authSecret = crypto.getRandomValues(new Uint8Array(16));
await Assert.rejects(
PushCrypto.encrypt(message, recvPublicKey, authSecret, { rs }),
@ -143,7 +143,7 @@ add_task(async function aes128gcm_rs() {
for (let rs of [18, 50, 1024, 4096, 16384]) {
info(`testing expected success with rs=${rs}`);
let payload = "x".repeat(rs * 3);
let message = new TextEncoder("utf-8").encode(payload);
let message = new TextEncoder().encode(payload);
let authSecret = crypto.getRandomValues(new Uint8Array(16));
let { ciphertext, encoding } = await PushCrypto.encrypt(
message,
@ -179,7 +179,7 @@ add_task(async function aes128gcm_edgecases() {
10240,
]) {
info(`testing encryption of ${size} byte payload`);
let message = new TextEncoder("utf-8").encode("x".repeat(size));
let message = new TextEncoder().encode("x".repeat(size));
let authSecret = crypto.getRandomValues(new Uint8Array(16));
let { ciphertext, encoding } = await PushCrypto.encrypt(
message,

Просмотреть файл

@ -7,7 +7,7 @@ var systemPrincipal = Services.scriptSecurityManager.getSystemPrincipal();
add_task(async function test_notifyWithData() {
let textData = '{"hello":"world"}';
let payload = new TextEncoder("utf-8").encode(textData);
let payload = new TextEncoder().encode(textData);
let notifyPromise = promiseObserverNotification(
PushServiceComponent.pushTopic

Просмотреть файл

@ -89,7 +89,7 @@ var waitForNotifierObservers = async function(
);
let scope = "chrome://test-scope";
let data = new TextEncoder("utf-8").encode(text);
let data = new TextEncoder().encode(text);
if (shouldNotify) {
pushNotifier.notifyPushWithData(scope, principal, "", data);

Просмотреть файл

@ -261,7 +261,7 @@ function iterateForOf(iter) {
}
function byteInflate(str) {
var encoder = new TextEncoder("utf-8");
var encoder = new TextEncoder();
var encoded = encoder.encode(str);
var result = "";
for (var i = 0; i < encoded.length; ++i) {

Просмотреть файл

@ -73,7 +73,7 @@ add_task(async function test_appid() {
.then(arrivingHereIsBad)
.catch(expectInvalidStateError);
let rpId = new TextEncoder("utf-8").encode(appid);
let rpId = new TextEncoder().encode(appid);
let rpIdHash = await crypto.subtle.digest("SHA-256", rpId);
// Succeed with the right fallback rpId.

Просмотреть файл

@ -73,7 +73,7 @@ add_task(async function test_appid() {
.then(arrivingHereIsBad)
.catch(expectInvalidStateError);
let rpId = new TextEncoder("utf-8").encode(appid);
let rpId = new TextEncoder().encode(appid);
let rpIdHash = await crypto.subtle.digest("SHA-256", rpId);
// Succeed with the right fallback rpId.

Просмотреть файл

@ -13,14 +13,14 @@ function run_test() {
sb.equal = equal;
let innerPromise = new Promise(r => (sb.test_done = r));
Cu.evalInSandbox('crypto.subtle.digest("SHA-256", ' +
' new TextEncoder("utf-8").encode("abc"))' +
' new TextEncoder().encode("abc"))' +
' .then(h => equal(new Uint16Array(h)[0], 30906))' +
' .then(test_done);', sb);
Cu.importGlobalProperties(["crypto"]);
ok(crypto);
ok(crypto.subtle);
let outerPromise = crypto.subtle.digest("SHA-256", new TextEncoder("utf-8").encode("abc"))
let outerPromise = crypto.subtle.digest("SHA-256", new TextEncoder().encode("abc"))
.then(h => Assert.equal(new Uint16Array(h)[0], 30906));
do_test_pending();

Просмотреть файл

@ -258,7 +258,7 @@ function basic_auth(metadata, response) {
// Digest functions
//
function bytesFromString(str) {
const encoder = new TextEncoder("utf-8");
const encoder = new TextEncoder();
return encoder.encode(str);
}

Просмотреть файл

@ -175,7 +175,7 @@ capture.toBase64 = function(canvas) {
*/
capture.toHash = function(canvas) {
let u = capture.toBase64(canvas);
let buffer = new TextEncoder("utf-8").encode(u);
let buffer = new TextEncoder().encode(u);
return crypto.subtle.digest("SHA-256", buffer).then(hash => hex(hash));
};

Просмотреть файл

@ -13,7 +13,7 @@ CertPasswordPromptDefault=Please enter your Primary Password.
# It's possible to verify the length of a translation using the Browser Console
# in Firefox and evaluating the following code:
#
# (new TextEncoder('utf-8').encode('YOURSTRING')).length
# (new TextEncoder().encode('YOURSTRING')).length
#
# Simply replace YOURSTRING with your translation.
#

Просмотреть файл

@ -264,7 +264,7 @@ class SendTab {
async send(to, tab) {
log.info(`Sending a tab to ${to.length} devices.`);
const flowID = this._fxai.telemetry.generateFlowID();
const encoder = new TextEncoder("utf8");
const encoder = new TextEncoder();
const data = { entries: [{ title: tab.title, url: tab.url }] };
const report = {
succeeded: [],

Просмотреть файл

@ -615,7 +615,7 @@ class FxAccountsKeys {
scopedKeyMetadata.keyRotationSecret
);
const salt = CommonUtils.hexToArrayBuffer(uid);
const context = new TextEncoder("utf8").encode(
const context = new TextEncoder().encode(
"identity.mozilla.com/picl/v1/scoped_key\n" + scopedKeyMetadata.identifier
);

Просмотреть файл

@ -228,7 +228,7 @@ add_task(async function test_sendtab_receive_old_client() {
// No 'flowID' in the encrypted payload, no 'streamID' anywhere.
const payload = {
flowID: "flow-id",
encrypted: new TextEncoder("utf8").encode(JSON.stringify(data)),
encrypted: new TextEncoder().encode(JSON.stringify(data)),
};
const reason = "push";
await sendTab.handle("sender-id", payload, reason);

Просмотреть файл

@ -775,11 +775,7 @@ XPCOMUtils.defineLazyGetter(Utils, "_utf8Converter", function() {
return converter;
});
XPCOMUtils.defineLazyGetter(
Utils,
"utf8Encoder",
() => new TextEncoder("utf-8")
);
XPCOMUtils.defineLazyGetter(Utils, "utf8Encoder", () => new TextEncoder());
/*
* Commonly-used services

Просмотреть файл

@ -50,7 +50,7 @@ function toByteArray(data) {
tmpData = JSON.stringify(tmpData);
if (typeof tmpData === 'string')
byteArray = new TextEncoder('utf-8').encode(tmpData);
byteArray = new TextEncoder().encode(tmpData);
return byteArray;
}

Просмотреть файл

@ -47,7 +47,7 @@ function nfc_test(func, name, properties) {
}
const test_text_data = 'Test text data.';
const test_text_byte_array = new TextEncoder('utf-8').encode(test_text_data);
const test_text_byte_array = new TextEncoder().encode(test_text_data);
const test_number_data = 42;
const test_json_data = {level: 1, score: 100, label: 'Game'};
const test_url_data = 'https://w3c.github.io/web-nfc/';
@ -124,7 +124,7 @@ function createTextRecord(data, encoding, lang) {
function createMimeRecordFromJson(json) {
return createRecord(
'mime', new TextEncoder('utf-8').encode(JSON.stringify(json)),
'mime', new TextEncoder().encode(JSON.stringify(json)),
test_record_id, 'application/json');
}

Просмотреть файл

@ -25,7 +25,7 @@ standardSetup(function() {
// The extension results will be in the authenticator outputs.
assert_true(new Uint8Array(credential.response.getAuthenticatorData())
.toString()
.includes(new TextEncoder("utf-8")
.includes(new TextEncoder()
.encode("minPinLength")
.toString()));
}, "navigator.credentials.create() with minPinLength requested");

Просмотреть файл

@ -24,7 +24,7 @@ const AUTHENTICATOR_SELECTION_CRITERIA = {
};
const MAKE_CREDENTIAL_OPTIONS = {
challenge: new TextEncoder("utf-8").encode(CHALLENGE),
challenge: new TextEncoder().encode(CHALLENGE),
rp: PUBLIC_KEY_RP,
user: PUBLIC_KEY_USER,
pubKeyCredParams: PUBLIC_KEY_PARAMETERS,

Просмотреть файл

@ -40,7 +40,7 @@ promise_test(async t => {
new Cbor(credential.response.attestationObject).getCBOR();
let rpIdHash = new Uint8Array(await crypto.subtle.digest(
{ name: "SHA-256" }, new TextEncoder("utf-8").encode(PUBLIC_KEY_RP.id)));
{ name: "SHA-256" }, new TextEncoder().encode(PUBLIC_KEY_RP.id)));
let authenticatorData = parseAuthenticatorData(attestationObject.authData);
@ -59,7 +59,7 @@ promise_test(async t => {
promise_test(async t => {
let assertion = await navigator.credentials.get({
publicKey: {
challenge: new TextEncoder("utf-8").encode(CHALLENGE),
challenge: new TextEncoder().encode(CHALLENGE),
rpId: PUBLIC_KEY_RP.id,
allowCredentials: [{
type: "public-key",
@ -87,7 +87,7 @@ promise_test(async t => {
let authenticatorData = parseAuthenticatorData(binaryAuthenticatorData);
let rpIdHash = new Uint8Array(await crypto.subtle.digest(
{ name: "SHA-256" }, new TextEncoder("utf-8").encode(PUBLIC_KEY_RP.id)));
{ name: "SHA-256" }, new TextEncoder().encode(PUBLIC_KEY_RP.id)));
assert_array_equals(authenticatorData.rpIdHash, rpIdHash)
assert_true(authenticatorData.flags.up);

Просмотреть файл

@ -521,7 +521,7 @@ ExtensionTestCommon = class ExtensionTestCommon {
for (let filename in files) {
let script = files[filename];
if (!instanceOf(script, "ArrayBuffer")) {
script = new TextEncoder("utf-8").encode(script).buffer;
script = new TextEncoder().encode(script).buffer;
}
let stream = Cc[

Просмотреть файл

@ -375,9 +375,7 @@ add_task(async function test_filter_302() {
filter.ondata = event => {
const script = "forceError();";
filter.write(
new Uint8Array(new TextEncoder("utf-8").encode(script))
);
filter.write(new Uint8Array(new TextEncoder().encode(script)));
filter.close();
browser.test.sendMessage("filter-ondata");
};

Просмотреть файл

@ -268,7 +268,7 @@ const TASKS = [
{
url: "slow_response.sjs",
task(filter, resolve, num) {
let encoder = new TextEncoder("utf-8");
let encoder = new TextEncoder();
filter.onstop = event => {
browser.test.fail(
@ -344,7 +344,7 @@ const TASKS = [
{
url: "slow_response.sjs",
task(filter, resolve, num) {
let encoder = new TextEncoder("utf-8");
let encoder = new TextEncoder();
let decoder = new TextDecoder("utf-8");
filter.onstop = event => {

Просмотреть файл

@ -34,7 +34,7 @@ add_task(async function test_StreamFilter_at_restart() {
details => {
let filter = browser.webRequest.filterResponseData(details.requestId);
filter.onstop = () => {
let encoded = new TextEncoder("utf-8").encode(data);
let encoded = new TextEncoder().encode(data);
filter.write(encoded);
filter.close();
};

Просмотреть файл

@ -232,7 +232,7 @@ function sha512(string) {
if (string == null) {
return null;
}
let encoder = new TextEncoder("utf-8");
let encoder = new TextEncoder();
let bytes = encoder.encode(string);
let hash = new CryptoHash("sha512");
hash.update(bytes, bytes.length);

Просмотреть файл

@ -92,8 +92,7 @@ var writeAtomic = function(path, buffer, options = {}) {
if (typeof buffer == "string") {
// Normalize buffer to a C buffer by encoding it
let encoding = options.encoding || "utf-8";
buffer = new TextEncoder(encoding).encode(buffer);
buffer = new TextEncoder().encode(buffer);
}
if (ArrayBuffer.isView(buffer)) {

Просмотреть файл

@ -432,8 +432,7 @@ if (typeof Components != "undefined") {
if (typeof buffer == "string") {
// Normalize buffer to a C buffer by encoding it
let encoding = options.encoding || "utf-8";
buffer = new TextEncoder(encoding).encode(buffer);
buffer = new TextEncoder().encode(buffer);
}
if ("compression" in options && options.compression == "lz4") {

Просмотреть файл

@ -2385,7 +2385,7 @@ PlacesUtils.metadata = {
},
_base64Encode(str) {
return ChromeUtils.base64URLEncode(new TextEncoder("utf-8").encode(str), {
return ChromeUtils.base64URLEncode(new TextEncoder().encode(str), {
pad: true,
});
},

Просмотреть файл

@ -327,7 +327,7 @@ export var SearchUtils = {
name +
disclaimer.replace(/\$appName/g, Services.appinfo.name);
let data = new TextEncoder("utf-8").encode(salt);
let data = new TextEncoder().encode(salt);
let hasher = Cc["@mozilla.org/security/hash;1"].createInstance(
Ci.nsICryptoHash
);

Просмотреть файл

@ -486,7 +486,7 @@ var Impl = {
const payload = {};
payload.encryptedData = await lazy.jwcrypto.generateJWE(
aOptions.publicKey,
new TextEncoder("utf-8").encode(JSON.stringify(aPayload))
new TextEncoder().encode(JSON.stringify(aPayload))
);
payload.schemaVersion = aOptions.schemaVersion;

Просмотреть файл

@ -55,7 +55,7 @@ function write_string_to_file(file, contents) {
);
bos.setOutputStream(ostream);
let utf8 = new TextEncoder("utf-8").encode(contents);
let utf8 = new TextEncoder().encode(contents);
bos.writeByteArray(utf8);
ostream.QueryInterface(Ci.nsISafeOutputStream).finish();
ostream.close();

Просмотреть файл

@ -73,7 +73,7 @@ var Sampling = {
*/
async truncatedHash(data) {
const hasher = crypto.subtle;
const input = new TextEncoder("utf-8").encode(JSON.stringify(data));
const input = new TextEncoder().encode(JSON.stringify(data));
const hash = await hasher.digest("SHA-256", input);
// truncate hash to 12 characters (2^48), because the full hash is larger
// than JS can meaningfully represent as a number.

Просмотреть файл

@ -33,7 +33,7 @@ function encodeEnvVar(name, value) {
return `${name}=${value}`;
}
let encoder = new TextEncoder("utf-8");
let encoder = new TextEncoder();
function encode(val) {
return typeof val === "string" ? encoder.encode(val) : val;
}

Просмотреть файл

@ -966,7 +966,7 @@ var AddonTestUtils = {
data = JSON.stringify(data);
}
if (!(data instanceof ArrayBuffer)) {
data = new TextEncoder("utf-8").encode(data).buffer;
data = new TextEncoder().encode(data).buffer;
}
let stream = ArrayBufferInputStream(data, 0, data.byteLength);