Wed, 31 Dec 2014 06:09:35 +0100
Cloned upstream origin tor-browser at tor-browser-31.3.0esr-4.5-1-build1
revision ID fc1c9ff7c1b2defdbc039f12214767608f46423f for hacking purpose.
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 name = window.location.pathname; |
michael@0 | 16 | |
michael@0 | 17 | const objectStoreName = "Blobs"; |
michael@0 | 18 | |
michael@0 | 19 | const b1 = getRandomBlob(10000); |
michael@0 | 20 | |
michael@0 | 21 | const b2 = [ getRandomBlob(5000), getRandomBlob(3000), getRandomBlob(12000), |
michael@0 | 22 | getRandomBlob(17000), getRandomBlob(16000), getRandomBlob(16000), |
michael@0 | 23 | getRandomBlob(8000) |
michael@0 | 24 | ]; |
michael@0 | 25 | |
michael@0 | 26 | const b3 = [ getRandomBlob(5000), getRandomBlob(3000), getRandomBlob(9000)]; |
michael@0 | 27 | |
michael@0 | 28 | const objectStoreData = [ |
michael@0 | 29 | { key: 1, blobs: [ b1, b1, b1, b1, b1, b1, b1, b1, b1, b1 ], |
michael@0 | 30 | expectedFileIds: [1, 1, 1, 1, 1, 1, 1, 1, 1, 1] }, |
michael@0 | 31 | { key: 2, blobs: [ b2[0], b2[1], b2[2], b2[3], b2[4], b2[5], b2[6] ], |
michael@0 | 32 | expectedFileIds: [2, 3, 4, 5, 6, 7, 8] }, |
michael@0 | 33 | { key: 3, blobs: [ b3[0], b3[0], b3[1], b3[2], b3[2], b3[0], b3[0] ], |
michael@0 | 34 | expectedFileIds: [9, 9, 10, 11, 11, 9, 9] } |
michael@0 | 35 | ]; |
michael@0 | 36 | |
michael@0 | 37 | let request = indexedDB.open(name, 1); |
michael@0 | 38 | request.onerror = errorHandler; |
michael@0 | 39 | request.onupgradeneeded = grabEventAndContinueHandler; |
michael@0 | 40 | request.onsuccess = grabEventAndContinueHandler; |
michael@0 | 41 | let event = yield undefined; |
michael@0 | 42 | |
michael@0 | 43 | is(event.type, "upgradeneeded", "Got correct event type"); |
michael@0 | 44 | |
michael@0 | 45 | let db = event.target.result; |
michael@0 | 46 | db.onerror = errorHandler; |
michael@0 | 47 | |
michael@0 | 48 | let objectStore = db.createObjectStore(objectStoreName, { }); |
michael@0 | 49 | |
michael@0 | 50 | for each (let data in objectStoreData) { |
michael@0 | 51 | objectStore.add(data.blobs, data.key); |
michael@0 | 52 | } |
michael@0 | 53 | |
michael@0 | 54 | event = yield undefined; |
michael@0 | 55 | |
michael@0 | 56 | is(event.type, "success", "Got correct event type"); |
michael@0 | 57 | |
michael@0 | 58 | for each (let data in objectStoreData) { |
michael@0 | 59 | objectStore = db.transaction([objectStoreName]) |
michael@0 | 60 | .objectStore(objectStoreName); |
michael@0 | 61 | |
michael@0 | 62 | request = objectStore.get(data.key); |
michael@0 | 63 | request.onsuccess = grabEventAndContinueHandler; |
michael@0 | 64 | event = yield undefined; |
michael@0 | 65 | |
michael@0 | 66 | verifyBlobArray(event.target.result, data.blobs, data.expectedFileIds); |
michael@0 | 67 | yield undefined; |
michael@0 | 68 | } |
michael@0 | 69 | |
michael@0 | 70 | is(bufferCache.length, 11, "Correct length"); |
michael@0 | 71 | |
michael@0 | 72 | finishTest(); |
michael@0 | 73 | yield undefined; |
michael@0 | 74 | } |
michael@0 | 75 | </script> |
michael@0 | 76 | <script type="text/javascript;version=1.7" src="file.js"></script> |
michael@0 | 77 | <script type="text/javascript;version=1.7" src="helpers.js"></script> |
michael@0 | 78 | |
michael@0 | 79 | </head> |
michael@0 | 80 | |
michael@0 | 81 | <body onload="runTest();"></body> |
michael@0 | 82 | |
michael@0 | 83 | </html> |