• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1// META: title=Blob slice overflow
2'use strict';
3
4var text = '';
5
6for (var i = 0; i < 2000; ++i) {
7  text += 'A';
8}
9
10test(function() {
11  var blob = new Blob([text]);
12  var sliceBlob = blob.slice(-1, blob.size);
13  assert_equals(sliceBlob.size, 1, "Blob slice size");
14}, "slice start is negative, relativeStart will be max((size + start), 0)");
15
16test(function() {
17  var blob = new Blob([text]);
18  var sliceBlob = blob.slice(blob.size + 1, blob.size);
19  assert_equals(sliceBlob.size, 0, "Blob slice size");
20}, "slice start is greater than blob size, relativeStart will be min(start, size)");
21
22test(function() {
23  var blob = new Blob([text]);
24  var sliceBlob = blob.slice(blob.size - 2, -1);
25  assert_equals(sliceBlob.size, 1, "Blob slice size");
26}, "slice end is negative, relativeEnd will be max((size + end), 0)");
27
28test(function() {
29  var blob = new Blob([text]);
30  var sliceBlob = blob.slice(blob.size - 2, blob.size + 999);
31  assert_equals(sliceBlob.size, 2, "Blob slice size");
32}, "slice end is greater than blob size, relativeEnd will be min(end, size)");
33