summaryrefslogtreecommitdiffstats
path: root/toolkit/components/antitracking/test/browser/localStorageEvents.html
blob: 737d1e0cabbb9499b257ca519c699d2e6546d4a2 (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
<script>

let eventCounter = 0;

onmessage = e => {
  if (e.data == "getValue") {
    parent.postMessage(localStorage.foo, "*");
    return;
  }

  if (e.data == "setValue") {
    localStorage.foo = "tracker-" + Math.random();
    return;
  }

  if (e.data == "getEvents") {
    parent.postMessage(eventCounter, "*");
    return;
  }

  if (e.data == "reload") {
    window.location.reload();
  }
};

addEventListener("storage", _ => {
  ++eventCounter;
});

</script>