summaryrefslogtreecommitdiffstats
path: root/toolkit/components/cookiebanners/test/browser/file_delayed_banner_load.html
blob: 0209ad76cd9e3c7924a076b210e34684991b3296 (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
<html>
<head>
  <title>A top-level page with delayed cookie banner</title>
  <script>
    function hideBanner() {
      document.getElementById("banner").style.display = "none";
    }

    function clickOptOut() {
      document.getElementById("result").textContent = "OptOut";
      hideBanner();
    }

    function clickOptIn() {
      document.getElementById("result").textContent = "OptIn";
      hideBanner();
    }

    function generateBanner() {
      let banner = document.createElement("div");
      banner.id = "banner";

      let buttonOptOut = document.createElement("button");
      buttonOptOut.id = "OptOut";
      buttonOptOut.onclick = () => {clickOptOut();};

      let buttonOptIn = document.createElement("button");
      buttonOptIn.id = "OptIn";
      buttonOptIn.onclick = () => {clickOptIn();};

      banner.appendChild(buttonOptOut);
      banner.appendChild(buttonOptIn);
      document.body.appendChild(banner);
    }

    window.onload = () => {
      generateBanner();
    };
  </script>
  <!-- This will cause DOMContentLoaded and load to be further apart which is
  required for certain test cases. slowSubresource.sjs will delay the page load
  event.-->
  <link rel="stylesheet" href="slowSubresource.sjs">
</head>
<body>
  <h1>This is the top-level page</h1>
  <p id="result">NoClick</p>
</body>
</html>