summaryrefslogtreecommitdiffstats
path: root/devtools/shared/commands/resource/tests/sources.html
blob: 9e1ad67d85b227d6611403051cf5dae62a595cfb (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
<!-- Any copyright is dedicated to the Public Domain.
     http://creativecommons.org/publicdomain/zero/1.0/ -->
<!doctype HTML>
<html>
  <head>
    <meta charset="utf-8"/>
  </head>
  <body>
    <!-- introductionType=eventHandler -->
    <div onclick="console.log('link')">link</div>

    <!-- introductionType=inlineScript mapped to scriptElement -->
    <script type="text/javascript">
      "use strict";
      /* eslint-disable */
      function inlineSource() {}

      // introductionType=eval
      // Assign it to a global in order to avoid it being GCed
      eval("this.global = function evalFunction() {}");

      // introductionType=Function
      // Also assign to a global to avoid being GCed
      this.global2 = new Function("return 42;");

      // introductionType=injectedScript mapped to scriptElement
      const script = document.createElement("script");
      script.textContent = "console.log('inline-script')";
      document.documentElement.appendChild(script);

      // introductionType=Worker, but ends up being null on SourceActor's form
      // Assign the worker to a global variable in order to avoid
      // having it be GCed.
      this.worker = new Worker("worker-sources.js");

      window.registrationPromise = navigator.serviceWorker.register("service-worker-sources.js");

      // introductionType=domTimer
      setTimeout(`console.log("timeout")`, 0);

      // introductionType=eventHandler
      window.addEventListener("DOMContentLoaded", () => {
        document.querySelector("div[onclick]").click();
      });
    </script>
    <!-- introductionType=srcScript mapped to scriptElement -->
    <script src="sources.js"></script>
    <!-- introductionType=javascriptURL -->
    <iframe src="javascript:666"></iframe>
    <!-- srcdoc attribute on iframes -->
    <iframe srcdoc="<script>console.log('srcdoc')</script> <script>console.log('srcdoc 2')</script>"></iframe>
  </body>
</html>