update detached buffer tests

This commit is contained in:
Kevin Gibbons 2024-02-07 16:43:17 -08:00 committed by Jordan Harband
parent 07807bd544
commit 911aa6173d
No known key found for this signature in database
GPG Key ID: 9F6A681E35EF8B56
2 changed files with 11 additions and 12 deletions

View File

@ -2,16 +2,16 @@
// This code is governed by the BSD license found in the LICENSE file.
/*---
esid: sec-uint8array.prototype.setfrombase64
description: Uint8Array.prototype.setFromBase64 does not write to or error on detatched buffers
description: Uint8Array.prototype.setFromBase64 throws on detatched buffers
includes: [detachArrayBuffer.js]
features: [uint8array-base64]
---*/
var target = new Uint8Array([255, 255, 255]);
$DETACHBUFFER(target.buffer);
var result = target.setFromBase64('Zg==');
assert.sameValue(result.read, 0);
assert.sameValue(result.written, 0);
assert.throws(TypeError, function() {
target.setFromBase64('Zg==');
});
var getterCalls = 0;
var targetDetachingOptions = {};
@ -23,7 +23,6 @@ Object.defineProperty(targetDetachingOptions, 'alphabet', {
}
});
var target = new Uint8Array([255, 255, 255]);
var result = target.setFromBase64('Zg==', targetDetachingOptions);
assert.sameValue(getterCalls, 1);
assert.sameValue(result.read, 0);
assert.sameValue(result.written, 0);
assert.throws(TypeError, function() {
target.setFromBase64('Zg==', targetDetachingOptions);
});

View File

@ -2,13 +2,13 @@
// This code is governed by the BSD license found in the LICENSE file.
/*---
esid: sec-uint8array.prototype.setfromhex
description: Uint8Array.prototype.setFromHex does not write to or error on detatched buffers
description: Uint8Array.prototype.setFromHex throws on detatched buffers
includes: [detachArrayBuffer.js]
features: [uint8array-base64]
---*/
var target = new Uint8Array([255, 255, 255]);
$DETACHBUFFER(target.buffer);
var result = target.setFromHex('aa');
assert.sameValue(result.read, 0);
assert.sameValue(result.written, 0);
assert.throws(TypeError, function() {
target.setFromHex('aa');
});