File: offsetParent_element_test.html

package info (click to toggle)
thunderbird 1%3A68.10.0-1~deb9u1
  • links: PTS, VCS
  • area: main
  • in suites: stretch
  • size: 2,754,812 kB
  • sloc: cpp: 5,411,679; javascript: 4,161,772; ansic: 2,639,702; python: 763,064; java: 346,606; xml: 266,623; asm: 265,884; sh: 117,270; lisp: 41,340; makefile: 23,560; perl: 18,042; objc: 5,277; yacc: 1,778; ada: 1,681; pascal: 1,673; lex: 1,417; cs: 879; exp: 527; awk: 495; php: 436; ruby: 221; sed: 69; csh: 27
file content (130 lines) | stat: -rw-r--r-- 4,895 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
121
122
123
124
125
126
127
128
129
130
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">

<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<title>CSSOM View —— offsetParent element test</title>
<link rel="author" title="neo_and_rayi" href="mailto:1988wangxiao@gmail.com">
<link rel="help" href="http://www.w3.org/TR/cssom-view/#extensions-to-the-htmlelement-interface">
<link rel="help" href="http://www.w3.org/TR/cssom-view/#dom-htmlelement-offsetparent">
<script src="/resources/testharness.js"></script>
<script src="/resources/testharnessreport.js"></script>
<style>
#fixed {
    position: fixed;
}

#none-element {
    display:none;
}

#relative-element {
    position: relative;
}

#absolute-element {
    position: absolute;
}
</style>

</head>
<body>

<div id="body-element-child"></div>

<div id="relative-element">
    <div id="relative-element-child"></div>
</div>

<div id="absolute-element">
    <div id="absolute-element-child"></div>
</div>

<table id="table-element">
    <caption>
        <div id="caption-element-child"></div>
    </caption>

    <tbody>
    <tr id="table-element-tr">
        <td id="table-element-td">
            <span id="table-element-child"></span>
        </td>
    </tr>
    </tbody>
</table>

<div id="none-element">
    <a href="#" id="none-element-child-a"></a>
    <p id="none-element-child-p"></p>
    <video id="none-element-child-video"></video>
    <audio id="none-element-child-audio"></audio>
    <canvas id="none-element-child-canvas"></canvas>
    <svg id="none-element-child-svg"></svg>
</div>

<div id="fixed">
</div>

<div id="log"></div>
<script type="text/javascript">
var getStyle = window.getComputedStyle;
var html = document.documentElement;
var body = document.body;
var fixed_element = document.getElementById('fixed');
var none_element = document.getElementById('none-element');

var none_element_child_a = document.getElementById('none-element-child-a');
var none_element_child_p = document.getElementById('none-element-child-p');
var none_element_child_video = document.getElementById('none-element-child-video');
var none_element_child_audio = document.getElementById('none-element-child-audio');
var none_element_child_canvas = document.getElementById('none-element-child-canvas');
var none_element_child_svg = document.getElementById('none-element-child-svg');

var relative_element = document.getElementById('relative-element');
var absolute_element = document.getElementById('absolute-element');
var td_element = document.getElementsByTagName('td')[0];

var body_element_child = document.getElementById('body-element-child');
var relative_element_child = document.getElementById('relative-element-child');
var absolute_element_child = document.getElementById('absolute-element-child');
var table_element_child = document.getElementById('table-element-child');

var caption_element_child = document.getElementById('caption-element-child');
var table_element_tr = document.getElementById('table-element-tr');
var table_element = document.getElementById('table-element');

// The offsetParent attribute algorithm rule checking passed!
test(function() {
    assert_equals(html.offsetParent,null);
    assert_equals(body.offsetParent,null);
    assert_equals(fixed_element.offsetParent,null);
    assert_equals(none_element.offsetParent,null);
    assert_equals(none_element_child_a.offsetParent,null);
    assert_equals(none_element_child_p.offsetParent,null);
    assert_equals(none_element_child_video.offsetParent,null);
    assert_equals(none_element_child_audio.offsetParent,null);
    assert_equals(none_element_child_canvas.offsetParent,null);
    assert_equals(none_element_child_svg.offsetParent,undefined);
}, "Valid the algorithm rule of offsetParent check step 1");

// The offsetParent attribute algorithm rule checking passed!
test(function() {
    assert_equals(body_element_child.offsetParent,body);
    assert_equals(window.getComputedStyle(relative_element).position,'relative');
    assert_equals(relative_element_child.offsetParent,relative_element);
    assert_equals(window.getComputedStyle(absolute_element).position,'absolute');
    assert_equals(absolute_element_child.offsetParent,absolute_element);
    assert_equals(window.getComputedStyle(td_element).position,'static');
    assert_equals(table_element_child.offsetParent,td_element);
    assert_equals(window.getComputedStyle(table_element_tr).position,'static');
    assert_equals(table_element_tr.offsetParent,table_element);
    assert_equals(window.getComputedStyle(caption_element_child).position,'static');
    assert_equals(caption_element_child.offsetParent,table_element);
    assert_equals(window.getComputedStyle(td_element).position,'static');
    assert_equals(td_element.offsetParent,table_element);
}, "Valid the algorithm rule of offsetParent check step 2");

</script>

</body>
</html>