Wed, 31 Dec 2014 06:55:50 +0100
Added tag UPSTREAM_283F7C6 for changeset ca08bd8f51b2
michael@0 | 1 | <!-- |
michael@0 | 2 | Any copyright is dedicated to the Public Domain. |
michael@0 | 3 | http://creativecommons.org/publicdomain/zero/1.0/ |
michael@0 | 4 | --> |
michael@0 | 5 | <html> |
michael@0 | 6 | <head> |
michael@0 | 7 | <title>Indexed Database Property Test</title> |
michael@0 | 8 | |
michael@0 | 9 | <script type="text/javascript" src="/tests/SimpleTest/SimpleTest.js"></script> |
michael@0 | 10 | <link rel="stylesheet" type="text/css" href="/tests/SimpleTest/test.css"/> |
michael@0 | 11 | |
michael@0 | 12 | <script type="text/javascript;version=1.7"> |
michael@0 | 13 | function testSteps() |
michael@0 | 14 | { |
michael@0 | 15 | const READ_WRITE = "readwrite"; |
michael@0 | 16 | |
michael@0 | 17 | const name = window.location.pathname; |
michael@0 | 18 | |
michael@0 | 19 | const objectStoreName = "Blobs"; |
michael@0 | 20 | |
michael@0 | 21 | const blob = getRandomBlob(1000); |
michael@0 | 22 | const file = getRandomFile("random.bin", 100000); |
michael@0 | 23 | |
michael@0 | 24 | const objectData1 = { key: 1, object: { foo: blob, bar: blob } }; |
michael@0 | 25 | const objectData2 = { key: 2, object: { foo: file, bar: file } }; |
michael@0 | 26 | |
michael@0 | 27 | let request = indexedDB.open(name, 1); |
michael@0 | 28 | request.onerror = errorHandler; |
michael@0 | 29 | request.onupgradeneeded = grabEventAndContinueHandler; |
michael@0 | 30 | request.onsuccess = grabEventAndContinueHandler; |
michael@0 | 31 | let event = yield undefined; |
michael@0 | 32 | |
michael@0 | 33 | is(event.type, "upgradeneeded", "Got correct event type"); |
michael@0 | 34 | |
michael@0 | 35 | let db = event.target.result; |
michael@0 | 36 | db.onerror = errorHandler; |
michael@0 | 37 | |
michael@0 | 38 | let objectStore = db.createObjectStore(objectStoreName, { }); |
michael@0 | 39 | |
michael@0 | 40 | objectStore.add(objectData1.object, objectData1.key); |
michael@0 | 41 | objectStore.add(objectData2.object, objectData2.key); |
michael@0 | 42 | |
michael@0 | 43 | event = yield undefined; |
michael@0 | 44 | |
michael@0 | 45 | is(event.type, "success", "Got correct event type"); |
michael@0 | 46 | |
michael@0 | 47 | objectStore = db.transaction([objectStoreName]) |
michael@0 | 48 | .objectStore(objectStoreName); |
michael@0 | 49 | request = objectStore.get(objectData1.key); |
michael@0 | 50 | request.onsuccess = grabEventAndContinueHandler; |
michael@0 | 51 | event = yield undefined; |
michael@0 | 52 | |
michael@0 | 53 | let result = event.target.result; |
michael@0 | 54 | |
michael@0 | 55 | verifyBlob(result.foo, blob, 1); |
michael@0 | 56 | yield undefined; |
michael@0 | 57 | |
michael@0 | 58 | verifyBlob(result.bar, blob, 1); |
michael@0 | 59 | yield undefined; |
michael@0 | 60 | |
michael@0 | 61 | objectStore = db.transaction([objectStoreName]) |
michael@0 | 62 | .objectStore(objectStoreName); |
michael@0 | 63 | request = objectStore.get(objectData2.key); |
michael@0 | 64 | request.onsuccess = grabEventAndContinueHandler; |
michael@0 | 65 | event = yield undefined; |
michael@0 | 66 | |
michael@0 | 67 | result = event.target.result; |
michael@0 | 68 | |
michael@0 | 69 | verifyBlob(result.foo, file, 2); |
michael@0 | 70 | yield undefined; |
michael@0 | 71 | |
michael@0 | 72 | verifyBlob(result.bar, file, 2); |
michael@0 | 73 | yield undefined; |
michael@0 | 74 | |
michael@0 | 75 | finishTest(); |
michael@0 | 76 | yield undefined; |
michael@0 | 77 | } |
michael@0 | 78 | </script> |
michael@0 | 79 | <script type="text/javascript;version=1.7" src="file.js"></script> |
michael@0 | 80 | <script type="text/javascript;version=1.7" src="helpers.js"></script> |
michael@0 | 81 | |
michael@0 | 82 | </head> |
michael@0 | 83 | |
michael@0 | 84 | <body onload="runTest();"></body> |
michael@0 | 85 | |
michael@0 | 86 | </html> |