From 1953a0fb9bfa96caea69397ea980bc486dd84067 Mon Sep 17 00:00:00 2001 From: Jon Surrell Date: Wed, 17 Jan 2024 17:58:55 +0100 Subject: [PATCH] add html5lib tests MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Squashed commit of the following: commit ce0f083b4d0abf036613da2500a1974fd00994ac Author: Jon Surrell Date: Wed Jan 17 16:19:08 2024 +0100 Add skip for known bug - all tests passing or skipped commit dcdc710066486b36a78ec21634dd37a16954bdee Author: Jon Surrell Date: Wed Jan 17 16:15:05 2024 +0100 Rename class and test function commit 6a087d2626ecb555c654e43e81e2e5c8b5e37c15 Author: Jon Surrell Date: Wed Jan 17 16:11:42 2024 +0100 Fixing more lints commit 60d173848baa33bbb2c45a60c952c92c44eacb6d Author: Jon Surrell Date: Tue Jan 16 22:44:52 2024 +0100 Clean up and refactor test document parsing commit 2871f31f17e726d5b5895cee1859f9865222791a Author: Jon Surrell Date: Tue Jan 16 22:12:18 2024 +0100 Add attributes to html5lib tests commit 429c506464b20b9111680056313800e47054cf27 Author: Jon Surrell Date: Tue Jan 16 15:08:26 2024 +0100 Fix lint commit 36c94f71537098568c891de8649b3660990bb6da Author: Jon Surrell Date: Tue Jan 16 14:37:06 2024 +0100 Skip head tests commit 994b9d03cf498a798ec97fcd6374d4b1e3b2d4bb Author: Jon Surrell Date: Tue Jan 16 14:31:22 2024 +0100 Fix some comments commit e1fbeb4418d3fd80bb049b174bb68b408a21f7d1 Author: Jon Surrell Date: Tue Jan 16 14:13:11 2024 +0100 Fix strlen paren bug commit 84a61b1d5381d1de7a70eab42150cef1dfe32faa Author: Jon Surrell Date: Tue Jan 16 14:09:38 2024 +0100 Fix lints commit 315d5cd391abb67ad41a71103cc03f8cb58e258b Author: Jon Surrell Date: Tue Jan 16 14:09:31 2024 +0100 Mark unsupported markup tests as incomplete, not skipped commit 6035fd7a1fd4ee11ec443e4acb5e927c9a673f2f Author: Jon Surrell Date: Tue Jan 16 14:06:10 2024 +0100 Skip incomplete token tests commit 3772db61ce1a12a74db9a652a4fd471c36482061 Author: Jon Surrell Date: Tue Jan 16 14:01:29 2024 +0100 Update ignores commit f1b23b6af9f8873aec676dc3105de8f7f44d5835 Author: Jon Surrell Date: Mon Jan 15 21:35:50 2024 +0100 Fix HTML input processing commit 1e0188803e8aa7fded0142be8ca1001938a219f4 Author: Jon Surrell Date: Mon Jan 15 19:05:22 2024 +0100 Use padded line number Allows filetering like line0001 so not line1 line10 line11… commit 48eb7b98b97674dc7a32f1d9fc1858400aededee Author: Jon Surrell Date: Mon Jan 15 18:31:27 2024 +0100 Use line numbers for test IDs Line numbers are stable even if we skip tests commit 91c6f73ca2531f8453387c6029612b7a4fa6c5a9 Author: Jon Surrell Date: Fri Dec 22 17:38:19 2023 +0100 Avoid running tests that expect anything in commit e570196f62a23d77eda8054c25cb28cab401ace3 Author: Dennis Snell Date: Wed Dec 20 10:49:50 2023 -0600 Add extra skipped tests commit d642bfb3028e1f5f002ab903ece01590292a400f Author: Jon Surrell Date: Wed Dec 20 13:22:07 2023 +0100 Fix expect/actual ordering, add test message commit 12dcc69e9612a7588b9fc0d62db7c8a76610564f Author: Jon Surrell Date: Tue Dec 19 20:20:26 2023 +0100 Move test data to test data dir commit 138d21ff9fd7911f048b9e278d92346c7927941d Author: Jon Surrell Date: Tue Dec 19 18:32:55 2023 +0100 Add ignores for formatting elements commit 47d2f36a82bb9c88d1215f87a96d0aa42f12a344 Author: Jon Surrell Date: Tue Dec 19 18:25:56 2023 +0100 Fix lint commit 4c6a28b25a798eceb9d029c335a3231bbcf48b48 Author: Jon Surrell Date: Tue Dec 19 18:16:09 2023 +0100 Add files crediting html5lib-tests project commit f5afccb0441156076a0dd1d2f24225f9dcd6cfe4 Author: Jon Surrell Date: Tue Dec 19 18:06:37 2023 +0100 Add skipping of certain tests commit 123ae095c7d0a829ebd0ece9aaeba5312064acbf Author: Jon Surrell Date: Tue Dec 19 15:30:03 2023 +0100 Remove space from test identifier, easier copy/paste filtering commit d995e4448bcb31f83889e86f8ec2126a84787f7a Author: Jon Surrell Date: Tue Dec 19 15:20:47 2023 +0100 Better tag finding commit db5e68fcf74068764d2206606f9d349e53e1309e Author: Jon Surrell Date: Tue Dec 19 14:07:30 2023 +0100 Print nicer tests names commit 257b87128ec2567f81ac8462d78309855fef8d45 Author: Jon Surrell Date: Tue Dec 19 13:59:21 2023 +0100 Skip doctype and comments in test dom tree commit b31c9213d9318f77c689d8f53565e5809333bc46 Author: Jon Surrell Date: Tue Dec 19 13:58:57 2023 +0100 1-index test case numbering commit 10dc753b0347bc14f8b20565b3f34294ef5059d0 Author: Dennis Snell Date: Mon Dec 18 16:20:41 2023 -0600 WPCS Nags commit 087e7bb51779bfad9cb39da306e48009f5ab70d4 Author: Dennis Snell Date: Mon Dec 18 15:57:53 2023 -0600 Add line number to test case label commit 4f5ca93d1970decb86428ea1b903e98931c079af Author: Dennis Snell Date: Mon Dec 18 15:23:47 2023 -0600 Avoid WPCS lint nags; skip tests for unsupported input or fragment context. commit 9faf91bf755872acbf481d09331eedaea7c97518 Author: Jon Surrell Date: Mon Dec 18 21:38:12 2023 +0100 Skip unhandled tests commit 077e0829782f576e93f132ce1f9e7543ed43861f Author: Jon Surrell Date: Mon Dec 18 21:22:51 2023 +0100 fix lints commit bf618ac21286937d7a43d5beab18a77b81490c39 Author: Jon Surrell Date: Mon Dec 18 21:18:04 2023 +0100 Move html5lib tests to new class commit 1f89fbdb78b1e8dd5ac1100b6d2f08c8445a00c6 Author: Jon Surrell Date: Mon Dec 18 21:13:49 2023 +0100 Remove git files from html5lib commit ed2f78423de4a6f8560d2355d157d8d08e84f07b Author: Jon Surrell Date: Mon Dec 18 20:26:12 2023 +0100 Add test cases from html5lib-tests tree-construction --- tests/phpunit/data/html5lib-tests/AUTHORS.rst | 34 + tests/phpunit/data/html5lib-tests/LICENSE | 21 + tests/phpunit/data/html5lib-tests/README.md | 8 + .../tree-construction/README.md | 108 + .../tree-construction/adoption01.dat | 354 +++ .../tree-construction/adoption02.dat | 39 + .../tree-construction/blocks.dat | 695 +++++ .../tree-construction/comments01.dat | 217 ++ .../tree-construction/doctype01.dat | 474 +++ .../tree-construction/domjs-unsafe.dat | Bin 0 -> 10356 bytes .../tree-construction/entities01.dat | 943 ++++++ .../tree-construction/entities02.dat | 309 ++ .../tree-construction/foreign-fragment.dat | 645 ++++ .../tree-construction/html5test-com.dat | 301 ++ .../tree-construction/inbody01.dat | 54 + .../tree-construction/isindex.dat | 49 + .../tree-construction/main-element.dat | 46 + .../html5lib-tests/tree-construction/math.dat | 104 + .../tree-construction/menuitem-element.dat | 240 ++ .../namespace-sensitivity.dat | 22 + .../tree-construction/noscript01.dat | 237 ++ ...pending-spec-changes-plain-text-unsafe.dat | Bin 0 -> 927 bytes .../pending-spec-changes.dat | 46 + .../tree-construction/plain-text-unsafe.dat | Bin 0 -> 9486 bytes .../tree-construction/quirks01.dat | 53 + .../html5lib-tests/tree-construction/ruby.dat | 302 ++ .../tree-construction/scriptdata01.dat | 372 +++ .../tree-construction/search-element.dat | 46 + .../html5lib-tests/tree-construction/svg.dat | 104 + .../tree-construction/tables01.dat | 322 ++ .../tree-construction/template.dat | 1673 +++++++++++ .../tree-construction/tests1.dat | 1956 +++++++++++++ .../tree-construction/tests10.dat | 849 ++++++ .../tree-construction/tests11.dat | 523 ++++ .../tree-construction/tests12.dat | 62 + .../tree-construction/tests14.dat | 75 + .../tree-construction/tests15.dat | 216 ++ .../tree-construction/tests16.dat | 2602 +++++++++++++++++ .../tree-construction/tests17.dat | 179 ++ .../tree-construction/tests18.dat | 558 ++++ .../tree-construction/tests19.dat | 1398 +++++++++ .../tree-construction/tests2.dat | 831 ++++++ .../tree-construction/tests20.dat | 842 ++++++ .../tree-construction/tests21.dat | 306 ++ .../tree-construction/tests22.dat | 190 ++ .../tree-construction/tests23.dat | 168 ++ .../tree-construction/tests24.dat | 79 + .../tree-construction/tests25.dat | 288 ++ .../tree-construction/tests26.dat | 453 +++ .../tree-construction/tests3.dat | 305 ++ .../tree-construction/tests4.dat | 74 + .../tree-construction/tests5.dat | 210 ++ .../tree-construction/tests6.dat | 663 +++++ .../tree-construction/tests7.dat | 453 +++ .../tree-construction/tests8.dat | 165 ++ .../tree-construction/tests9.dat | 472 +++ .../tree-construction/tests_innerHTML_1.dat | 843 ++++++ .../tree-construction/tricky01.dat | 336 +++ .../tree-construction/webkit01.dat | 785 +++++ .../tree-construction/webkit02.dat | 554 ++++ .../html-api/wpHtmlProcessorHtml5lib.php | 309 ++ 61 files changed, 24562 insertions(+) create mode 100644 tests/phpunit/data/html5lib-tests/AUTHORS.rst create mode 100644 tests/phpunit/data/html5lib-tests/LICENSE create mode 100644 tests/phpunit/data/html5lib-tests/README.md create mode 100644 tests/phpunit/data/html5lib-tests/tree-construction/README.md create mode 100644 tests/phpunit/data/html5lib-tests/tree-construction/adoption01.dat create mode 100644 tests/phpunit/data/html5lib-tests/tree-construction/adoption02.dat create mode 100644 tests/phpunit/data/html5lib-tests/tree-construction/blocks.dat create mode 100644 tests/phpunit/data/html5lib-tests/tree-construction/comments01.dat create mode 100644 tests/phpunit/data/html5lib-tests/tree-construction/doctype01.dat create mode 100644 tests/phpunit/data/html5lib-tests/tree-construction/domjs-unsafe.dat create mode 100644 tests/phpunit/data/html5lib-tests/tree-construction/entities01.dat create mode 100644 tests/phpunit/data/html5lib-tests/tree-construction/entities02.dat create mode 100644 tests/phpunit/data/html5lib-tests/tree-construction/foreign-fragment.dat create mode 100644 tests/phpunit/data/html5lib-tests/tree-construction/html5test-com.dat create mode 100644 tests/phpunit/data/html5lib-tests/tree-construction/inbody01.dat create mode 100644 tests/phpunit/data/html5lib-tests/tree-construction/isindex.dat create mode 100644 tests/phpunit/data/html5lib-tests/tree-construction/main-element.dat create mode 100644 tests/phpunit/data/html5lib-tests/tree-construction/math.dat create mode 100644 tests/phpunit/data/html5lib-tests/tree-construction/menuitem-element.dat create mode 100644 tests/phpunit/data/html5lib-tests/tree-construction/namespace-sensitivity.dat create mode 100644 tests/phpunit/data/html5lib-tests/tree-construction/noscript01.dat create mode 100644 tests/phpunit/data/html5lib-tests/tree-construction/pending-spec-changes-plain-text-unsafe.dat create mode 100644 tests/phpunit/data/html5lib-tests/tree-construction/pending-spec-changes.dat create mode 100644 tests/phpunit/data/html5lib-tests/tree-construction/plain-text-unsafe.dat create mode 100644 tests/phpunit/data/html5lib-tests/tree-construction/quirks01.dat create mode 100644 tests/phpunit/data/html5lib-tests/tree-construction/ruby.dat create mode 100644 tests/phpunit/data/html5lib-tests/tree-construction/scriptdata01.dat create mode 100644 tests/phpunit/data/html5lib-tests/tree-construction/search-element.dat create mode 100644 tests/phpunit/data/html5lib-tests/tree-construction/svg.dat create mode 100644 tests/phpunit/data/html5lib-tests/tree-construction/tables01.dat create mode 100644 tests/phpunit/data/html5lib-tests/tree-construction/template.dat create mode 100644 tests/phpunit/data/html5lib-tests/tree-construction/tests1.dat create mode 100644 tests/phpunit/data/html5lib-tests/tree-construction/tests10.dat create mode 100644 tests/phpunit/data/html5lib-tests/tree-construction/tests11.dat create mode 100644 tests/phpunit/data/html5lib-tests/tree-construction/tests12.dat create mode 100644 tests/phpunit/data/html5lib-tests/tree-construction/tests14.dat create mode 100644 tests/phpunit/data/html5lib-tests/tree-construction/tests15.dat create mode 100644 tests/phpunit/data/html5lib-tests/tree-construction/tests16.dat create mode 100644 tests/phpunit/data/html5lib-tests/tree-construction/tests17.dat create mode 100644 tests/phpunit/data/html5lib-tests/tree-construction/tests18.dat create mode 100644 tests/phpunit/data/html5lib-tests/tree-construction/tests19.dat create mode 100644 tests/phpunit/data/html5lib-tests/tree-construction/tests2.dat create mode 100644 tests/phpunit/data/html5lib-tests/tree-construction/tests20.dat create mode 100644 tests/phpunit/data/html5lib-tests/tree-construction/tests21.dat create mode 100644 tests/phpunit/data/html5lib-tests/tree-construction/tests22.dat create mode 100644 tests/phpunit/data/html5lib-tests/tree-construction/tests23.dat create mode 100644 tests/phpunit/data/html5lib-tests/tree-construction/tests24.dat create mode 100644 tests/phpunit/data/html5lib-tests/tree-construction/tests25.dat create mode 100644 tests/phpunit/data/html5lib-tests/tree-construction/tests26.dat create mode 100644 tests/phpunit/data/html5lib-tests/tree-construction/tests3.dat create mode 100644 tests/phpunit/data/html5lib-tests/tree-construction/tests4.dat create mode 100644 tests/phpunit/data/html5lib-tests/tree-construction/tests5.dat create mode 100644 tests/phpunit/data/html5lib-tests/tree-construction/tests6.dat create mode 100644 tests/phpunit/data/html5lib-tests/tree-construction/tests7.dat create mode 100644 tests/phpunit/data/html5lib-tests/tree-construction/tests8.dat create mode 100644 tests/phpunit/data/html5lib-tests/tree-construction/tests9.dat create mode 100644 tests/phpunit/data/html5lib-tests/tree-construction/tests_innerHTML_1.dat create mode 100644 tests/phpunit/data/html5lib-tests/tree-construction/tricky01.dat create mode 100644 tests/phpunit/data/html5lib-tests/tree-construction/webkit01.dat create mode 100644 tests/phpunit/data/html5lib-tests/tree-construction/webkit02.dat create mode 100644 tests/phpunit/tests/html-api/wpHtmlProcessorHtml5lib.php diff --git a/tests/phpunit/data/html5lib-tests/AUTHORS.rst b/tests/phpunit/data/html5lib-tests/AUTHORS.rst new file mode 100644 index 0000000000000..4a7de17ad456c --- /dev/null +++ b/tests/phpunit/data/html5lib-tests/AUTHORS.rst @@ -0,0 +1,34 @@ +Credits +======= + +The ``html5lib`` test data is maintained by: + +- James Graham +- Geoffrey Sneddon + + +Contributors +------------ + +- Adam Barth +- Andi Sidwell +- Anne van Kesteren +- David Flanagan +- Edward Z. Yang +- Geoffrey Sneddon +- Henri Sivonen +- Ian Hickson +- Jacques Distler +- James Graham +- Lachlan Hunt +- lantis63 +- Mark Pilgrim +- Mats Palmgren +- Ms2ger +- Nolan Waite +- Philip Taylor +- Rafael Weinstein +- Ryan King +- Sam Ruby +- Simon Pieters +- Thomas Broyer diff --git a/tests/phpunit/data/html5lib-tests/LICENSE b/tests/phpunit/data/html5lib-tests/LICENSE new file mode 100644 index 0000000000000..8812371b41cfc --- /dev/null +++ b/tests/phpunit/data/html5lib-tests/LICENSE @@ -0,0 +1,21 @@ +Copyright (c) 2006-2013 James Graham, Geoffrey Sneddon, and +other contributors + +Permission is hereby granted, free of charge, to any person obtaining +a copy of this software and associated documentation files (the +"Software"), to deal in the Software without restriction, including +without limitation the rights to use, copy, modify, merge, publish, +distribute, sublicense, and/or sell copies of the Software, and to +permit persons to whom the Software is furnished to do so, subject to +the following conditions: + +The above copyright notice and this permission notice shall be +included in all copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, +EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF +MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND +NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE +LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION +OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION +WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. diff --git a/tests/phpunit/data/html5lib-tests/README.md b/tests/phpunit/data/html5lib-tests/README.md new file mode 100644 index 0000000000000..07d8ecb62551b --- /dev/null +++ b/tests/phpunit/data/html5lib-tests/README.md @@ -0,0 +1,8 @@ +html5lib-tests +============== + +This test data was taken from: + +https://github.com/html5lib/html5lib-tests + +The sha was `a9f44960a9fedf265093d22b2aa3c7ca123727b9`. diff --git a/tests/phpunit/data/html5lib-tests/tree-construction/README.md b/tests/phpunit/data/html5lib-tests/tree-construction/README.md new file mode 100644 index 0000000000000..4737a3a867e86 --- /dev/null +++ b/tests/phpunit/data/html5lib-tests/tree-construction/README.md @@ -0,0 +1,108 @@ +Tree Construction Tests +======================= + +Each file containing tree construction tests consists of any number of +tests separated by two newlines (LF) and a single newline before the end +of the file. For instance: + + [TEST]LF + LF + [TEST]LF + LF + [TEST]LF + +Where [TEST] is the following format: + +Each test must begin with a string "\#data" followed by a newline (LF). +All subsequent lines until a line that says "\#errors" are the test data +and must be passed to the system being tested unchanged, except with the +final newline (on the last line) removed. + +Then there must be a line that says "\#errors". It must be followed by +one line per parse error that a conformant checker would return. It +doesn't matter what those lines are, although they can't be +"\#new-errors", "\#document-fragment", "\#document", "\#script-off", +"\#script-on", or empty, the only thing that matters is that there be +the right number of parse errors. + +Then there \*may\* be a line that says "\#new-errors", which works like +the "\#errors" section adding more errors to the expected number of +errors. + +Then there \*may\* be a line that says "\#document-fragment", which must +be followed by a newline (LF), followed by a string of characters that +indicates the context element, followed by a newline (LF). If the string +of characters starts with "svg ", the context element is in the SVG +namespace and the substring after "svg " is the local name. If the +string of characters starts with "math ", the context element is in the +MathML namespace and the substring after "math " is the local name. +Otherwise, the context element is in the HTML namespace and the string +is the local name. If this line is present the "\#data" must be parsed +using the HTML fragment parsing algorithm with the context element as +context. + +Then there \*may\* be a line that says "\#script-off" or +"\#script-on". If a line that says "\#script-off" is present, the +parser must set the scripting flag to disabled. If a line that says +"\#script-on" is present, it must set it to enabled. Otherwise, the +test should be run in both modes. + +Then there must be a line that says "\#document", which must be followed +by a dump of the tree of the parsed DOM. Each node must be represented +by a single line. Each line must start with "| ", followed by two spaces +per parent node that the node has before the root document node. + +- Element nodes must be represented by a "`<`" then the *tag name + string* "`>`", and all the attributes must be given, sorted + lexicographically by UTF-16 code unit according to their *attribute + name string*, on subsequent lines, as if they were children of the + element node. +- Attribute nodes must have the *attribute name string*, then an "=" + sign, then the attribute value in double quotes ("). +- Text nodes must be the string, in double quotes. Newlines aren't + escaped. +- Comments must be "`<`" then "`!-- `" then the data then "` -->`". +- DOCTYPEs must be "``". +- Processing instructions must be "``". (The HTML parser cannot emit + processing instructions, but scripts can, and the WebVTT to DOM + rules can emit them.) +- Template contents are represented by the string "content" with the + children below it. + +The *tag name string* is the local name prefixed by a namespace +designator. For the HTML namespace, the namespace designator is the +empty string, i.e. there's no prefix. For the SVG namespace, the +namespace designator is "svg ". For the MathML namespace, the namespace +designator is "math ". + +The *attribute name string* is the local name prefixed by a namespace +designator. For no namespace, the namespace designator is the empty +string, i.e. there's no prefix. For the XLink namespace, the namespace +designator is "xlink ". For the XML namespace, the namespace designator +is "xml ". For the XMLNS namespace, the namespace designator is "xmlns +". Note the difference between "xlink:href" which is an attribute in no +namespace with the local name "xlink:href" and "xlink href" which is an +attribute in the xlink namespace with the local name "href". + +If there is also a "\#document-fragment" the bit following "\#document" +must be a representation of the HTML fragment serialization for the +context element given by "\#document-fragment". + +For example: + + #data +

One

Two + #errors + 3: Missing document type declaration + #document + | + | + | + |

+ | "One" + |

+ | "Two" diff --git a/tests/phpunit/data/html5lib-tests/tree-construction/adoption01.dat b/tests/phpunit/data/html5lib-tests/tree-construction/adoption01.dat new file mode 100644 index 0000000000000..38f98efded0ae --- /dev/null +++ b/tests/phpunit/data/html5lib-tests/tree-construction/adoption01.dat @@ -0,0 +1,354 @@ +#data +

+#errors +(1,3): expected-doctype-but-got-start-tag +(1,10): adoption-agency-1.3 +#document +| +| +| +| +|

+| + +#data +1

23

+#errors +(1,3): expected-doctype-but-got-start-tag +(1,12): adoption-agency-1.3 +#document +| +| +| +| +| "1" +|

+| +| "2" +| "3" + +#data +1 +#errors +(1,3): expected-doctype-but-got-start-tag +(1,17): adoption-agency-1.3 +#document +| +| +| +| +| "1" +|