6 box-sizing: border-box;
11 border:
3px solid black;
15 box-sizing: content-box;
20 border:
3px solid black;
24 <script src=
"../../../http/tests/inspector/inspector-test.js"></script>
25 <script src=
"../../../http/tests/inspector/elements-test.js"></script>
28 var initialize_AdditionalPreload = function() {
29 InspectorTest
.preloadModule("source_frame");
32 function dumpDimensions()
36 element
= document
.getElementById("content-box");
37 document
.getElementById("output-content").textContent
= "content-box rendered dimensions: " + element
.offsetWidth
+ " x " + element
.offsetHeight
;
38 element
= document
.getElementById("border-box");
39 document
.getElementById("output-border").textContent
= "border-box rendered dimensions: " + element
.offsetWidth
+ " x " + element
.offsetHeight
;
44 var contentWidthElement
;
45 var contentHeightElement
;
47 function getChildTextByClassName(element
, className
)
49 var children
= element
.children
;
50 for (var i
= 0; i
< children
.length
; ++i
) {
51 if (children
[i
].classList
&& children
[i
].classList
.contains(className
))
52 return children
[i
].textContent
;
57 function dumpMetrics(sectionElement
)
59 var marginElement
= sectionElement
.getElementsByClassName("margin")[0];
60 var borderElement
= sectionElement
.getElementsByClassName("border")[0];
61 var paddingElement
= sectionElement
.getElementsByClassName("padding")[0];
62 var contentDimensions
= sectionElement
.getElementsByClassName("content")[0].getElementsByTagName("span");
63 InspectorTest
.addResult("margin: " + getChildTextByClassName(marginElement
, "top") + " " + getChildTextByClassName(marginElement
, "right") + " " + getChildTextByClassName(marginElement
, "bottom") + " " + getChildTextByClassName(marginElement
, "left"));
64 InspectorTest
.addResult("border: " + getChildTextByClassName(borderElement
, "top") + " " + getChildTextByClassName(borderElement
, "right") + " " + getChildTextByClassName(borderElement
, "bottom") + " " + getChildTextByClassName(borderElement
, "left"));
65 InspectorTest
.addResult("padding: " + getChildTextByClassName(paddingElement
, "top") + " " + getChildTextByClassName(paddingElement
, "right") + " " + getChildTextByClassName(paddingElement
, "bottom") + " " + getChildTextByClassName(paddingElement
, "left"));
66 InspectorTest
.addResult("content: " + contentDimensions
[0].textContent
+ " x " + contentDimensions
[1].textContent
);
69 function createDoubleClickEvent()
71 var event
= document
.createEvent("MouseEvent");
72 event
.initMouseEvent("dblclick", true, true, null, 2, 0, 0, 0, 0, false, false, false, false, 0, null);
76 InspectorTest
.runTestSuite([
77 function testBorderBoxInit1(next
)
79 InspectorTest
.selectNodeAndWaitForStyles("border-box", next
);
82 function testBorderBoxInit2(next
)
84 section
= WebInspector
.panels
.elements
.sidebarPanes
.metrics
;
86 InspectorTest
.addSniffer(section
._updateController
._updateThrottler
, "_processCompletedForTests", next
);
89 function testInitialBorderBoxMetrics(next
)
91 var spanElements
= section
.element
.getElementsByClassName("content")[0].getElementsByTagName("span");
92 contentWidthElement
= spanElements
[0];
93 contentHeightElement
= spanElements
[1];
94 InspectorTest
.addResult("=== Initial border-box ===");
95 dumpMetrics(section
.element
);
96 contentWidthElement
.dispatchEvent(createDoubleClickEvent());
97 contentWidthElement
.textContent
= "60";
98 contentWidthElement
.dispatchEvent(InspectorTest
.createKeyEvent("Enter"));
99 InspectorTest
.runAfterPendingDispatches(next
);
102 function testModifiedBorderBoxMetrics(next
)
104 InspectorTest
.addResult("=== Modified border-box ===");
105 dumpMetrics(section
.element
);
109 function testContentBoxInit1(next
)
111 InspectorTest
.selectNodeWithId("content-box", next
);
114 function testContentBoxInit2(next
)
116 section
= WebInspector
.panels
.elements
.sidebarPanes
.metrics
;
118 InspectorTest
.addSniffer(section
._updateController
._updateThrottler
, "_processCompletedForTests", next
);
121 function testInitialContentBoxMetrics(next
)
123 var spanElements
= section
.element
.getElementsByClassName("content")[0].getElementsByTagName("span");
124 contentWidthElement
= spanElements
[0];
125 contentHeightElement
= spanElements
[1];
126 InspectorTest
.addResult("=== Initial content-box ===");
127 dumpMetrics(section
.element
);
128 contentWidthElement
.dispatchEvent(createDoubleClickEvent());
129 contentWidthElement
.textContent
= "60";
130 contentWidthElement
.dispatchEvent(InspectorTest
.createKeyEvent("Enter"));
131 InspectorTest
.runAfterPendingDispatches(next
);
135 function testModifiedContentBoxMetrics(next
)
142 InspectorTest
.addResult("=== Modified content-box ===");
143 dumpMetrics(section
.element
);
144 InspectorTest
.evaluateInPage("dumpDimensions()", callback
);
151 <body onload=
"runTest()">
153 Tests that content-box and border-box content area dimensions are handled property by the Metrics pane.
155 <div id=
"content-box">content-box
</div>
156 <div id=
"border-box">border-box
</div>
157 <div id=
"output-content">zzz
</div>
158 <div id=
"output-border">zzz
</div>