| FazBrowse GitHub Viewer | Trending | | Home |
| Tools: [Download Repo ZIP] [Original HTTPS Page] |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -3,16 +3,20 @@ | |||
| 3 | 3 | ||
| 4 | 4 | require('../common'); | |
| 5 | 5 | const assert = require('assert'); | |
| 6 | + const { kMaxLength } = require('buffer'); | ||
| 6 | 7 | const { isSharedArrayBuffer } = require('util/types'); | |
| 7 | 8 | const { constructSharedArrayBuffer } = require('internal/util'); | |
| 8 | 9 | ||
| 9 | 10 | // We're testing that we can construct a SAB even when the global is not exposed. | |
| 10 | 11 | assert.strictEqual(typeof SharedArrayBuffer, 'undefined'); | |
| 11 | 12 | ||
| 12 | - for (const length of [undefined, 0, 1, 2 ** 32]) { | ||
| 13 | + for (const length of [undefined, 0, 1, 2 ** 16]) { | ||
| 13 | 14 | assert(isSharedArrayBuffer(constructSharedArrayBuffer(length))); | |
| 14 | 15 | } | |
| 15 | 16 | ||
| 16 | - for (const length of [-1, Number.MAX_SAFE_INTEGER + 1, 2 ** 64]) { | ||
| 17 | + // Specifically test the following cases: | ||
| 18 | + // - out-of-range allocation requests should not crash the process | ||
| 19 | + // - no int64 overflow | ||
| 20 | + for (const length of [-1, kMaxLength + 1, 2 ** 64]) { | ||
| 17 | 21 | assert.throws(() => constructSharedArrayBuffer(length), RangeError); | |
| 18 | 22 | } | |
| Back | FazBrowse Home | New Git URL |
0 commit comments