summaryrefslogtreecommitdiffstats
path: root/testing/talos/talos/tests/devtools/addon/content/pages/custom/inspector/iframe.html
blob: 894f647089840a2f66a5cd3aea144fa64d3ba36b (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
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
<!DOCTYPE html>
<!-- This Source Code Form is subject to the terms of the Mozilla Public
   - License, v. 2.0. If a copy of the MPL was not distributed with this file,
   - You can obtain one at http://mozilla.org/MPL/2.0/.  -->
<html>
<head>
  <meta charset="utf-8">
  <title>Custom page for the Inspector</title>
  <style>
    div {
      margin-left: 0.5em;
    }
  </style>
</head>
<body>
  <script type="text/javascript">
    // We first create a deep tree with ${deep} nested children
    let deep = 50;
    // Then we create ${n} element after the deep tree
    let n = 50;
    // Number of attributes set on the repeated elements
    let attributes = 50;

    // Build the <div> with $attributes data attributes
    let div = "<div";
    for (var i = 1; i <= attributes; i++) {
      div += ` data-a${i}="${i}"`;
    }
    div += ">";

    // Build the tree of $deep elements
    let tree = "";
    for (i = 1; i <= deep; i++) {
      tree += new Array(i).join(" ");
      tree += div + " " + i + "\n";
    }
    for (i = deep; i >= 1; i--) {
      tree += new Array(i).join(" ");
      tree += "</div>\n";
    }

    // Build the list of $n elements
    let repeat = "";
    for (i = 1; i <= n; i++) {
      repeat += div + " " + i + " </div>\n";
    }

    // Prepare CSS rules to add to the document <style>.
    let CSS_RULES_COUNT = 200;
    let manyCssRules = "";
    for (i = 0; i < CSS_RULES_COUNT; i++) {
      manyCssRules += `
      .many-css-rules {
        font-size: ${i}px;
        margin: 10px;
        padding: 10px;
        font-family: Arial;
        margin: 20px;
      }`;
    }

    let CSS_VARIABLES_COUNT = 300;
    let manyCSSVariablesDeclarations = "";
    for (i = 0; i < CSS_VARIABLES_COUNT; i++) {
      manyCSSVariablesDeclarations += `
      --variable-${i}: ${i};
      content: var(--variable-${i});
      `
    }
    let manyCSSVariables = `.many-css-variables {
      ${manyCSSVariablesDeclarations}
    }`

    let expandManyChildren = new Array(100).join("  <div attr='my-attr'>content</div>\n");

    let maxBalancedDepth = 8;
    function createBalancedMarkup(level = 0) {
      let tab = new Array(level + 1).join("  ");
      if (level < maxBalancedDepth) {
        let child = createBalancedMarkup(level + 1);
        return `${tab}<div>
    ${child}
    ${child}
    ${tab}</div>`;
      } else {
        return tab + "<div class='leaf'>leaf</div>";
      }
    }
    let expandBalanced = createBalancedMarkup();

    let style = document.createElement("style");
    style.type = "text/css";
    style.appendChild(document.createTextNode(manyCssRules));
    style.appendChild(document.createTextNode(manyCSSVariables));
    document.head.appendChild(style);

    var tpl = document.createElement('template');
    tpl.innerHTML =
      `
       <div id="initial-node">
         <!-- <div> elements with ${deep} nested childs, all with ${attributes} attributes -->
         <!-- The deepest <div> has id="deep"> -->
         ${tree}
         <!-- ${n} <div> elements without any children -->
         ${repeat}
         <!-- Elements for custom.inspector.manyrules tests -->
         <div class="no-css-rules"></div>
         <div class="many-css-rules"></div>
         <div class="many-css-variables"></div>
         <div class="expand-many-children">
         ${expandManyChildren}
         </div>
         <div class="expand-balanced">
         ${expandBalanced}
         </div>
         <section class="nesting">
           <div class="deeply-nested"></div>
         </section>
       </div>`;
    document.body.appendChild(tpl.content);
  </script>

</body>
</html>