Skip to content

test: gate HTML tree structure a browser would silently repair - #139

Merged
hivecommons-hive[bot] merged 1 commit into
mainfrom
quality/test-page-structure
Oct 8, 2026
Merged

hivecommons-hive[bot] merged 1 commit into
mainfrom
quality/test-page-structure

Conversation

@hivecommons-hive

Copy link
Copy Markdown
Contributor

Test Improvement

Adds scripts/page-structure.test.mjs, a zero-dependency tokenizer/tree gate over every committed HTML page (redirect shortcuts and 404.html included). 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:

  • stray, mismatched or missing end tags (with both line numbers), </br>, self-closing <div/> outside SVG, unclosed comment/<script>;
  • a block element inside <p>, reported as the stray </p> it leaves behind;
  • the same attribute twice on one element (second is dropped);
  • a raw </> 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;
  • interactive content nested in <a>/<button>/<label>;
  • non-metadata content in <head>;
  • exactly one <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.mjs step — no workflow change. README ## Checks documents the gate (required by ci-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.sh all green. Mutation checks against index.html (each restored afterwards): deleting one </section> → line 646: </main> but <section> opened at line 60 is still open; a second class= on an <a> → repeats attribute "class"; > in the description content → 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

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>
@kubestellar-prow

Copy link
Copy Markdown

[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.

Details Needs approval from an approver in each of these files:

Approvers can indicate their approval by writing /approve in a comment
Approvers can cancel approval by writing /approve cancel in a comment

@hivecommons-hive
hivecommons-hive Bot merged commit d0ebaac into main Oct 8, 2026
6 of 7 checks passed
@kubestellar-prow
kubestellar-prow Bot deleted the quality/test-page-structure branch October 8, 2026 01:42
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[quality] gate HTML tree structure: tag balance, duplicate attributes, nesting a browser would silently repair

0 participants