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
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
|
/* vim: set ts=2 et sw=2 tw=80: */
/* Any copyright is dedicated to the Public Domain.
http://creativecommons.org/publicdomain/zero/1.0/ */
"use strict";
// Test that the box model displays the right values and that it updates when
// the node's style is changed
// Expected values:
var res1 = [
{
selector: "#boxmodel-element-size",
value: "160" + "\u00D7" + "160.117"
},
{
selector: ".boxmodel-size > span",
value: "100" + "\u00D7" + "100.117"
},
{
selector: ".boxmodel-margin.boxmodel-top > span",
value: 30
},
{
selector: ".boxmodel-margin.boxmodel-left > span",
value: "auto"
},
{
selector: ".boxmodel-margin.boxmodel-bottom > span",
value: 30
},
{
selector: ".boxmodel-margin.boxmodel-right > span",
value: "auto"
},
{
selector: ".boxmodel-padding.boxmodel-top > span",
value: 20
},
{
selector: ".boxmodel-padding.boxmodel-left > span",
value: 20
},
{
selector: ".boxmodel-padding.boxmodel-bottom > span",
value: 20
},
{
selector: ".boxmodel-padding.boxmodel-right > span",
value: 20
},
{
selector: ".boxmodel-border.boxmodel-top > span",
value: 10
},
{
selector: ".boxmodel-border.boxmodel-left > span",
value: 10
},
{
selector: ".boxmodel-border.boxmodel-bottom > span",
value: 10
},
{
selector: ".boxmodel-border.boxmodel-right > span",
value: 10
},
];
var res2 = [
{
selector: "#boxmodel-element-size",
value: "190" + "\u00D7" + "210"
},
{
selector: ".boxmodel-size > span",
value: "100" + "\u00D7" + "150"
},
{
selector: ".boxmodel-margin.boxmodel-top > span",
value: 30
},
{
selector: ".boxmodel-margin.boxmodel-left > span",
value: "auto"
},
{
selector: ".boxmodel-margin.boxmodel-bottom > span",
value: 30
},
{
selector: ".boxmodel-margin.boxmodel-right > span",
value: "auto"
},
{
selector: ".boxmodel-padding.boxmodel-top > span",
value: 20
},
{
selector: ".boxmodel-padding.boxmodel-left > span",
value: 20
},
{
selector: ".boxmodel-padding.boxmodel-bottom > span",
value: 20
},
{
selector: ".boxmodel-padding.boxmodel-right > span",
value: 50
},
{
selector: ".boxmodel-border.boxmodel-top > span",
value: 10
},
{
selector: ".boxmodel-border.boxmodel-left > span",
value: 10
},
{
selector: ".boxmodel-border.boxmodel-bottom > span",
value: 10
},
{
selector: ".boxmodel-border.boxmodel-right > span",
value: 10
},
];
add_task(function* () {
let style = "div { position: absolute; top: 42px; left: 42px; " +
"height: 100.111px; width: 100px; border: 10px solid black; " +
"padding: 20px; margin: 30px auto;}";
let html = "<style>" + style + "</style><div></div>";
yield addTab("data:text/html," + encodeURIComponent(html));
let {inspector, view, testActor} = yield openBoxModelView();
yield selectNode("div", inspector);
yield testInitialValues(inspector, view);
yield testChangingValues(inspector, view, testActor);
});
function* testInitialValues(inspector, view) {
info("Test that the initial values of the box model are correct");
let viewdoc = view.doc;
for (let i = 0; i < res1.length; i++) {
let elt = viewdoc.querySelector(res1[i].selector);
is(elt.textContent, res1[i].value,
res1[i].selector + " has the right value.");
}
}
function* testChangingValues(inspector, view, testActor) {
info("Test that changing the document updates the box model");
let viewdoc = view.doc;
let onUpdated = waitForUpdate(inspector);
yield testActor.setAttribute("div", "style",
"height:150px;padding-right:50px;");
yield onUpdated;
for (let i = 0; i < res2.length; i++) {
let elt = viewdoc.querySelector(res2[i].selector);
is(elt.textContent, res2[i].value,
res2[i].selector + " has the right value after style update.");
}
}
|