Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
update detached buffer tests
  • Loading branch information
bakkot authored and ljharb committed Feb 8, 2024
commit 911aa6173dd43cbe01b63ef396d58bd16e7e306c
Original file line number Diff line number Diff line change
Expand Up @@ -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 = {};
Expand All @@ -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);
});
Original file line number Diff line number Diff line change
Expand Up @@ -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');
});