Skip to content

Commit

Permalink
Serving a repro for dexie/Dexie.js#1052
Browse files Browse the repository at this point in the history
  • Loading branch information
David Fahlander committed Nov 5, 2024
1 parent 0cb1da6 commit fdc5483
Showing 1 changed file with 79 additions and 0 deletions.
79 changes: 79 additions & 0 deletions test/dexie-issue-1052/repro-for-1052.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,79 @@
<!DOCTYPE html>
<html>
<!-- Include dexie.js -->
<script src="https://npmcdn.com/dexie/dist/dexie.js"></script>

<!-- Just a simple log function... -->
<script>
function log(txt) {
document.getElementById("log").value += txt + "\n";
}

// Check that browser supports generator functions:
try {
eval("(function* (){})");
} catch (e) {
log(
"This browser doesn't support generator functions. Must use a recent version of Chrome, Opera, Firefox or Edge."
);
}
</script>

<style>
body {
font-family: Arial;
padding: 10px;
}
textarea {
width: 100%;
height: 50vh;
}
</style>

<body>
<!-- Some HTML for the log window -->
<a href="http://dexie.org/docs/API-Reference" target="_new"
>Dexie API Reference (new tab)</a
>

<h3>Log</h3>
<textarea id="log"></textarea>
<p id="safari-version" style="display: none">
This browser denies indexedDB access from iframes.
<a href="https://fiddle.jshell.net/dfahlander/6rqyfag9/show" target="_top"
>Click here to open it directly without any iframe.</a
>
</p>
</body>

<script defer>
var db = new Dexie("MyFriendDB3");
db.version(1).stores({
consumption: "a, b",
});

async function main() {
log("User agent: " + navigator.userAgent);
log("Dexie: " + Dexie.semVer);
try {
const uniqueKeys = await db.consumption.orderBy("a").uniqueKeys();
log("Unique keys: " + JSON.stringify(uniqueKeys));
} catch (error) {
log(error);
}

await db.delete();
}

main().catch((e) => {
if (e.inner) e = e.inner;
if (e.name === "MissingAPIError") log("Couldn't find indexedDB API");
else if (e.name == "SecurityError") {
document.getElementById("log").style = "display:none";
document.getElementById("safari-version").style = "display:";
} else {
log(e);
}
});
</script>
</html>

0 comments on commit fdc5483

Please sign in to comment.