* Validates [AllowShared] and [AllowResizable] backing-store constraints. * @param {ArrayBuffer|SharedArrayBuffer} buffer Backing buffer. * @param {ConversionOptions} options Conversion options. * @returns {void}
(buffer, options)
| 862 | * @returns {void} |
| 863 | */ |
| 864 | function validateBufferSourceBacking(buffer, options) { |
| 865 | let resizable; |
| 866 | try { |
| 867 | // ArrayBuffer.prototype.resizable is an ArrayBuffer brand check and the |
| 868 | // [AllowResizable] value we need. For SharedArrayBuffer-backed views it |
| 869 | // throws, which lets this path avoid a separate IsSharedArrayBuffer check. |
| 870 | // BufferSource has separate inline logic because [AllowShared] cannot be |
| 871 | // used with that typedef. |
| 872 | resizable = ArrayBufferPrototypeGetResizable(buffer); |
| 873 | } catch { |
| 874 | // ArrayBufferView conversion step 2: reject SharedArrayBuffer |
| 875 | // backing stores unless [AllowShared] is present. |
| 876 | if (!options.allowShared) { |
| 877 | throw makeException( |
| 878 | 'is a view on a SharedArrayBuffer, which is not allowed.', |
| 879 | options); |
| 880 | } |
| 881 | // Step 3: reject non-fixed SharedArrayBuffer backing stores unless |
| 882 | // [AllowResizable] is present. |
| 883 | validateAllowGrowableSharedArrayBuffer(buffer, options); |
| 884 | return; |
| 885 | } |
| 886 | |
| 887 | // ArrayBuffer conversion step 3 and ArrayBufferView conversion step 3: |
| 888 | // reject non-fixed ArrayBuffer backing stores unless [AllowResizable] |
| 889 | // is present. |
| 890 | validateAllowResizableArrayBuffer(resizable, options); |
| 891 | } |
| 892 | |
| 893 | /** |
| 894 | * Validates the [AllowResizable] constraint for growable SharedArrayBuffer. |
no test coverage detected
searching dependent graphs…