mirror of
https://github.com/LadybirdBrowser/ladybird
synced 2026-05-05 06:32:30 +02:00
Without this, an open request could hang if a prior connection was not explicitly close()d but instead allowed to go out of scope. The spec says that the dangling connection should be closed when the execution context it was opened in is destroyed, but no other browser does so. Detecting the execution context being destroyed would likely mean a lot of overhead in JS calls, so it's best to avoid that, despite this being observable.
47 lines
1.2 KiB
HTML
47 lines
1.2 KiB
HTML
<!DOCTYPE html>
|
|
<script src="include.js"></script>
|
|
<script>
|
|
asyncTest(done => {
|
|
const DB_NAME = "gc-closes-unreachable-connection";
|
|
|
|
indexedDB.deleteDatabase(DB_NAME);
|
|
|
|
function openAndForget() {
|
|
return new Promise((resolve) => {
|
|
let req = indexedDB.open(DB_NAME, 1);
|
|
req.onupgradeneeded = (e) => {
|
|
e.target.result.createObjectStore("store");
|
|
};
|
|
req.onsuccess = (e) => {
|
|
resolve();
|
|
};
|
|
});
|
|
}
|
|
|
|
function tryUpgrade() {
|
|
let req = indexedDB.open(DB_NAME, 2);
|
|
|
|
req.onblocked = () => {
|
|
println("FAIL: upgrade blocked, connection was not closed by GC");
|
|
done();
|
|
};
|
|
|
|
req.onupgradeneeded = () => {
|
|
println("PASS");
|
|
};
|
|
|
|
req.onsuccess = () => {
|
|
req.result.close();
|
|
indexedDB.deleteDatabase(DB_NAME);
|
|
done();
|
|
};
|
|
}
|
|
|
|
openAndForget().then(() => {
|
|
return internals.gcAsync()
|
|
}).then(() => {
|
|
tryUpgrade();
|
|
});
|
|
});
|
|
</script>
|