Skip to content

Commit f7c5b03

Browse files
committed
HTML: test UA style for embedded content
See whatwg/html#8028
1 parent b63072d commit f7c5b03

File tree

2 files changed

+76
-1
lines changed

2 files changed

+76
-1
lines changed
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,69 @@
1+
<!doctype html>
2+
<title>default styles for embedded content</title>
3+
<meta name="viewport" content="width=device-width">
4+
<script src="/resources/testharness.js"></script>
5+
<script src="/resources/testharnessreport.js"></script>
6+
<script src="/html/rendering/support/test-ua-stylesheet.js"></script>
7+
<style>
8+
/* Specify this bogus namespace, so the rules in this stylesheet only apply to the `fakeClone`d elements in #refs, not the HTML elements in #tests. */
9+
@namespace url(urn:not-html);
10+
@namespace svg url(urn:not-svg);
11+
12+
iframe { border: 2px inset; }
13+
video { object-fit: contain; }
14+
img, video, canvas, svg|svg:not(:root) {
15+
overflow: clip;
16+
overflow-clip-margin: content-box;
17+
}
18+
iframe, object, embed {
19+
overflow: clip !important;
20+
overflow-clip-margin: content-box !important;
21+
}
22+
</style>
23+
24+
<style>
25+
/* Check that !important rules are actually !important */
26+
@namespace url(http://www.w3.org/1999/xhtml);
27+
28+
iframe, object, embed {
29+
overflow: auto;
30+
overflow-clip-margin: border-box;
31+
}
32+
</style>
33+
34+
<div id="log"></div>
35+
36+
<div id="tests">
37+
<iframe></iframe>
38+
<video></video>
39+
<img>
40+
<canvas></canvas>
41+
<svg></svg>
42+
<object></object>
43+
<embed>
44+
</div>
45+
46+
<div id="refs"></div>
47+
48+
<script>
49+
const props = [
50+
'border-top-style',
51+
'border-right-style',
52+
'border-bottom-style',
53+
'border-left-style',
54+
'border-top-width',
55+
'border-right-width',
56+
'border-bottom-width',
57+
'border-left-width',
58+
'border-top-color',
59+
'border-right-color',
60+
'border-bottom-color',
61+
'border-left-color',
62+
'object-fit',
63+
'overflow-x',
64+
'overflow-y',
65+
'overflow-clip-margin',
66+
];
67+
runUAStyleTests(props);
68+
69+
</script>

html/rendering/support/test-ua-stylesheet.js

+7-1
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,13 @@ function runUAStyleTests(props) {
3333
}
3434

3535
function fakeClone(el) {
36-
const clone = document.createElementNS('urn:not-html', el.localName);
36+
let ns = 'urn:not-html';
37+
if (el.namespaceURI === 'http://www.w3.org/2000/svg') {
38+
ns = 'urn:not-svg';
39+
} else if (el.namespaceURI === 'http://www.w3.org/1998/Math/MathML') {
40+
ns = 'urn:not-mathml';
41+
}
42+
const clone = document.createElementNS(ns, el.localName);
3743
for (const att of el.attributes) {
3844
clone.setAttributeNS(att.namespaceURI, att.name, att.value);
3945
}

0 commit comments

Comments
 (0)