summaryrefslogtreecommitdiffstats
path: root/dom/tests/browser/page_localstorage_snapshotting_e10s.html
blob: ae8b685d02ed9849f2fd8416d2c03da010252496 (plain)
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
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
<!doctype html>
<html>
<head>
  <meta charset="utf-8">
<script>
/**
 * Helper page used by browser_localStorage_snapshotting.js.
 *
 * We expose methods to be invoked by ContentTask.spawn() calls.
 *
 **/
var pageName = document.location.search.substring(1);
window.addEventListener(
  "load",
  () => { document.getElementById("pageNameH").textContent = pageName; });

function applyMutations(mutations) {
  mutations.forEach(function([key, value]) {
    if (key !== null) {
      if (value === null) {
        localStorage.removeItem(key);
      } else {
        localStorage.setItem(key, value);
      }
    } else {
      localStorage.clear();
    }
  });
}

function getState() {
  let state = {};
  let length = localStorage.length;
  for (let index = 0; index < length; index++) {
    let key = localStorage.key(index);
    state[key] = localStorage.getItem(key);
  }
  return state;
}

function getKeys() {
  return Object.keys(localStorage);
}

function beginExplicitSnapshot() {
  localStorage.beginExplicitSnapshot();
}

function endExplicitSnapshot() {
  localStorage.endExplicitSnapshot();
}
</script>
</head>
<body><h2 id="pageNameH"></h2></body>
</html>