11cb0ef41Sopenharmony_ci// META: title=Blob slice overflow 21cb0ef41Sopenharmony_ci'use strict'; 31cb0ef41Sopenharmony_ci 41cb0ef41Sopenharmony_civar text = ''; 51cb0ef41Sopenharmony_ci 61cb0ef41Sopenharmony_cifor (var i = 0; i < 2000; ++i) { 71cb0ef41Sopenharmony_ci text += 'A'; 81cb0ef41Sopenharmony_ci} 91cb0ef41Sopenharmony_ci 101cb0ef41Sopenharmony_citest(function() { 111cb0ef41Sopenharmony_ci var blob = new Blob([text]); 121cb0ef41Sopenharmony_ci var sliceBlob = blob.slice(-1, blob.size); 131cb0ef41Sopenharmony_ci assert_equals(sliceBlob.size, 1, "Blob slice size"); 141cb0ef41Sopenharmony_ci}, "slice start is negative, relativeStart will be max((size + start), 0)"); 151cb0ef41Sopenharmony_ci 161cb0ef41Sopenharmony_citest(function() { 171cb0ef41Sopenharmony_ci var blob = new Blob([text]); 181cb0ef41Sopenharmony_ci var sliceBlob = blob.slice(blob.size + 1, blob.size); 191cb0ef41Sopenharmony_ci assert_equals(sliceBlob.size, 0, "Blob slice size"); 201cb0ef41Sopenharmony_ci}, "slice start is greater than blob size, relativeStart will be min(start, size)"); 211cb0ef41Sopenharmony_ci 221cb0ef41Sopenharmony_citest(function() { 231cb0ef41Sopenharmony_ci var blob = new Blob([text]); 241cb0ef41Sopenharmony_ci var sliceBlob = blob.slice(blob.size - 2, -1); 251cb0ef41Sopenharmony_ci assert_equals(sliceBlob.size, 1, "Blob slice size"); 261cb0ef41Sopenharmony_ci}, "slice end is negative, relativeEnd will be max((size + end), 0)"); 271cb0ef41Sopenharmony_ci 281cb0ef41Sopenharmony_citest(function() { 291cb0ef41Sopenharmony_ci var blob = new Blob([text]); 301cb0ef41Sopenharmony_ci var sliceBlob = blob.slice(blob.size - 2, blob.size + 999); 311cb0ef41Sopenharmony_ci assert_equals(sliceBlob.size, 2, "Blob slice size"); 321cb0ef41Sopenharmony_ci}, "slice end is greater than blob size, relativeEnd will be min(end, size)"); 33