Skip to content

Commit 27a0ad9

Browse files
committed
squash: adjust tests
1 parent 7d40cb5 commit 27a0ad9

File tree

4 files changed

+8
-3
lines changed

4 files changed

+8
-3
lines changed

lib/fs.js

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -588,12 +588,17 @@ function openAsBlob(path, options, callback) {
588588
validateObject(options, 'options');
589589
const type = options.type || '';
590590
validateString(type, 'options.type');
591+
validateFunction(callback, 'cb');
591592

592593
let blob;
593594
let cbError = null;
594595
try {
595596
blob = createBlobFromFilePath(pathModule.toNamespacedPath(path), { type });
596597
} catch (err) {
598+
// Permission errors should be thrown instead of being passed to callback
599+
if (err.code === 'ERR_ACCESS_DENIED') {
600+
throw err;
601+
}
597602
cbError = err;
598603
}
599604
callback(cbError, blob);

test/fixtures/permission/fs-read.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -253,7 +253,7 @@ const regularFile = __filename;
253253
// fs.openAsBlob
254254
{
255255
assert.throws(() => {
256-
fs.openAsBlob(blockedFile);
256+
fs.openAsBlob(blockedFile, () => {});
257257
}, common.expectsError({
258258
code: 'ERR_ACCESS_DENIED',
259259
permission: 'FileSystemRead',

test/parallel/test-blob-file-backed.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ const {
99
const { TextDecoder } = require('util');
1010
const {
1111
writeFileSync,
12-
openAsBlob,
12+
promises: { openAsBlob },
1313
} = require('fs');
1414

1515
const {

test/parallel/test-permission-fs-supported.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@ const supportedApis = [
3636
...syncAndAsyncAPI('mkdir'),
3737
...syncAndAsyncAPI('mkdtemp'),
3838
...syncAndAsyncAPI('open'),
39-
'openAsBlob',
39+
...syncAndAsyncAPI('openAsBlob'),
4040
...syncAndAsyncAPI('mkdtemp'),
4141
...syncAndAsyncAPI('readdir'),
4242
...syncAndAsyncAPI('readFile'),

0 commit comments

Comments
 (0)