-
Notifications
You must be signed in to change notification settings - Fork 3.2k
HTML API: Add test suite from html5lib #5794
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Closed
Closed
Changes from all commits
Commits
Show all changes
70 commits
Select commit
Hold shift + click to select a range
e2468d2
Add test cases from html5lib-tests tree-construction
sirreal 491acc1
Add html5lib test class
sirreal 37ff9f8
Skip unhandled tests
sirreal 70088f1
Avoid WPCS lint nags; skip tests for unsupported input or fragment co…
dmsnell 01dd880
Add line number to test case label
dmsnell 647e086
WPCS Nags
dmsnell 94a6c83
1-index test case numbering
sirreal bf55265
Skip doctype and comments in test dom tree
sirreal dc8ad56
Print nicer tests names
sirreal e5cdeaf
Better tag finding
sirreal b37739a
Remove space from test identifier, easier copy/paste filtering
sirreal 8724ea4
Add skipping of certain tests
sirreal 9d50600
Add files crediting html5lib-tests project
sirreal e80bf95
Fix lint
sirreal 01f4149
Add ignores for formatting elements
sirreal c2d0e1f
Move test data to test data dir
sirreal aff5cd6
Fix expect/actual ordering, add test message
sirreal 493cf5c
Add extra skipped tests
dmsnell 273479f
Avoid running tests that expect anything in <head>
sirreal fd603fa
Use line numbers for test IDs
sirreal e57f7a8
Use padded line number
sirreal 25bd659
Fix HTML input processing
sirreal b647629
Update ignores
sirreal 47dc0f4
Skip incomplete token tests
sirreal 0fbcfd1
Mark unsupported markup tests as incomplete, not skipped
sirreal 9d5b180
Fix lints
sirreal 5907bc7
Fix strlen paren bug
sirreal 5e399f2
Fix some comments
sirreal 867f109
Skip head tests
sirreal 659eebd
Fix lint
sirreal 544a4a6
Add attributes to html5lib tests
sirreal 825c97f
Clean up and refactor test document parsing
sirreal 9fd69f3
Fixing more lints
sirreal 8ece64b
Rename class and test function
sirreal f49bbf3
Add skip for known bug - all tests passing or skipped
sirreal 6b6c3dc
Ignore another P tag test
sirreal 08d51e6
Use DIR_TESTDATA
sirreal a251cd8
Update covers
sirreal 40da3e8
Add todo comments
sirreal 252e37a
Remove covers
sirreal 07fa7ad
Remove comment test skip
sirreal 672bb47
Add much more HTML to tests
sirreal 89aed66
Skip entities tests
sirreal 8d4cb2a
Better variable name
sirreal 3dce944
Skip all entities for now
sirreal 1d113a7
Update skips
sirreal 4148612
Remove leading class body space
sirreal 7598fb7
Fix void tag indenting
sirreal 286803b
Replace $p with $processor
sirreal a51363c
Expand README and add update instructions
sirreal 1878f93
Add description to test class
sirreal 8a45383
fix some test skipping
sirreal bec7014
Handle CDATA lookalike comment types
sirreal 33f6a4b
Throw on unhandled token types
sirreal 035f0ee
Skip whitespace test
sirreal f892705
Fix lint
sirreal 168bba6
var_export our token type
sirreal 429e933
Rename tree representation method, make private
sirreal dd0d56d
Skip tests with known issues
sirreal f0bcccd
Add ticket to dataProvider
sirreal 084def5
Use assertSame over assertEquals
sirreal 49c80f4
Extract should_skip_test function
sirreal 09ce469
Rename result variable to expected_tree
sirreal cc1ed71
Mark unsupported tests as skipped
sirreal d73836e
Add and exclude html-api-html5lib-tests group
sirreal 209af9a
Also exclude html5lib tests from multisite
sirreal b23ecda
Update since annotation
sirreal 9717fff
Abort when error at end of token loop
sirreal c64034e
Explicitly mark test files as text, despite the .dat file extension.
dmsnell bbe7c21
Merge branch 'trunk' into add-html5lib-tests
dmsnell File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1 @@ | ||
| *.dat -text diff |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -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 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -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. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,25 @@ | ||
| # html5lib-tests | ||
|
|
||
| This directory contains a third-party test suite used for testing the WordPress HTML API. | ||
|
|
||
| `html5lib-tests` can be found on GitHub at [html5lib/html5lib-tests](https://github.com/html5lib/html5lib-tests). | ||
|
|
||
| The necessary files have been copied to this directory: | ||
|
|
||
| - `AUTHORS.rst` | ||
| - `LICENSE` | ||
| - `README.md` | ||
| - `tree-construction/README.md` | ||
| - `tree-construction/*.dat` | ||
|
|
||
| The version of these files was taken from the git commit with | ||
| SHA [`a9f44960a9fedf265093d22b2aa3c7ca123727b9`](https://github.com/html5lib/html5lib-tests/commit/a9f44960a9fedf265093d22b2aa3c7ca123727b9). | ||
|
|
||
| ## Updating | ||
|
|
||
| If there have been changes to the html5lib-tests repository, this test suite can be updated. In | ||
| order to update: | ||
|
|
||
| 1. Check out the latest version of git repository mentioned above. | ||
| 1. Copy the files listed above into this directory. | ||
| 1. Update the SHA mentioned in this README file with the new html5lib-tests SHA. |
108 changes: 108 additions & 0 deletions
108
tests/phpunit/data/html5lib-tests/tree-construction/README.md
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -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 "`<!DOCTYPE `" then the name then if either of the | ||
| system id or public id is non-empty a space, public id in | ||
| double-quotes, another space an the system id in double-quotes, and | ||
| then in any case "`>`". | ||
| - Processing instructions must be "`<?`", then the target, then a | ||
| space, then the data and then "`>`". (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 | ||
| <p>One<p>Two | ||
| #errors | ||
| 3: Missing document type declaration | ||
| #document | ||
| | <html> | ||
| | <head> | ||
| | <body> | ||
| | <p> | ||
| | "One" | ||
| | <p> | ||
| | "Two" |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.