chromium/content/test/data/indexeddb/write_4mb_blob.html

<!DOCTYPE html>
<html>
<!--
Copyright 2017 The Chromium Authors
Use of this source code is governed by a BSD-style license that can be
found in the LICENSE file.
-->
<head>
<title>IDB Test that blobs use space when created and free up space when deleted</title>
<script src="common.js"></script>
<script>

// Constants.
var store_name = 'blobs';
var blob_key = 'blob_key';
var blob_size = 4 * 1024 * 1024;  // 4MB

// Shared variables.
var db;

function test() {
  indexedDBTest(prepareDatabase, putBlob);
}

function prepareDatabase() {
  db = event.target.result;
  db.createObjectStore(store_name);
}

function putBlob() {
  debug("Writing blob.");

  var trans = db.transaction(store_name, 'readwrite');
  trans.onabort = unexpectedAbortCallback;
  trans.oncomplete = done;

  var data = new Array(1 + blob_size).join("X");
  var blob = new Blob([data]);
  var request = trans.objectStore(store_name).put(blob, blob_key);
  request.onerror = unexpectedErrorCallback;
}

</script>
</head>
<body onLoad="test()">
  <div id="status">Starting...<br></div>
</body>
</html>