Skip to content

Commit a78c18a

Browse files
Test with both allowShared and allowResizable
1 parent d9501fe commit a78c18a

File tree

1 file changed

+50
-0
lines changed

1 file changed

+50
-0
lines changed

test/buffer-source.js

Lines changed: 50 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -319,6 +319,23 @@ for (const type of bufferSourceConstructors) {
319319

320320
commonNotOk(allowResizableSUT);
321321
});
322+
323+
describe("with [AllowShared, AllowResizable]", () => {
324+
const allowSharedAndResizableSUT = (v, opts) => {
325+
return conversions[typeName](v, { ...opts, allowShared: true, allowResizable: true });
326+
};
327+
328+
for (const { label, creator, typeName: innerTypeName, isDetached, isForged } of bufferSourceCreators) {
329+
const testFunction = innerTypeName === typeName &&
330+
!isDetached &&
331+
!isForged ?
332+
testOk :
333+
testNotOk;
334+
testFunction(label, allowSharedAndResizableSUT, creator);
335+
}
336+
337+
commonNotOk(allowSharedAndResizableSUT);
338+
});
322339
});
323340
}
324341

@@ -415,6 +432,26 @@ describe("WebIDL ArrayBufferView type", () => {
415432

416433
commonNotOk(allowResizableSUT);
417434
});
435+
436+
describe("with [AllowShared, AllowResizable]", () => {
437+
const allowResizableSUT = (v, opts) => {
438+
return conversions.ArrayBufferView(v, { ...opts, allowShared: true, allowResizable: true });
439+
};
440+
441+
for (const { label, creator, typeName, isDetached, isForged } of bufferSourceCreators) {
442+
const testFunction =
443+
typeName !== "ArrayBuffer" &&
444+
typeName !== "SharedArrayBuffer" &&
445+
!isDetached &&
446+
!isForged ?
447+
testOk :
448+
testNotOk;
449+
450+
testFunction(label, allowResizableSUT, creator);
451+
}
452+
453+
commonNotOk(allowResizableSUT);
454+
});
418455
});
419456

420457
describe("WebIDL BufferSource type", () => {
@@ -448,4 +485,17 @@ describe("WebIDL BufferSource type", () => {
448485

449486
commonNotOk(allowResizableSUT);
450487
});
488+
489+
describe("with [AllowShared, AllowResizable]", () => {
490+
const allowResizableSUT = (v, opts) => {
491+
return conversions.BufferSource(v, { ...opts, allowShared: true, allowResizable: true });
492+
};
493+
494+
for (const { label, creator, isDetached, isForged } of bufferSourceCreators) {
495+
const testFunction = !isDetached && !isForged ? testOk : testNotOk;
496+
testFunction(label, allowResizableSUT, creator);
497+
}
498+
499+
commonNotOk(allowResizableSUT);
500+
});
451501
});

0 commit comments

Comments
 (0)