2012-01-04 07:43:33 -08:00
|
|
|
/**
|
|
|
|
* Any copyright is dedicated to the Public Domain.
|
|
|
|
* http://creativecommons.org/publicdomain/zero/1.0/
|
|
|
|
*/
|
|
|
|
|
2012-04-30 16:52:27 -07:00
|
|
|
const { 'classes': Cc, 'interfaces': Ci } = Components;
|
2012-01-04 07:43:33 -08:00
|
|
|
|
2012-04-11 14:55:22 -07:00
|
|
|
const DOMException = Ci.nsIDOMDOMException;
|
2012-01-04 07:43:33 -08:00
|
|
|
const IDBCursor = Ci.nsIIDBCursor;
|
|
|
|
const IDBTransaction = Ci.nsIIDBTransaction;
|
|
|
|
const IDBOpenDBRequest = Ci.nsIIDBOpenDBRequest;
|
|
|
|
const IDBVersionChangeEvent = Ci.nsIIDBVersionChangeEvent
|
|
|
|
const IDBDatabase = Ci.nsIIDBDatabase
|
|
|
|
const IDBFactory = Ci.nsIIDBFactory
|
|
|
|
const IDBIndex = Ci.nsIIDBIndex
|
|
|
|
const IDBObjectStore = Ci.nsIIDBObjectStore
|
|
|
|
const IDBRequest = Ci.nsIIDBRequest
|
|
|
|
|
|
|
|
function is(a, b, msg) {
|
2012-06-01 10:21:12 -07:00
|
|
|
dump("is(" + a + ", " + b + ", \"" + msg + "\")");
|
2012-01-04 07:43:33 -08:00
|
|
|
do_check_eq(a, b, Components.stack.caller);
|
|
|
|
}
|
|
|
|
|
|
|
|
function ok(cond, msg) {
|
2012-06-01 10:21:12 -07:00
|
|
|
dump("ok(" + cond + ", \"" + msg + "\")");
|
2012-01-04 07:43:33 -08:00
|
|
|
do_check_true(!!cond, Components.stack.caller);
|
|
|
|
}
|
|
|
|
|
|
|
|
function isnot(a, b, msg) {
|
2012-06-01 10:21:12 -07:00
|
|
|
dump("isnot(" + a + ", " + b + ", \"" + msg + "\")");
|
2012-01-04 07:43:33 -08:00
|
|
|
do_check_neq(a, b, Components.stack.caller);
|
|
|
|
}
|
|
|
|
|
|
|
|
function executeSoon(fun) {
|
|
|
|
do_execute_soon(fun);
|
|
|
|
}
|
|
|
|
|
|
|
|
function todo(condition, name, diag) {
|
|
|
|
dump("TODO: ", diag);
|
|
|
|
}
|
|
|
|
|
|
|
|
function run_test() {
|
|
|
|
runTest();
|
|
|
|
};
|
|
|
|
|
|
|
|
function runTest()
|
|
|
|
{
|
2012-07-14 04:24:20 -07:00
|
|
|
// XPCShell does not get a profile by default.
|
|
|
|
do_get_profile();
|
|
|
|
|
|
|
|
var idbManager = Cc["@mozilla.org/dom/indexeddb/manager;1"].
|
|
|
|
getService(Ci.nsIIndexedDatabaseManager);
|
|
|
|
idbManager.initWindowless(this);
|
|
|
|
|
2012-01-04 07:43:33 -08:00
|
|
|
do_test_pending();
|
|
|
|
testGenerator.next();
|
|
|
|
}
|
|
|
|
|
|
|
|
function finishTest()
|
|
|
|
{
|
|
|
|
do_execute_soon(function(){
|
|
|
|
testGenerator.close();
|
|
|
|
do_test_finished();
|
|
|
|
})
|
|
|
|
}
|
|
|
|
|
|
|
|
function grabEventAndContinueHandler(event)
|
|
|
|
{
|
|
|
|
testGenerator.send(event);
|
|
|
|
}
|
|
|
|
|
|
|
|
function continueToNextStep()
|
|
|
|
{
|
|
|
|
do_execute_soon(function() {
|
|
|
|
testGenerator.next();
|
|
|
|
});
|
|
|
|
}
|
|
|
|
|
|
|
|
function errorHandler(event)
|
|
|
|
{
|
2012-06-01 10:21:12 -07:00
|
|
|
dump("indexedDB error: " + event.target.error.name);
|
2012-01-04 07:43:33 -08:00
|
|
|
do_check_true(false);
|
|
|
|
finishTest();
|
|
|
|
}
|
|
|
|
|
|
|
|
function unexpectedSuccessHandler()
|
|
|
|
{
|
|
|
|
do_check_true(false);
|
|
|
|
finishTest();
|
|
|
|
}
|
|
|
|
|
2012-04-11 14:55:22 -07:00
|
|
|
function ExpectError(name)
|
2012-01-04 07:43:33 -08:00
|
|
|
{
|
2012-04-11 14:55:22 -07:00
|
|
|
this._name = name;
|
2012-01-04 07:43:33 -08:00
|
|
|
}
|
|
|
|
ExpectError.prototype = {
|
|
|
|
handleEvent: function(event)
|
|
|
|
{
|
|
|
|
do_check_eq(event.type, "error");
|
2012-04-11 14:55:22 -07:00
|
|
|
do_check_eq(this._name, event.target.error.name);
|
2012-01-04 07:43:33 -08:00
|
|
|
event.preventDefault();
|
|
|
|
grabEventAndContinueHandler(event);
|
|
|
|
}
|
|
|
|
};
|
|
|
|
|
|
|
|
function continueToNextStepSync()
|
|
|
|
{
|
|
|
|
testGenerator.next();
|
|
|
|
}
|
|
|
|
|
|
|
|
function compareKeys(k1, k2) {
|
|
|
|
let t = typeof k1;
|
|
|
|
if (t != typeof k2)
|
|
|
|
return false;
|
|
|
|
|
|
|
|
if (t !== "object")
|
|
|
|
return k1 === k2;
|
|
|
|
|
|
|
|
if (k1 instanceof Date) {
|
|
|
|
return (k2 instanceof Date) &&
|
|
|
|
k1.getTime() === k2.getTime();
|
|
|
|
}
|
|
|
|
|
|
|
|
if (k1 instanceof Array) {
|
|
|
|
if (!(k2 instanceof Array) ||
|
|
|
|
k1.length != k2.length)
|
|
|
|
return false;
|
|
|
|
|
|
|
|
for (let i = 0; i < k1.length; ++i) {
|
|
|
|
if (!compareKeys(k1[i], k2[i]))
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
|
|
|
function addPermission(permission, url)
|
|
|
|
{
|
|
|
|
throw "addPermission";
|
|
|
|
}
|
|
|
|
|
|
|
|
function removePermission(permission, url)
|
|
|
|
{
|
|
|
|
throw "removePermission";
|
|
|
|
}
|
|
|
|
|
|
|
|
function setQuota(quota)
|
|
|
|
{
|
|
|
|
throw "setQuota";
|
|
|
|
}
|
|
|
|
|
|
|
|
function allowIndexedDB(url)
|
|
|
|
{
|
|
|
|
throw "allowIndexedDB";
|
|
|
|
}
|
|
|
|
|
|
|
|
function disallowIndexedDB(url)
|
|
|
|
{
|
|
|
|
throw "disallowIndexedDB";
|
|
|
|
}
|
|
|
|
|
|
|
|
function allowUnlimitedQuota(url)
|
|
|
|
{
|
|
|
|
throw "allowUnlimitedQuota";
|
|
|
|
}
|
|
|
|
|
|
|
|
function disallowUnlimitedQuota(url)
|
|
|
|
{
|
|
|
|
throw "disallowUnlimitedQuota";
|
|
|
|
}
|
2012-06-01 10:21:12 -07:00
|
|
|
|
2012-08-10 09:15:02 -07:00
|
|
|
function gc()
|
|
|
|
{
|
|
|
|
Components.utils.forceGC();
|
|
|
|
Components.utils.forceCC();
|
|
|
|
}
|
|
|
|
|
2012-06-01 10:21:12 -07:00
|
|
|
var SpecialPowers = {
|
|
|
|
isMainProcess: function() {
|
|
|
|
return Components.classes["@mozilla.org/xre/app-info;1"]
|
|
|
|
.getService(Components.interfaces.nsIXULRuntime)
|
|
|
|
.processType == Ci.nsIXULRuntime.PROCESS_TYPE_DEFAULT;
|
|
|
|
}
|
|
|
|
};
|