'UnknownError' 在 Firefox 中 indexedDB.open
'UnknownError' on indexedDB.open in Firefox
我在使用 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:28:30 处显示 'UnknownError'。我不知道哪里出了问题。
几天来我一直在处理这个问题。在我们的案例中,我们发现问题出在使用 Firefox ESR 的用户身上,似乎不知何故,当配置文件因升级而受到破坏时,它会使 indexedDB 无法正常工作。我们找到的修复方法是使用此命令创建新的配置文件:
$ /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-create-and-remove-firefox-profiles
我们目前的解决方案不仅是让应用程序崩溃,还要做一个功能检查,基本上是这样的:
var DBOpenRequest = window.indexedDB.open('someDb');
DBOpenRequest.onerror = function(event) {
window.location.href = '/unsupported_browser.html';
};
我们还要求用户修复他们的个人资料,以便能够使用我们的应用程序(它依赖于 indexedDB 来工作)。
希望对您有所帮助!
我在使用 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:28:30 处显示 'UnknownError'。我不知道哪里出了问题。
几天来我一直在处理这个问题。在我们的案例中,我们发现问题出在使用 Firefox ESR 的用户身上,似乎不知何故,当配置文件因升级而受到破坏时,它会使 indexedDB 无法正常工作。我们找到的修复方法是使用此命令创建新的配置文件:
$ /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-create-and-remove-firefox-profiles
我们目前的解决方案不仅是让应用程序崩溃,还要做一个功能检查,基本上是这样的:
var DBOpenRequest = window.indexedDB.open('someDb');
DBOpenRequest.onerror = function(event) {
window.location.href = '/unsupported_browser.html';
};
我们还要求用户修复他们的个人资料,以便能够使用我们的应用程序(它依赖于 indexedDB 来工作)。
希望对您有所帮助!