Skip to content

The headless browser for AI agents and web scraping

test: assert absolute placement coordinates

SGavrl1526d0220017
diff --git a/render-repros/absolute-containing-block.html b/render-repros/absolute-containing-block.html
new file mode 100644
index 00000000..4c8233cd
--- /dev/null
+++ b/render-repros/absolute-containing-block.html
@@ -0,0 +1,16 @@
+<!DOCTYPE html><html><head><title>absolute containing block</title><style>
+html,body{margin:0}
+.cb{position:relative;margin:40px 0 0 60px;width:400px;height:240px;padding:20px;border:10px solid #111;box-sizing:border-box;background:#ddd}
+.static{position:static;margin:50px 0 0 70px;width:120px;height:80px;background:#bbb}
+.absolute{position:absolute;left:15px;top:25px;width:80px;height:60px;background:#087f5b}
+.absolute-end{position:absolute;right:30px;bottom:20px;width:70px;height:50px;background:#1971c2}
+.absolute-percent{position:absolute;left:50%;top:50%;width:30px;height:30px;background:#f08c00}
+.fixed{position:fixed;left:520px;top:40px;width:90px;height:55px;background:#a61e4d}
+</style></head><body>
+<div class="cb"><div class="static">
+ <span class="absolute"></span>
+ <div class="absolute-end"></div>
+ <div class="absolute-percent"></div>
+ <div class="fixed"></div>
+</div></div>
+</body></html>
diff --git a/render-repros/check.py b/render-repros/check.py
index ad4bd1a2..fbb764c2 100755
--- a/render-repros/check.py
+++ b/render-repros/check.py
@@ -32,7 +32,15 @@ def components(array, color):
width = slices[1].stop - slices[1].start
area = int(mask[slices].sum())
if area >= 20:
- found.append({"width": width, "height": height, "area": area})
+ found.append(
+ {
+ "x": slices[1].start,
+ "y": slices[0].start,
+ "width": width,
+ "height": height,
+ "area": area,
+ }
+ )
return found
@@ -99,9 +107,11 @@ def main():
expected_count = check.get("count", 1)
matches = []
for component in components(array, rgb(check["color"])):
+ x_ok = "x" not in check or abs(component["x"] - check["x"]) <= 1
+ y_ok = "y" not in check or abs(component["y"] - check["y"]) <= 1
width_ok = "width" not in check or abs(component["width"] - check["width"]) <= 1
height_ok = "height" not in check or abs(component["height"] - check["height"]) <= 1
- if width_ok and height_ok:
+ if x_ok and y_ok and width_ok and height_ok:
matches.append(component)
passed = len(matches) >= expected_count
fixture["behavior"][engine].append(
diff --git a/render-repros/checks.json b/render-repros/checks.json
index b31d4e21..edd3889f 100644
--- a/render-repros/checks.json
+++ b/render-repros/checks.json
@@ -4,6 +4,12 @@
{"name": "teal fill", "color": "#008080", "width": 400, "height": 100},
{"name": "purple fill", "color": "#800080", "width": 400, "height": 100}
],
+ "absolute-containing-block": [
+ {"name": "nearest positioned ancestor", "color": "#087f5b", "x": 85, "y": 75, "width": 80, "height": 60},
+ {"name": "end insets use padding box", "color": "#1971c2", "x": 350, "y": 200, "width": 70, "height": 50},
+ {"name": "percent insets use padding box", "color": "#f08c00", "x": 260, "y": 160, "width": 30, "height": 30},
+ {"name": "fixed viewport containing block", "color": "#a61e4d", "x": 520, "y": 40, "width": 90, "height": 55}
+ ],
"box-sizing": [
{"name": "content-box fixed", "color": "#22aa55", "width": 220, "height": 90},
{"name": "border-box fixed", "color": "#228866", "width": 190, "height": 60},