blob: 7c479a78cdf7fc40d92f74ac21a556a343acb078 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
|
// |reftest| shell-option(--enable-uint8array-base64) skip-if(!Uint8Array.fromBase64||!xulRuntime.shell) -- uint8array-base64 is not enabled unconditionally, requires shell-options
// Copyright (C) 2024 Kevin Gibbons. All rights reserved.
// This code is governed by the BSD license found in the LICENSE file.
/*---
esid: sec-uint8array.prototype.setfrombase64
description: Uint8Array.prototype.setFromBase64 throws if its first argument is not a string
features: [uint8array-base64, TypedArray]
---*/
var toStringCalls = 0;
var throwyToString = {
toString: function() {
toStringCalls += 1;
throw new Test262Error("toString called");
}
};
assert.throws(TypeError, function() {
var target = new Uint8Array(10);
target.setFromBase64(throwyToString);
});
assert.sameValue(toStringCalls, 0);
var optionAccesses = 0;
var touchyOptions = {};
Object.defineProperty(touchyOptions, "alphabet", {
get: function() {
optionAccesses += 1;
throw new Test262Error("alphabet accessed");
}
});
Object.defineProperty(touchyOptions, "lastChunkHandling", {
get: function() {
optionAccesses += 1;
throw new Test262Error("lastChunkHandling accessed");
}
});
assert.throws(TypeError, function() {
var target = new Uint8Array(10);
target.setFromBase64(throwyToString, touchyOptions);
});
assert.sameValue(toStringCalls, 0);
assert.sameValue(optionAccesses, 0);
reportCompare(0, 0);
|