2011-12-16 11:34:24 +04:00
|
|
|
<!--
|
|
|
|
Any copyright is dedicated to the Public Domain.
|
|
|
|
http://creativecommons.org/publicdomain/zero/1.0/
|
|
|
|
-->
|
|
|
|
<html>
|
|
|
|
<head>
|
|
|
|
<title>Indexed Database Property Test</title>
|
|
|
|
|
|
|
|
<script type="text/javascript" src="/tests/SimpleTest/SimpleTest.js"></script>
|
|
|
|
<link rel="stylesheet" type="text/css" href="/tests/SimpleTest/test.css"/>
|
|
|
|
|
2017-02-23 00:10:07 +03:00
|
|
|
<script type="text/javascript">
|
2016-12-01 12:11:32 +03:00
|
|
|
function* testSteps()
|
2011-12-16 11:34:24 +04:00
|
|
|
{
|
2013-07-29 21:12:21 +04:00
|
|
|
const READ_WRITE = "readwrite";
|
2011-12-16 11:34:24 +04:00
|
|
|
|
|
|
|
const databaseInfo = [
|
2012-07-13 09:37:28 +04:00
|
|
|
{ name: window.location.pathname + "1" },
|
2018-10-19 15:55:39 +03:00
|
|
|
{ name: window.location.pathname + "2" },
|
2011-12-16 11:34:24 +04:00
|
|
|
];
|
|
|
|
|
|
|
|
const objectStoreName = "Blobs";
|
|
|
|
|
|
|
|
const fileData = { key: 1, file: getRandomFile("random.bin", 100000) };
|
|
|
|
|
2016-10-25 22:18:29 +03:00
|
|
|
SpecialPowers.pushPrefEnv({ set: [["dom.indexedDB.dataThreshold", -1]] },
|
|
|
|
continueToNextStep);
|
|
|
|
yield undefined;
|
|
|
|
|
2011-12-16 11:34:24 +04:00
|
|
|
let databases = [];
|
2015-01-23 22:56:48 +03:00
|
|
|
for (let info of databaseInfo) {
|
2012-07-13 09:37:28 +04:00
|
|
|
let request = indexedDB.open(info.name, 1);
|
2011-12-16 11:34:24 +04:00
|
|
|
request.onerror = errorHandler;
|
|
|
|
request.onupgradeneeded = grabEventAndContinueHandler;
|
|
|
|
request.onsuccess = grabEventAndContinueHandler;
|
2013-07-11 01:52:35 +04:00
|
|
|
let event = yield undefined;
|
2011-12-16 11:34:24 +04:00
|
|
|
|
|
|
|
is(event.type, "upgradeneeded", "Got correct event type");
|
|
|
|
|
|
|
|
let db = event.target.result;
|
|
|
|
db.onerror = errorHandler;
|
|
|
|
|
|
|
|
let objectStore = db.createObjectStore(objectStoreName, { });
|
|
|
|
objectStore.add(fileData.file, fileData.key);
|
|
|
|
|
2013-07-11 01:52:35 +04:00
|
|
|
event = yield undefined;
|
2011-12-16 11:34:24 +04:00
|
|
|
|
|
|
|
is(event.type, "success", "Got correct event type");
|
|
|
|
|
|
|
|
databases.push(db);
|
|
|
|
}
|
|
|
|
|
|
|
|
let refResult;
|
2015-01-23 22:56:48 +03:00
|
|
|
for (let db of databases) {
|
2011-12-16 11:34:24 +04:00
|
|
|
let request = db.transaction([objectStoreName])
|
|
|
|
.objectStore(objectStoreName).get(fileData.key);
|
|
|
|
request.onsuccess = grabEventAndContinueHandler;
|
2017-05-10 19:28:55 +03:00
|
|
|
let event = yield undefined;
|
2011-12-16 11:34:24 +04:00
|
|
|
|
|
|
|
let result = event.target.result;
|
|
|
|
verifyBlob(result, fileData.file, 1);
|
2013-07-11 01:52:35 +04:00
|
|
|
yield undefined;
|
2011-12-16 11:34:24 +04:00
|
|
|
|
|
|
|
if (!refResult) {
|
|
|
|
refResult = result;
|
|
|
|
continue;
|
|
|
|
}
|
2012-06-03 20:33:52 +04:00
|
|
|
|
2014-09-27 03:21:57 +04:00
|
|
|
isnot(getFilePath(result), getFilePath(refResult), "Different os files");
|
2011-12-16 11:34:24 +04:00
|
|
|
}
|
|
|
|
|
|
|
|
for (let i = 1; i < databases.length; i++) {
|
|
|
|
let db = databases[i];
|
|
|
|
|
|
|
|
let objectStore = db.transaction([objectStoreName], READ_WRITE)
|
|
|
|
.objectStore(objectStoreName);
|
|
|
|
|
2017-05-10 19:05:18 +03:00
|
|
|
let request = objectStore.add(refResult, 2);
|
2011-12-16 11:34:24 +04:00
|
|
|
request.onsuccess = grabEventAndContinueHandler;
|
2017-05-10 19:28:55 +03:00
|
|
|
let event = yield undefined;
|
2011-12-16 11:34:24 +04:00
|
|
|
|
|
|
|
is(event.target.result, 2, "Got correct key");
|
|
|
|
|
|
|
|
request = objectStore.get(2);
|
|
|
|
request.onsuccess = grabEventAndContinueHandler;
|
2013-07-11 01:52:35 +04:00
|
|
|
event = yield undefined;
|
2011-12-16 11:34:24 +04:00
|
|
|
|
|
|
|
let result = event.target.result;
|
|
|
|
verifyBlob(result, refResult, 2);
|
2013-07-11 01:52:35 +04:00
|
|
|
yield undefined;
|
2012-06-03 20:33:52 +04:00
|
|
|
|
2014-09-27 03:21:57 +04:00
|
|
|
isnot(getFilePath(result), getFilePath(refResult), "Different os files");
|
2011-12-16 11:34:24 +04:00
|
|
|
}
|
|
|
|
|
|
|
|
is(bufferCache.length, 2, "Correct length");
|
|
|
|
|
|
|
|
finishTest();
|
|
|
|
}
|
|
|
|
</script>
|
2017-02-23 00:10:07 +03:00
|
|
|
<script type="text/javascript" src="file.js"></script>
|
|
|
|
<script type="text/javascript" src="helpers.js"></script>
|
2011-12-16 11:34:24 +04:00
|
|
|
|
|
|
|
</head>
|
|
|
|
|
|
|
|
<body onload="runTest();"></body>
|
|
|
|
|
|
|
|
</html>
|