blob: a18fae06d2a87c1a75814a44d167d3fc3b4aaad7 [file] [log] [blame]
<!DOCTYPE html>
<meta charset="utf-8">
<script src="/resources/testharness.js"></script>
<script src="/resources/testharnessreport.js"></script>
<script src="resources/simple-queue-common.js"></script>
<script>
// Verify that wraparound works correctly in SimpleQueue by creating a queue
// with more than 16K elements. This tests push(), shift() and peek().
promise_test(t => {
let expectedNextValue = 0;
const ws = new WritableStream({
write: t.step_func(chunk => {
assert_equals(expectedNextValue, chunk,
'chunk should have the expected value');
++expectedNextValue;
})
});
const writer = ws.getWriter();
let lastPromise;
// Because this loop is synchronous, the elements all have to be queued before
// they can be processed.
for (let i = 0; i < NUMBER_OF_WRITES; ++i) {
lastPromise = writer.write(i);
}
assert_equals(1 - NUMBER_OF_WRITES, writer.desiredSize,
'underlying sink write() should not have been called yet');
return lastPromise;
}, 'queueing more than 16K chunks should work');
</script>