Skip to content

Commit e3d98c3

Browse files
KhafraDevRafaelGSS
authored andcommitted
buffer: use private properties for brand checks in File
PR-URL: #47154 Refs: #46904 Reviewed-By: Yagiz Nizipli <[email protected]> Reviewed-By: Luigi Pinca <[email protected]>
1 parent a3bffba commit e3d98c3

File tree

2 files changed

+11
-15
lines changed

2 files changed

+11
-15
lines changed

lib/internal/file.js

-9
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,6 @@ const {
2121

2222
const {
2323
codes: {
24-
ERR_INVALID_THIS,
2524
ERR_MISSING_ARGS,
2625
},
2726
} = require('internal/errors');
@@ -64,18 +63,10 @@ class File extends Blob {
6463
}
6564

6665
get name() {
67-
if (!this || !(#name in this)) {
68-
throw new ERR_INVALID_THIS('File');
69-
}
70-
7166
return this.#name;
7267
}
7368

7469
get lastModified() {
75-
if (!this || !(#name in this)) {
76-
throw new ERR_INVALID_THIS('File');
77-
}
78-
7970
return this.#lastModified;
8071
}
8172

test/parallel/test-file.js

+11-6
Original file line numberDiff line numberDiff line change
@@ -146,10 +146,15 @@ const { inspect } = require('util');
146146

147147
{
148148
const getter = Object.getOwnPropertyDescriptor(File.prototype, 'name').get;
149-
assert.throws(
150-
() => getter.call(undefined), // eslint-disable-line no-useless-call
151-
{
152-
code: 'ERR_INVALID_THIS',
153-
}
154-
);
149+
150+
[
151+
undefined,
152+
null,
153+
true,
154+
].forEach((invalidThis) => {
155+
assert.throws(
156+
() => getter.call(invalidThis),
157+
TypeError
158+
);
159+
});
155160
}

0 commit comments

Comments
 (0)