-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathdurable.html
37 lines (34 loc) · 1.03 KB
/
durable.html
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
<script>
function log(str) {
document.getElementById("log").innerText += (str + "\n");
}
function checkPermission() {
navigator.storage.persistentPermission().then(function (result) {
log("Query result was " + result);
},
function (error) {
log(error);
});
}
function requestPermission() {
navigator.storage.requestPersistent().then(function (result) {
log("Request result was " + result);
},
function (error) {
log(error);
});
}
window.onload = function() {
document.getElementById("someButton").onclick = requestPermission;
document.getElementById("checkButton").onclick = checkPermission;
if (!navigator.storage) {
log("Can't find navigator.storage, maybe you aren't running with " +
"--enable-experimental-web-platform-features (or " +
"chrome://flags/#enable-experimental-web-platform-features) or your " +
"version of chrome is too old. You need at least ~46.0.2486.")
}
}
</script>
<button id="someButton">Request</button>
<button id="checkButton">Query</button>
<div id="log"></div>