-
Notifications
You must be signed in to change notification settings - Fork 0
/
array-buffer.js
44 lines (29 loc) · 1.18 KB
/
array-buffer.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
describe('ArrayBuffer', () => {
describe('constructor()', () => {
let length;
after((done) => {
// @todo This is an optimistic fix to prevent the famous 'Some of your tests did a full page reload!' error.
setTimeout(done, 1000);
});
beforeEach(() => {
/*
* 2147479551 is the largest possible length but an ArrayBuffer of that size can't be used by Chrome and Safari on
* Sauce Labs. However a size of 200,000,000 bytes is enough to let the test pass.
*/
length = 200000000;
});
it('should block the main thread', function () {
this.timeout(10000);
let lastNow = performance.now();
let currentNow = performance.now();
expect(currentNow - lastNow).to.be.below(10);
lastNow = performance.now();
new ArrayBuffer(length);
currentNow = performance.now();
expect(currentNow - lastNow).to.be.above(10);
lastNow = performance.now();
currentNow = performance.now();
expect(currentNow - lastNow).to.be.below(10);
});
});
});