htmlcmp 2.4.3__tar.gz → 2.5.0__tar.gz
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- {htmlcmp-2.4.3 → htmlcmp-2.5.0}/PKG-INFO +14 -1
- {htmlcmp-2.4.3 → htmlcmp-2.5.0}/README.md +13 -0
- {htmlcmp-2.4.3 → htmlcmp-2.5.0}/pyproject.toml +1 -1
- {htmlcmp-2.4.3 → htmlcmp-2.5.0}/src/htmlcmp/html_render_diff.py +55 -10
- {htmlcmp-2.4.3 → htmlcmp-2.5.0}/src/htmlcmp.egg-info/PKG-INFO +14 -1
- {htmlcmp-2.4.3 → htmlcmp-2.5.0}/tests/test_html_render_diff.py +31 -1
- {htmlcmp-2.4.3 → htmlcmp-2.5.0}/setup.cfg +0 -0
- {htmlcmp-2.4.3 → htmlcmp-2.5.0}/src/htmlcmp/__init__.py +0 -0
- {htmlcmp-2.4.3 → htmlcmp-2.5.0}/src/htmlcmp/common.py +0 -0
- {htmlcmp-2.4.3 → htmlcmp-2.5.0}/src/htmlcmp/compare_output_cli.py +0 -0
- {htmlcmp-2.4.3 → htmlcmp-2.5.0}/src/htmlcmp/compare_output_server.py +0 -0
- {htmlcmp-2.4.3 → htmlcmp-2.5.0}/src/htmlcmp/comparison_worker.py +0 -0
- {htmlcmp-2.4.3 → htmlcmp-2.5.0}/src/htmlcmp/static/common.js +0 -0
- {htmlcmp-2.4.3 → htmlcmp-2.5.0}/src/htmlcmp/static/compare.js +0 -0
- {htmlcmp-2.4.3 → htmlcmp-2.5.0}/src/htmlcmp/static/index.js +0 -0
- {htmlcmp-2.4.3 → htmlcmp-2.5.0}/src/htmlcmp/static/style.css +0 -0
- {htmlcmp-2.4.3 → htmlcmp-2.5.0}/src/htmlcmp/templates/compare.html +0 -0
- {htmlcmp-2.4.3 → htmlcmp-2.5.0}/src/htmlcmp/templates/index.html +0 -0
- {htmlcmp-2.4.3 → htmlcmp-2.5.0}/src/htmlcmp/templates/missing.html +0 -0
- {htmlcmp-2.4.3 → htmlcmp-2.5.0}/src/htmlcmp/tidy_output.py +0 -0
- {htmlcmp-2.4.3 → htmlcmp-2.5.0}/src/htmlcmp.egg-info/SOURCES.txt +0 -0
- {htmlcmp-2.4.3 → htmlcmp-2.5.0}/src/htmlcmp.egg-info/dependency_links.txt +0 -0
- {htmlcmp-2.4.3 → htmlcmp-2.5.0}/src/htmlcmp.egg-info/entry_points.txt +0 -0
- {htmlcmp-2.4.3 → htmlcmp-2.5.0}/src/htmlcmp.egg-info/requires.txt +0 -0
- {htmlcmp-2.4.3 → htmlcmp-2.5.0}/src/htmlcmp.egg-info/top_level.txt +0 -0
- {htmlcmp-2.4.3 → htmlcmp-2.5.0}/tests/test_browser_transport.py +0 -0
- {htmlcmp-2.4.3 → htmlcmp-2.5.0}/tests/test_collect_tasks.py +0 -0
- {htmlcmp-2.4.3 → htmlcmp-2.5.0}/tests/test_compare_html_retries.py +0 -0
- {htmlcmp-2.4.3 → htmlcmp-2.5.0}/tests/test_comparison_worker.py +0 -0
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.4
|
|
2
2
|
Name: htmlcmp
|
|
3
|
-
Version: 2.
|
|
3
|
+
Version: 2.5.0
|
|
4
4
|
Summary: Compare HTML files by rendered output
|
|
5
5
|
Author: Andreas Stefl
|
|
6
6
|
Maintainer-email: Andreas Stefl <stefl.andreas@gmail.com>
|
|
@@ -30,6 +30,19 @@ Provides various entry points to run:
|
|
|
30
30
|
|
|
31
31
|
Used for regression testing in https://github.com/opendocument-app/OpenDocument.core.
|
|
32
32
|
|
|
33
|
+
## When a screenshot is taken
|
|
34
|
+
|
|
35
|
+
A page is screenshotted once it has stopped changing:
|
|
36
|
+
|
|
37
|
+
- the document has loaded and its web fonts have arrived
|
|
38
|
+
- no element carries `aria-busy="true"`, the WAI-ARIA way for a page that keeps
|
|
39
|
+
laying itself out after load to say it is not done yet
|
|
40
|
+
- finite animations, such as a fade-in, have finished; an infinite one is left
|
|
41
|
+
running
|
|
42
|
+
- two frames have been painted since
|
|
43
|
+
|
|
44
|
+
Waiting stops after 10 seconds, and the page is screenshotted as it is then.
|
|
45
|
+
|
|
33
46
|
## Browser timeouts in the CLI
|
|
34
47
|
|
|
35
48
|
`compare-html --timeout 120` limits each browser comparison to 120 seconds,
|
|
@@ -10,6 +10,19 @@ Provides various entry points to run:
|
|
|
10
10
|
|
|
11
11
|
Used for regression testing in https://github.com/opendocument-app/OpenDocument.core.
|
|
12
12
|
|
|
13
|
+
## When a screenshot is taken
|
|
14
|
+
|
|
15
|
+
A page is screenshotted once it has stopped changing:
|
|
16
|
+
|
|
17
|
+
- the document has loaded and its web fonts have arrived
|
|
18
|
+
- no element carries `aria-busy="true"`, the WAI-ARIA way for a page that keeps
|
|
19
|
+
laying itself out after load to say it is not done yet
|
|
20
|
+
- finite animations, such as a fade-in, have finished; an infinite one is left
|
|
21
|
+
running
|
|
22
|
+
- two frames have been painted since
|
|
23
|
+
|
|
24
|
+
Waiting stops after 10 seconds, and the page is screenshotted as it is then.
|
|
25
|
+
|
|
13
26
|
## Browser timeouts in the CLI
|
|
14
27
|
|
|
15
28
|
`compare-html --timeout 120` limits each browser comparison to 120 seconds,
|
|
@@ -53,31 +53,76 @@ def screenshot(
|
|
|
53
53
|
return Image.open(io.BytesIO(png))
|
|
54
54
|
|
|
55
55
|
|
|
56
|
-
#: Waits
|
|
57
|
-
#:
|
|
58
|
-
#:
|
|
59
|
-
#:
|
|
56
|
+
#: Waits until the page has stopped changing, then for two frames, and answers
|
|
57
|
+
#: when that is done or the deadline passes.
|
|
58
|
+
#:
|
|
59
|
+
#: - `readyState` does not cover a web font: the load event fires while the face
|
|
60
|
+
#: is still arriving, and the text is laid out again once it lands.
|
|
61
|
+
#: - A page that keeps laying itself out after load marks what is still changing
|
|
62
|
+
#: with `aria-busy="true"` (WAI-ARIA), and clears it once that is done.
|
|
63
|
+
#: - A finite animation, such as a fade-in, is waited out; an infinite one never
|
|
64
|
+
#: ends, so it is left running.
|
|
65
|
+
#:
|
|
66
|
+
#: Two frames then say a paint has happened rather than merely been asked for.
|
|
67
|
+
#: The checks repeat until one round finds nothing to wait for, since finishing
|
|
68
|
+
#: one kind of work can start another.
|
|
60
69
|
_SETTLE = """
|
|
61
70
|
const done = arguments[arguments.length - 1];
|
|
62
|
-
const
|
|
63
|
-
|
|
64
|
-
(
|
|
71
|
+
const deadline = performance.now() + arguments[0];
|
|
72
|
+
const left = () => Math.max(0, deadline - performance.now());
|
|
73
|
+
const sleep = (ms) => new Promise((resolve) => setTimeout(resolve, ms));
|
|
74
|
+
const frame = () => new Promise((resolve) => requestAnimationFrame(resolve));
|
|
75
|
+
const busy = () => document.querySelector('[aria-busy="true"]') !== null;
|
|
76
|
+
const animations = () =>
|
|
77
|
+
document.getAnimations
|
|
78
|
+
? document.getAnimations().filter((animation) => {
|
|
79
|
+
const timing = animation.effect && animation.effect.getComputedTiming();
|
|
80
|
+
return (
|
|
81
|
+
animation.playState === "running" &&
|
|
82
|
+
timing !== null &&
|
|
83
|
+
timing.endTime !== Infinity
|
|
84
|
+
);
|
|
85
|
+
})
|
|
86
|
+
: [];
|
|
87
|
+
(async () => {
|
|
88
|
+
if (document.fonts) {
|
|
89
|
+
await Promise.race([document.fonts.ready.catch(() => {}), sleep(left())]);
|
|
90
|
+
}
|
|
91
|
+
for (;;) {
|
|
92
|
+
while (busy() && left() > 0) await sleep(50);
|
|
93
|
+
const running = animations();
|
|
94
|
+
if (running.length) {
|
|
95
|
+
await Promise.race([
|
|
96
|
+
Promise.all(running.map((a) => a.finished.catch(() => {}))),
|
|
97
|
+
sleep(left()),
|
|
98
|
+
]);
|
|
99
|
+
}
|
|
100
|
+
await frame();
|
|
101
|
+
await frame();
|
|
102
|
+
if (left() === 0 || (!busy() && animations().length === 0)) break;
|
|
103
|
+
}
|
|
104
|
+
done(true);
|
|
105
|
+
})();
|
|
65
106
|
"""
|
|
66
107
|
|
|
108
|
+
#: How long `settle` waits for the page, in seconds. The page gives up a second
|
|
109
|
+
#: before WebDriver does, so the screenshot follows either way.
|
|
110
|
+
_SETTLE_TIMEOUT = 10
|
|
111
|
+
|
|
67
112
|
|
|
68
113
|
def settle(browser: webdriver.Remote, settling_time: float = 0) -> None:
|
|
69
114
|
"""Waits until the page has finished painting what it loaded.
|
|
70
115
|
|
|
71
116
|
A screenshot taken before that catches the page mid-render, which is what
|
|
72
117
|
makes an otherwise identical pair compare as different from one run to the
|
|
73
|
-
next.
|
|
118
|
+
next. A page still busy at the deadline is screenshotted as it is.
|
|
74
119
|
"""
|
|
75
120
|
if not isinstance(browser, webdriver.Remote):
|
|
76
121
|
raise TypeError(f"Expected webdriver.Remote, got {type(browser)}")
|
|
77
122
|
|
|
78
|
-
browser.set_script_timeout(
|
|
123
|
+
browser.set_script_timeout(_SETTLE_TIMEOUT)
|
|
79
124
|
try:
|
|
80
|
-
browser.execute_async_script(_SETTLE)
|
|
125
|
+
browser.execute_async_script(_SETTLE, (_SETTLE_TIMEOUT - 1) * 1000)
|
|
81
126
|
except WebDriverException:
|
|
82
127
|
# an old driver without async scripts still gets the sleep below
|
|
83
128
|
pass
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.4
|
|
2
2
|
Name: htmlcmp
|
|
3
|
-
Version: 2.
|
|
3
|
+
Version: 2.5.0
|
|
4
4
|
Summary: Compare HTML files by rendered output
|
|
5
5
|
Author: Andreas Stefl
|
|
6
6
|
Maintainer-email: Andreas Stefl <stefl.andreas@gmail.com>
|
|
@@ -30,6 +30,19 @@ Provides various entry points to run:
|
|
|
30
30
|
|
|
31
31
|
Used for regression testing in https://github.com/opendocument-app/OpenDocument.core.
|
|
32
32
|
|
|
33
|
+
## When a screenshot is taken
|
|
34
|
+
|
|
35
|
+
A page is screenshotted once it has stopped changing:
|
|
36
|
+
|
|
37
|
+
- the document has loaded and its web fonts have arrived
|
|
38
|
+
- no element carries `aria-busy="true"`, the WAI-ARIA way for a page that keeps
|
|
39
|
+
laying itself out after load to say it is not done yet
|
|
40
|
+
- finite animations, such as a fade-in, have finished; an infinite one is left
|
|
41
|
+
running
|
|
42
|
+
- two frames have been painted since
|
|
43
|
+
|
|
44
|
+
Waiting stops after 10 seconds, and the page is screenshotted as it is then.
|
|
45
|
+
|
|
33
46
|
## Browser timeouts in the CLI
|
|
34
47
|
|
|
35
48
|
`compare-html --timeout 120` limits each browser comparison to 120 seconds,
|
|
@@ -2,7 +2,14 @@ import pytest
|
|
|
2
2
|
from pathlib import Path
|
|
3
3
|
import shutil
|
|
4
4
|
|
|
5
|
-
|
|
5
|
+
import time
|
|
6
|
+
|
|
7
|
+
from htmlcmp.html_render_diff import (
|
|
8
|
+
to_url,
|
|
9
|
+
get_browser,
|
|
10
|
+
html_render_diff,
|
|
11
|
+
screenshot,
|
|
12
|
+
)
|
|
6
13
|
|
|
7
14
|
|
|
8
15
|
def test_to_url():
|
|
@@ -49,3 +56,26 @@ def test_html_render_diff():
|
|
|
49
56
|
assert diff.getbbox() is not None
|
|
50
57
|
finally:
|
|
51
58
|
browser.quit()
|
|
59
|
+
|
|
60
|
+
|
|
61
|
+
@pytest.mark.parametrize("driver", ["chrome", "firefox"])
|
|
62
|
+
@pytest.mark.parametrize("page", ["busy.html", "animated.html"])
|
|
63
|
+
def test_screenshot_waits_for_the_page_to_settle(driver, page):
|
|
64
|
+
here = Path(__file__).parent
|
|
65
|
+
browser = get_browser(driver)
|
|
66
|
+
try:
|
|
67
|
+
diff, _ = html_render_diff(here / page, here / "settled.html", browser)
|
|
68
|
+
assert diff.getbbox() is None
|
|
69
|
+
finally:
|
|
70
|
+
browser.quit()
|
|
71
|
+
|
|
72
|
+
|
|
73
|
+
@pytest.mark.parametrize("driver", ["chrome", "firefox"])
|
|
74
|
+
def test_screenshot_leaves_an_infinite_animation_running(driver):
|
|
75
|
+
browser = get_browser(driver)
|
|
76
|
+
try:
|
|
77
|
+
started = time.monotonic()
|
|
78
|
+
screenshot(browser, to_url(Path(__file__).parent / "spinning.html"))
|
|
79
|
+
assert time.monotonic() - started < 5
|
|
80
|
+
finally:
|
|
81
|
+
browser.quit()
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|