Closed fniephaus closed 4 years ago
After trying to understand what is happening here, I think I have identified the problem.
If indexedDB
is unavailable, a fake DB is used and it does not call onerror
nor onsuccess
:
https://github.com/bertfreudenberg/SqueakJS/blob/a4d76c0dfecee23f2e499f957a0dd8e97bb88bff/vm.js#L474-L489
This naive fix seems to get it working:
this.dbTransaction("readonly", "get " + filepath, function(fileStore) {
var callFetchTemplateFile = function() {
Squeak.fetchTemplateFile(path.fullname,
function gotTemplate(template) {thenDo(template)},
function noTemplate() {
// if no indexedDB then we have checked fake db already
if (typeof indexedDB == "undefined") return errorDo("file not found: " + path.fullname);
// fall back on fake db, may be file is there
var fakeReq = Squeak.dbFake().get(path.fullname);
fakeReq.onerror = function(e) { errorDo("file not found: " + path.fullname) };
fakeReq.onsuccess = function(e) { thenDo(this.result); }
});
};
if (typeof indexedDB == "undefined") {
callFetchTemplateFile();
return;
}
var getReq = fileStore.get(path.fullname);
getReq.onerror = function(e) { errorDo(e.target.error.name) };
getReq.onsuccess = function(e) {
if (this.result !== undefined) return thenDo(this.result);
// might be a template
callFetchTemplateFile();
};
});
To reproduce, add
delete window.indexedDB;
after this line and then run Etoys.You should see something like this in the Console:![image](https://cloud.githubusercontent.com/assets/2368856/13029989/6a33826a-d293-11e5-9c8d-4609a18140d0.png)