File: test_bug375003-2.html

package info (click to toggle)
firefox 143.0.3-1
  • links: PTS, VCS
  • area: main
  • in suites: sid
  • size: 4,617,328 kB
  • sloc: cpp: 7,478,492; javascript: 6,417,157; ansic: 3,720,058; python: 1,396,372; xml: 627,523; asm: 438,677; java: 186,156; sh: 63,477; makefile: 19,171; objc: 13,059; perl: 12,983; yacc: 4,583; cs: 3,846; pascal: 3,405; lex: 1,720; ruby: 1,003; exp: 762; php: 436; lisp: 258; awk: 247; sql: 66; sed: 53; csh: 10
file content (120 lines) | stat: -rw-r--r-- 3,556 bytes parent folder | download | duplicates (10)
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
<!DOCTYPE HTML>
<html>
<!--
https://bugzilla.mozilla.org/show_bug.cgi?id=375003
-->
<head>
    <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
    <title>Test 2 for bug 375003</title>

    <script src="/tests/SimpleTest/SimpleTest.js"></script>
    <link rel="stylesheet" type="text/css" href="/tests/SimpleTest/test.css" />

    <style type="text/css">

        html {
             padding:0; margin:0;
        }
        body {
            color:black; background-color:white; font-size:12px; padding:10px; margin:0;
        }

        #div1,#abs1,#table1 {
          border: 20px solid lime;
          padding: 30px;
          width: 100px;
          height: 60px;
          overflow:scroll;
        }
        #abs1,#table2parent {
          position:absolute;
          left:500px;
        }
        #table3parent {
          position:fixed;
          left:300px;
          top:100px;
        }
        .content {
          display:block;
	  width:200px;
	  height:200px;
	  background:yellow;
	  border: 0px dotted black;
        }
</style>


<script type="text/javascript">
var x = [ 'Left','Top','Width','Height' ];
function test(id,s,expected, fuzzy) {
  var el = document.getElementById(id);
  for(var i = 0; i < x.length; ++i) {
    // eslint-disable-next-line no-eval
    var actual = eval('el.'+s+x[i]);
    if (expected[i] != -1 && s+x[i]!='scrollHeight') {
      let check = fuzzy ?
        (actual, expected, desc) => isfuzzy(actual, expected, 1, desc) :
        is;
      check(actual, expected[i], id+"."+s+x[i]);
    }
  }
}
function t3(id,c,o,s,pid,fuzzy) {
  test(id,'client',c);
  test(id,'offset',o);
  test(id,'scroll',s,fuzzy);
  var p = document.getElementById(id).offsetParent;
  is(p.id, pid, id+".offsetParent");
}

function run_test() {
   // Due to how the document is rendered and then scaled to viewport,
   // rounding errors are introduced that we need to account for.
   // This is propagated to only tests that we observed failures attributed
   // to the cause above, to prevent false negatives.
   // TODO(dshin, Bug 1930223): Perhaps the test runner should handle this.
   const fuzzy = navigator.appVersion.includes("Android");
   // XXX how test clientWidth/clientHeight (the -1 below) in cross-platform manner
   // without hard-coding the scrollbar width?
   t3('div1',[20,20,-1,-1],[10,10,200,160],[0,0,260,20],'body',fuzzy);
   t3('abs1',[20,20,-1,-1],[500,170,200,160],[0,0,260,20],'body',fuzzy);
   t3('table1',[0,0,306,306],[10,170,306,306],[0,0,306,306],'body');
   t3('table2',[0,0,206,206],[0,0,206,206],[0,0,206,20],'table2parent');
   t3('table3',[0,0,228,228],[0,0,228,228],[0,0,228,228],'table3parent');
   t3('table3parent',[0,0,228,228],[300,100,228,228],[0,0,228,228],'body');
}
</script>

</head>
<body id="body">
<div id="content">
<div id="div1parent">
  <div id="div1"><span class="content">DIV</span></div>
</div>

<div id="abs1parent">
  <div id="abs1"><span class="content">abs.pos.DIV</span></div>
</div>

<div id="table1parent">
  <table id="table1"><tbody><tr><td id="td1"><span class="content">TABLE</span></td></tr></tbody></table>
</div>

<div id="table2parent">
  <table id="table2"><tbody><tr><td id="td2"><span class="content">TABLE in abs</span></td></tr></tbody></table>
</div>

<div id="table3parent">
  <table id="table3" border="10"><tbody><tr><td id="td3"><span class="content">TABLE in fixed</span></td></tr></tbody></table>
</div>
</div>

<pre id="test">
<script class="testbody" type="text/javascript">
run_test();
</script>
</pre>

</body>
</html>