OLD | NEW |
| (Empty) |
1 <html> | |
2 <head> | |
3 <script src="../../resources/js-test.js"></script> | |
4 <script src="resources/shared.js"></script> | |
5 </head> | |
6 <body> | |
7 <input type="file" id="fileInput" multiple></input> | |
8 <script> | |
9 | |
10 description("Confirm Blob/File/FileList limitations of WebKit's IndexedDB implem
entation."); | |
11 // FIXME: This verifies that blob-type data is rejected for now, rather than sil
ently failing. | |
12 // Tracked for the Chromium port as: http://crbug.com/108012 | |
13 | |
14 fileInput = document.getElementById("fileInput"); | |
15 if (window.eventSender) { | |
16 var fileRect = fileInput.getClientRects()[0]; | |
17 var targetX = fileRect.left + fileRect.width / 2; | |
18 var targetY = fileRect.top + fileRect.height / 2; | |
19 eventSender.beginDragWithFiles(['resources/test-data.html', 'resources/test-
data.txt']); | |
20 eventSender.mouseMoveTo(targetX, targetY); | |
21 eventSender.mouseUp(); | |
22 } | |
23 | |
24 function prepareDatabase() | |
25 { | |
26 db = event.target.result; | |
27 var trans = event.target.transaction; | |
28 evalAndLog("store = db.createObjectStore('storeName')"); | |
29 evalAndLog("store.put('value', 'key')"); | |
30 trans.onerror = unexpectedErrorCallback; | |
31 trans.onabort = unexpectedAbortCallback; | |
32 } | |
33 | |
34 function testBlob() | |
35 { | |
36 debug(""); | |
37 debug("testBlob():"); | |
38 | |
39 shouldBeTrue("FileReader != null"); | |
40 evalAndLog("test_content = 'This is a test. This is only a test.'"); | |
41 evalAndLog("blob = new Blob([test_content])"); | |
42 validateExceptions("blob", testFile); | |
43 } | |
44 | |
45 function testFile() | |
46 { | |
47 debug(""); | |
48 debug("testFile():"); | |
49 evalAndLog("file = fileInput.files[0]"); | |
50 validateExceptions("file", testFileList); | |
51 } | |
52 | |
53 function testFileList() | |
54 { | |
55 debug(""); | |
56 debug("testFileList():"); | |
57 evalAndLog("filelist = fileInput.files"); | |
58 validateExceptions("filelist", finishJSTest); | |
59 } | |
60 | |
61 function validateExceptions(variable, onComplete) | |
62 { | |
63 debug(""); | |
64 debug("validateExceptions(" + variable + "):"); | |
65 evalAndLog("transaction = db.transaction('storeName', 'readwrite')"); | |
66 evalAndLog("store = transaction.objectStore('storeName')"); | |
67 evalAndExpectException("store.put(" + variable + ", 'key')", "DOMException.D
ATA_CLONE_ERR"); | |
68 evalAndExpectException("store.add(" + variable + ", 'key')", "DOMException.D
ATA_CLONE_ERR"); | |
69 evalAndLog("request = store.openCursor()"); | |
70 request.onsuccess = function () { | |
71 evalAndLog("cursor = request.result"); | |
72 evalAndExpectException("cursor.update(" + variable + ")", "DOMException.
DATA_CLONE_ERR"); | |
73 }; | |
74 transaction.oncomplete = onComplete; | |
75 } | |
76 | |
77 if (window.eventSender) { | |
78 indexedDBTest(prepareDatabase, testBlob); | |
79 } else { | |
80 alert("Select file(s) using the input control above to initiate the test"); | |
81 document.getElementById("fileInput").onchange = function() { indexedDBTest(p
repareDatabase, testBlob); }; | |
82 } | |
83 | |
84 </script> | |
85 </body> | |
86 </html> | |
OLD | NEW |