我在使用indexedDB时有一个非常基本的失败。在当前的Firefox(56.0,64位)中运行,但我已经看到这个问题了一段时间。
以下相当简单的html/javaScript演示了问题:
<!DOCTYPE html>
<html>
<head>
<title>indexedDB simple test</title>
<script src="/fb/jquery-2.2.4.min.js"></script>
</head>
<body>
<div id="wrapper"></div>
<script>
try {
if ('indexedDB' in window) {
$('#wrapper').append('Has native indexedDB<br />');
} else {
indexedDB = window.indexedDB || window.mozIndexedDB || window.webkitIndexedDB || window.msIndexedDB;
IDBTransaction = window.IDBTransaction || window.webkitIDBTransaction || window.msIDBTransaction;
IDBKeyRange = window.IDBKeyRange || window.webkitIDBKeyRange || window.msIDBKeyRange;
$('#wrapper').append('Has indexedDB, but not native<br />');
}
if (indexedDB) {
var ver = 1;
if ( ! 'open' in indexedDB ) {
$('#wrapper').append('indexedDB.open doesn't exist.<br />');
}
if ( typeof indexedDB.open != 'function' ) {
$('#wrapper').append('indexedDB.open is not a function.<br />');
}
try {
var request = indexedDB.open("foo", ver);
} catch (ex) {
$('#wrapper').append('indexedDB.open threw error.<br />');
}
}
} catch (ex) {
}
</script>
</body>
indexedDB
显示为本机;indexedDB.open
显示为现有功能;但是当称为时,Web控制台在indexed_db_simple_test.html上显示" Unknownerror":28:30。我不知道可能是什么问题。
我已经处理了几天。就我们的情况而言,我们发现问题是使用Firefox ESR的用户,似乎某种程度上,当配置文件从升级中弄脏时,索引dexedDB无法正常工作。我们发现的修复程序是使用此命令创建一个新的配置文件:
$ /Applications/Firefox.app/Contents/MacOS/firefox-bin -P
如果确实可以解决您的问题,那么您可以在Firefox问题中看到此处提到的问题:https://bugzilla.mozilla.org/show_bug.cgi?id=1246615
有关该配置文件命令的更多信息,请参见文档:https://support.mozilla.org/en-us/kb/profile-manager-manager-create-ande-ande-ande-and-remove-firefox-profiles
我们目前的解决方案不仅要使应用程序爆炸是进行类似这样的功能检查:
var DBOpenRequest = window.indexedDB.open('someDb');
DBOpenRequest.onerror = function(event) {
window.location.href = '/unsupported_browser.html';
};
我们还要求用户修复他们的配置文件,以启用我们的应用程序(依赖索引deceddb工作)。
我希望这会有所帮助!