Permalink
Browse files

Use the Acid2 version from webstandards.org

It uses http://www.webstandards.org/404/ instead of
http://www.damowmow.com/404/ and thus does not have
network problems.

Also, using the new get_png_pages() API we can get
each page separately. No custom stylesheet is needed
anymore.
  • Loading branch information...
1 parent 45a09df commit cf822b981f631cb0aafeaa0772e8a19fff729cf5 @SimonSapin SimonSapin committed Jun 28, 2012
@@ -0,0 +1,17 @@
+<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN">
+<html>
+ <head>
+ <title>The Second Acid Test (Reference Rendering)</title>
+ <style type="text/css">
+ html { margin: 0; padding: 0; border: 0; overflow: hidden; background: white; }
+ body { margin: 0; padding: 0; border: 0; }
+ h2 { margin: 0; padding: 48px 0 36px 84px; border: 0; font: 24px/24px sans-serif; color: navy; }
+ p { margin: 0; padding: 0 0 0 72px; border: 0; }
+ img { vertical-align: top; margin: 0; padding: 0; border: 0; }
+ </style>
+ </head>
+ <body>
+ <h2>Hello&nbsp;World!</h2>
+ <p><a href="reference.png"><img src="data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAKgAAACoCAMAAABDlVWGAAABUFBMVEUAAAABAQADAwAICAAIpQQOpwodHQAhISAmryIsLAAwsy1AQEBDQwBSUgBTwFBUVAB1dQCAgACBgQCCggCDgwCEhACFhQCGhgCJiQCJ1IeKigCLiwCMjACOjgCPjwCPj4+SkgCTkwCVlQCXlwCYmACbmwCdnQCdnZ2fnwCgoACiogCi3aClpQCmpgCpqQCrqwCsrACtrQCvrwCwsLCysgCzswC2tgC8vAC9vQC+vgDBwQDCwgDDwwDExADIyADJyQDKygDKysrLywDNzQDOzgDO7c3Q0ADS0gDT0wDU1ADW1gDX1wDa2gDb29vd3QDf3wDg4ADh4QDk5ADl5QDo6ADo9ujp6QDq6gDq6urr6wDs7ADt7QDv7wDw8ADx8QDy8gDz8wDz+vP19QD29gD39wD4+AD5+QD7+wD7+/v8/AD9/QD9/f3+/gD+/v7//wD///+VIlNwAAADWklEQVR42u3d6VPaQB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FNhIACCiiggAL6daD4DwOAAgoooIACqljoDwseYUYsza58AAAAAElFTkSuQmCC" alt="Follow this link to view the reference image, which should be rendered below the text &quot;Hello World!&quot; on the test page in the same way that this paragraph is rendered below that text on this page."></a></p>
+ </body>
+</html>
@@ -117,19 +117,21 @@
<link rel="appendix stylesheet" href="data:text/css,.picture%20%7B%20background%3A%20none%3B%20%7D"> <!-- this stylesheet should be applied by default -->
</head>
<body>
+
<div class="intro">
<h1>Standards compliant?</h1>
- <p><a href="#top">Take The Acid2 Test</a> and compare it to <a
- href="reference.html">the reference rendering</a>.</p>
+ <p><a href="#top">Take The Acid2 Test</a> and compare it to <a href="reference.html">the reference rendering</a>.</p>
</div>
<h2 id="top">Hello World!</h2>
+
<div class="picture">
<p><table><tr><td></table><p class="bad"> <!-- <table> closes <p> per the HTML4 DTD -->
<blockquote class="first one"><address class="second two"></address></blockquote>
<div class="forehead"><div>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</div></div>
- <div class="eyes"><div id="eyes-a"><object data="data:application/x-unknown,ERROR"><object data="http://www.damowmow.com/404/" type="text/html"><object data="data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAGAAAAAYCAYAAAFy7sgCAAAGsUlEQVRo3u2ZbWwcZxHHf3s%2B7LNbO3ZjXBtowprGODRX0qpNQCjmJKuVKhMl1P2AkCwhFOIKkCBSm9IXavGFKAixIAECwkmWo5MrhRI3Ub40IEwQgp6aIDg3Cd6eEqyIHEteah%2B1E69vhw%2BZtTaX8704ZzkKjHS6271nZ56ZZ%2BY%2F%2F%2BdZKF%2FCwYshx3EkkggLsD1v4FQkEZZYLCbAKyG9%2Ba9EIsG6hnUAf8x74K3aUC3j4%2B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7lDaGg1%2FQgp43lfK0yqtRMuJa3ceKe5DfgYsCYAZ2ngD8CfAkzqTpW7xY%2F%2FSznyX%2FVeUb2kVmX4AAAAAElFTkSuQmCC">ERROR</object></object></object></div><div id="eyes-b"></div><div id="eyes-c"></div></div> <!-- that's a PNG with 8bit alpha containing two eyes -->
+ <div class="eyes"><div id="eyes-a"><object data="data:application/x-unknown,ERROR"><object data="http://www.webstandards.org/404/" type="text/html"><object data="data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAGAAAAAYCAYAAAFy7sgCAAAGsUlEQVRo3u2ZbWwcZxHHf3s%2B7LNbO3ZjXBtowprGODRX0qpNQCjmJKuVKhMl1P2AkCwhFOIKkCBSm9IXavGFKAixIAECwkmWo5MrhRI3Ub40IEwQgp6aIDg3Cd6eEqyIHEteah%2B1E69vhw%2BZtTaX8704ZzkKjHS6271nZ56ZZ%2BY%2F%2F%2BdZKF%2FCwYshx3EkkggLsD1v4FQkEZZYLCbAKyG9%2Ba9EIsG6hnUAf8x74K3aUC3j4%2BM54HcsR2oAIomwZOezkv%2FnSHpYNh%2BNCmAE7xv94zvFdd1bHsjMZmQkPSxAJP%2B%2FfuBLwK54PC7JZFKAVJmzXLBt2w%2FMvcDLwIb8QS8CeJ4nkURYIomw7J%2FYJ8BvSiiXptGGxWds2%2Fa9%2Bnaxh%2BYAD%2Bgt04NDgABTpQY2cvvSFLzw86gWeBVwC8SzlOSv2YeBPfmDBoBHgKmR9LBEEmHZfDTqGykqfkUE0nA78BzQGfSgUeP3wNeTXwXg7MwZDhw4UHL6ra2ti79%2FOvljgG8AZ4H64Lhm4MvAocxsRppGG%2FxcXihlwLIs6R%2FfKV2HO%2F26uA94pdDYUKUZUU7W1RQYXA98Gnhaf5%2FXWX0HeAHYoQonqa4sZSOsSWMCWeC9Yko%2BCQwBe4E6oNc0Tc91XTl1%2BaTsn9gnI%2Blhyc5nZWxsrBIkKSbl2tiic3tW53YDEwOKaoFBrcOfqKee53lG9xsPMjV784r%2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UHZ76PnZ1k2p0mJzlykmPancbOTnL0whHs7CQfb%2B5mx2d3sH79%2BtCRI0c6FeaOr9ICrIQfLvA%2B8BGNXxi4R6HrisJVUWrxAVW2oMFf0Aczim8o3kV6enowDIPjF9%2Fk%2BMU3S3rrjzMMg56eHr%2BxP7qKFbASfojG6kpeDGs1tiW53RxwWT%2Bin5q8w4xpQK5evQpAR30H7ZH2khNvj7TTUd8BgD4rqmu1ZKX8qNeY%2BfHz4zlXDgT5E8tpCTUq7XSBC4Euv8227TV9fX1E73%2BYtvo27BmbS9cvFVTY3bSRFza9yOcf6Gfmygy7d%2B%2Fm%2FPnzF4DvrsBLhnJlJfwIKXxv1PheAE4qK6p4H9AGbNKTuhngBPBPXYRe4IemaT5kWZbR19fHNbmGnZ1k4r3U4glDR30Hm5qjbGjsImJEOHbsGHv27JFz5869o0eFq01Jq%2BmHAXwI6FFKagMTgHM7GzFDS%2BoeLSMv7zjzC9x4Y7gxFovVDAwMEI1GaWlpWSzRVCrFwYMH%2FXfxZ4AfAa8B%2F7lDaGg1%2FQgp43lfK0yqtRMuJa3ceKe5DfgYsCYAZ2ngD8CfAkzqTpW7xY%2F%2FSznyX%2FVeUb2kVmX4AAAAAElFTkSuQmCC">ERROR</object></object></object></div><div id="eyes-b"></div><div id="eyes-c"></div></div> <!-- that's a PNG with 8bit alpha containing two eyes -->
<div class="nose"><div><div></div></div></div>
<div class="empty"><div></div></div>
+
<div class="smile"><div><div><span><em><strong></strong></em></span></div></div></div>
<div class="chin"><div>&nbsp;</div></div>
<div class="parser-container"><div class="parser"><!-- ->ERROR<!- --></div></div> <!-- two dashes is what delimits a comment, so the text "->ERROR<!-" earlier on this line is actually part of a comment -->
@@ -138,8 +140,9 @@ <h2 id="top">Hello World!</h2>
<li class="second-part"></li>
<li class="third-part"></li>
<li class="fourth-part"></li>
+
</ul>
<div class="image-height-test"><table><tr><td><img src="data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAEAAAABACAIAAAFSDNYfAAAAaklEQVR42u3XQQrAIAwAQeP%2F%2F6wf8CJBJTK9lnQ7FpHGaOurt1I34nfH9pMMZAZ8BwMGEvvh%2BBsJCAgICLwIOA8EBAQEBAQEBAQEBK79H5RfIQAAAAAAAAAAAAAAAAAAAAAAAAAAAID%2FABMSqAfj%2FsLmvAAAAABJRU5ErkJggg%3D%3D" alt=""></td></tr></table></div>
</div>
</body>
-</html>
+</html>
@@ -1,17 +0,0 @@
-<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN">
-<html>
- <head>
- <title>The Second Acid Test (Reference Rendering)</title>
- <style type="text/css">
- html { margin: 0; padding: 0; border: 0; overflow: hidden; background: white; }
- body { margin: 0; padding: 0; border: 0; }
- h2 { margin: 0; padding: 48px 0 36px 84px; border: 0; font: 24px/24px sans-serif; color: navy; }
- p { margin: 0; padding: 0 0 0 72px; border: 0; }
- img { vertical-align: top; margin: 0; padding: 0; border: 0; }
- </style>
- </head>
- <body>
- <h2>Hello&nbsp;World!</h2>
- <p><a href="reference.png"><img src="reference.png" alt="Follow this link to view the reference image, which should be rendered below the text &quot;Hello World!&quot; on the test page in the same way that this paragraph is rendered below that text on this page."></a></p>
- </body>
-</html>
Deleted file not rendered
@@ -17,7 +17,7 @@
import tempfile
import shutil
import itertools
-import socket
+import operator
from io import BytesIO
import pytest
@@ -124,9 +124,11 @@ def document_to_pixels(document, name, expected_width, expected_height,
"""
Render an HTML document to PNG, checks its size and return pixel data.
"""
- png_bytes = document.write_png()
assert len(document.pages) == nb_pages
+ return png_to_pixels(document.write_png(), expected_width, expected_height)
+
+def png_to_pixels(png_bytes, expected_width, expected_height):
with contextlib.closing(pystacia.read_blob(png_bytes)) as image:
assert image.size == (expected_width, expected_height)
raw = image.get_raw('rgba')['raw']
@@ -1922,29 +1924,19 @@ def test_2d_transform():
@assert_no_logs
def test_acid2():
"""A local version of http://acid2.acidtests.org/"""
- size = 640
- tolerance = 3
-
- stylesheet = CSS(string='''
- @page { -weasy-size: %ipx; margin: 0 }
-
- /* Remove the introduction from the test, it is not in the reference */
- .intro { display: none }
- ''' % size)
- def get_pixels(filename):
- return document_to_pixels(
- HTML(resource_filename(filename))._get_document(
- [stylesheet], True),
- 'acid2', size, size)
+ def get_png_pages(filename):
+ return HTML(resource_filename(filename)).get_png_pages()
with capture_logs():
- # http://www.damowmow.com/404/ sometimes times out on IPv6…
- previous_timeout = socket.getdefaulttimeout()
- socket.setdefaulttimeout(1)
- try:
- result = get_pixels('acid2/index.html')
- finally:
- socket.setdefaulttimeout(previous_timeout)
-
- reference = get_pixels('acid2/reference.html')
- assert_pixels_equal('acid2', size, size, result, reference, tolerance)
+ # This is a copy of http://www.webstandards.org/files/acid2/test.html
+ intro_page, test_page = get_png_pages('acid2-test.html')
+ # Ignore the intro page: it is not in the reference
+ width, height, test_png = test_page
+
+ # This is a copy of http://www.webstandards.org/files/acid2/reference.html
+ (ref_width, ref_height, ref_png), = get_png_pages('acid2-reference.html')
+
+ assert (width, height) == (ref_width, ref_height)
+ assert_pixels_equal(
+ 'acid2', width, height, png_to_pixels(test_png, width, height),
+ png_to_pixels(ref_png, width, height), tolerance=2)

0 comments on commit cf822b9

Please sign in to comment.