Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(64)

Unified Diff: LayoutTests/storage/indexeddb/blob-basics-metadata.html

Issue 18590006: Blob support for IDB [Blink] (Closed) Base URL: svn://svn.chromium.org/blink/trunk
Patch Set: aaaaaaaand one more nit. Created 6 years, 6 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « no previous file | LayoutTests/storage/indexeddb/blob-basics-metadata-expected.txt » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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..9760e6f765393caf9e6d170cebe9a0029d3e077a
--- /dev/null
+++ b/LayoutTests/storage/indexeddb/blob-basics-metadata.html
@@ -0,0 +1,137 @@
+<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 = function (e) {
+ shouldBeTrue("event.target.result" + validation);
+ onComplete();
+ }
+ transaction.oncomplete = function () {
+ doRead(keyName, readTransactionOnComplete);
+ }
+}
+
+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>
« no previous file with comments | « no previous file | LayoutTests/storage/indexeddb/blob-basics-metadata-expected.txt » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698