diff --git a/.gitattributes b/.gitattributes
index 6f479225..24a0444d 100644
--- a/.gitattributes
+++ b/.gitattributes
@@ -3,3 +3,6 @@
tests/data/** linguist-vendored
benches/data/** linguist-vendored
fuzz/corpus/** linguist-vendored
+
+# Keep the tree construction tests byte-for-byte: some of them contain CR characters.
+tests/data/tree-construction/*.dat -text diff
diff --git a/tests/data/tree-construction/README.md b/tests/data/tree-construction/README.md
new file mode 100644
index 00000000..7dbe7864
--- /dev/null
+++ b/tests/data/tree-construction/README.md
@@ -0,0 +1,25 @@
+# Tree construction tests
+
+These are the html5lib tree construction tests, copied from [html5lib-tests][html5lib-tests] at
+revision `9329e64694e7835d0dcff9811e22856ef6ad16f9`, the last one before they were removed from
+that repository. They are now maintained in [web-platform-tests][wpt] (WPT).
+
+We only use the inputs (the `#data` sections): the feedback tests compare our tokens against the
+ones html5ever produces for the same input. The scripted tests are not included (`scripted/` in
+html5lib-tests, `scripted_*.dat` in WPT), since they require script execution.
+
+To replace the files with the ones from WPT revision `$rev`, run this from the root of the
+repository (and update the source revision above):
+
+```sh
+url=https://raw.githubusercontent.com/web-platform-tests/wpt/$rev/html/syntax/parsing/resources
+rm tests/data/tree-construction/*.dat
+gh api "repos/web-platform-tests/wpt/contents/html/syntax/parsing/resources?ref=$rev" \
+ --jq '.[].name | select(endswith(".dat") and (startswith("scripted_") | not))' |
+ while read -r name; do
+ curl -sSfLo "tests/data/tree-construction/$name" "$url/$name"
+ done
+```
+
+[html5lib-tests]: https://github.com/html5lib/html5lib-tests
+[wpt]: https://github.com/web-platform-tests/wpt/tree/master/html/syntax/parsing/resources
diff --git a/tests/data/tree-construction/adoption01.dat b/tests/data/tree-construction/adoption01.dat
new file mode 100644
index 00000000..38f98efd
--- /dev/null
+++ b/tests/data/tree-construction/adoption01.dat
@@ -0,0 +1,354 @@
+#data
+