| Index: LayoutTests/storage/indexeddb/blob-basics-metadata.html
|
| diff --git a/LayoutTests/storage/indexeddb/blob-basics-metadata.html b/LayoutTests/storage/indexeddb/blob-basics-metadata.html
|
| new file mode 100644
|
| index 0000000000000000000000000000000000000000..6071fdd946a62849dce1a596c0327d0880bc303b
|
| --- /dev/null
|
| +++ b/LayoutTests/storage/indexeddb/blob-basics-metadata.html
|
| @@ -0,0 +1,142 @@
|
| +<html>
|
| +<head>
|
| +<script src="../../resources/js-test.js"></script>
|
| +<script src="resources/shared.js"></script>
|
| +</head>
|
| +<body>
|
| +<input type="file" id="fileInput" multiple></input>
|
| +<script>
|
| +
|
| +description("Confirm basic Blob/File/FileList functionality.");
|
| +
|
| +fileInput = document.getElementById("fileInput");
|
| +if (window.eventSender) {
|
| + var fileRect = fileInput.getClientRects()[0];
|
| + var targetX = fileRect.left + fileRect.width / 2;
|
| + var targetY = fileRect.top + fileRect.height / 2;
|
| + eventSender.beginDragWithFiles(['resources/test-data.html', 'resources/test-data.txt']);
|
| + eventSender.mouseMoveTo(targetX, targetY);
|
| + eventSender.mouseUp();
|
| +}
|
| +
|
| +function prepareDatabase()
|
| +{
|
| + db = event.target.result;
|
| + var trans = event.target.transaction;
|
| + evalAndLog("store = db.createObjectStore('storeName')");
|
| + evalAndLog("store.put('value', 'key')");
|
| + trans.onerror = unexpectedErrorCallback;
|
| + trans.onabort = unexpectedAbortCallback;
|
| +}
|
| +
|
| +var blobValidation = ".size == test_content.length";
|
| +function testBlob()
|
| +{
|
| + debug("");
|
| + debug("testBlob():");
|
| +
|
| + shouldBeTrue("FileReader != null");
|
| + evalAndLog("test_content = 'This is a test. This is only a test.'");
|
| + evalAndLog("blob = new Blob([test_content])");
|
| + validateResult("blob", blobValidation, testFile);
|
| +}
|
| +
|
| +var fileValidation = ".name == fileInput.files[0].name";
|
| +function testFile()
|
| +{
|
| + debug("");
|
| + debug("testFile():");
|
| + evalAndLog("file = fileInput.files[0]");
|
| + validateResult("file", fileValidation, testFileList);
|
| +}
|
| +
|
| +var fileListValidation = "[1].name == fileInput.files[1].name";
|
| +function testFileList()
|
| +{
|
| + debug("");
|
| + debug("testFileList():");
|
| + evalAndLog("filelist = fileInput.files");
|
| + validateResult("filelist",
|
| + fileListValidation, testCursor);
|
| +}
|
| +
|
| +function testCursor()
|
| +{
|
| + debug("");
|
| + debug("testCursor():");
|
| + evalAndLog("transaction = db.transaction('storeName', 'readonly')");
|
| + transaction.onerror = unexpectedErrorCallback;
|
| + evalAndLog("store = transaction.objectStore('storeName')");
|
| + evalAndLog("request = store.openCursor()");
|
| +
|
| + var count = 0;
|
| + request.onsuccess = continueToTest;
|
| +
|
| + function continueToTest(event)
|
| + {
|
| + cursor = event.target.result;
|
| + switch (count++) {
|
| + case 0:
|
| + shouldBeTrue("cursor.value" + blobValidation);
|
| + break;
|
| + case 1:
|
| + shouldBeTrue("cursor.value" + fileValidation);
|
| + break;
|
| + case 2:
|
| + shouldBeTrue("cursor.value" + fileListValidation);
|
| + break;
|
| + case 3:
|
| + shouldBeTrue("cursor.value == 'value'");
|
| + break;
|
| + case 4:
|
| + shouldBeNull(cursor);
|
| + finishJSTest();
|
| + return;
|
| + default:
|
| + testFailed("count was unexpectedly " + count);
|
| + }
|
| + evalAndLog("cursor.continue();");
|
| + }
|
| +}
|
| +
|
| +function validateResult(variable, validation, onComplete)
|
| +{
|
| + var keyName = variable + "key";
|
| + debug("");
|
| + debug("validateResult(" + variable + "):");
|
| + evalAndLog("transaction = db.transaction('storeName', 'readwrite')");
|
| + evalAndLog("store = transaction.objectStore('storeName')");
|
| + evalAndLog("store.put(" + variable + ", '" + keyName + "')");
|
| + var readTransactionOnComplete = getValidator(validation, onComplete);
|
| + transaction.oncomplete = function () {
|
| + doRead(keyName, readTransactionOnComplete);
|
| + }
|
| +}
|
| +
|
| +function getValidator(validation, onComplete)
|
| +{
|
| + return function (e) {
|
| + shouldBeTrue("event.target.result" + validation);
|
| + onComplete();
|
| + }
|
| +}
|
| +
|
| +function doRead(keyName, onComplete)
|
| +{
|
| + evalAndLog("transaction = db.transaction('storeName', 'readwrite')");
|
| + evalAndLog("store = transaction.objectStore('storeName')");
|
| + evalAndLog("request = store.get('" + keyName + "')");
|
| + request.onsuccess = onComplete;
|
| + transaction.onerror = unexpectedErrorCallback;
|
| +}
|
| +
|
| +if (window.eventSender) {
|
| + indexedDBTest(prepareDatabase, testBlob);
|
| +} else {
|
| + alert("Select at least 2 files using the input control above to initiate the test");
|
| + document.getElementById("fileInput").onchange = function() { indexedDBTest(prepareDatabase, testBlob); };
|
| +}
|
| +
|
| +</script>
|
| +</body>
|
| +</html>
|
|
|