Repository navigation
test: gate HTML tree structure a browser would silently repair - #139
Merged
Merged
Conversation
Add scripts/page-structure.test.mjs, a zero-dependency tokenizer/tree gate over every committed HTML page (redirect shortcuts and 404.html included). It parses pages the way the HTML tokenizer does — comments, raw-text script/style/textarea/title bodies, quoted attributes, the spec's optional end tags, foreign content for inline SVG — and reports every repair a browser would make: stray/mismatched/missing end tags, void-element end tags and non-void self-closing, a block inside <p>, duplicate attributes, raw < or > inside attribute values (which truncates the tag every sibling [^>]* gate reads), required-parent violations, interactive content nested in a/button/label, non-metadata content in <head>, and the html/head/body/main skeleton. Each rule has a fixture self-test. Document the gate in README Checks. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com> Signed-off-by: quality <quality@hive.kubestellar.io>
|
[APPROVALNOTIFIER] This PR is NOT APPROVED This pull-request has been approved by: The full list of commands accepted by this bot can be found here. DetailsNeeds approval from an approver in each of these files:Approvers can indicate their approval by writing |
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
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
Test Improvement
Adds
scripts/page-structure.test.mjs, a zero-dependency tokenizer/tree gate over every committed HTML page (redirect shortcuts and404.htmlincluded). The existing gates tokenize tags one at a time with/<tag[^>]*>/and the stub-DOM tests build their own elements, so nothing noticed markup a browser repairs silently. The gate parses each page the way the HTML tokenizer does — comments, raw-text<script>/<style>/<textarea>/<title>bodies, quoted attribute values, the spec's optional end tags (<li>,<dt>/<dd>,<p>,<option>, table parts), foreign content for inline SVG — and reports every repair a browser would make:</br>, self-closing<div/>outside SVG, unclosed comment/<script>;<p>, reported as the stray</p>it leaves behind;</>inside an attribute value — valid HTML, but it truncates the tag that every sibling[^>]*gate reads, so this also hardens those;<li>/<option>/<tr>/<td>/<figcaption>/<summary>/<legend>/<source>/… outside their required parent;<a>/<button>/<label>;<head>;<html>/<head>/<body>, at most one<main>(required on non-redirect pages).Each rule has a fixture self-test. Picked up by the existing
node --test scripts/*.test.mjsstep — no workflow change. README## Checksdocuments the gate (required byci-wiring.test.mjs).Verified locally at
cb88619: full suite 351 → 476 pass;check-links.sh --external-warn,check-links.test.sh,check-redirects.test.sh,check-redirects.shall green. Mutation checks againstindex.html(each restored afterwards): deleting one</section>→line 646: </main> but <section> opened at line 60 is still open; a secondclass=on an<a>→repeats attribute "class";>in the descriptioncontent→contains a raw "<" or ">";<button>inside<a>→nested inside <a>. Every pre-existing gate stays green on all four.Closes #138
Filed by quality agent (ACMM L4/L6 — full mode)
— hive: agent=quality backend=copilot model=claude-fable-5.1 copilot=1.0.88