Skip to content

parser: test gaps in the class-attribute truncation tests (pin 20,000, real second throw, RangeError-only retry, dead loop) #1571

Closed

Description

@nc9

Found in the independent review of #1558 (the fix for the class-attribute parse crash, #1557). The new tests leave gaps that 11 of 30 mutants exploit.

Surviving mutants

  • MAX_CLASS_TOKENS 20,000 to 25,000: the tests compare against the constant, so the documented limit is not pinned.
  • Only the first class attribute per tag cut.
  • The six non-script text elements removed from the raw-text skip (title, xmp, plaintext, noembed, noframes, iframe).
  • Retry on any error instead of RangeError only.
  • A second throw propagating instead of falling back to the empty document: the "retry that throws again" test passes a non-string, so it never reaches that path.
  • Whitespace handled as only space, and as JavaScript \s.
  • <SCRIPT> closer case.
  • Unterminated quote handling.
  • Retry even when nothing was cut.
  • Comment search offset open+4 to open+3.

Also the test "single quotes, no quotes, upper case..." hits if (tag.includes(" ")) continue; for all three of its tags, so its assertions never run.

Acceptance Criteria

  • The 20,000 limit is pinned as a literal in the tests (19,999, 20,000 and 20,001 tokens).
  • A real second throw (a page that still overflows after the cut, built without relying on a non-string input) reaches the empty-document fallback, with a test asserting the empty document and the notice.
  • A test shows only a RangeError triggers the retry (another error type is not retried).
  • The dead loop in "single quotes, no quotes, upper case..." asserts for each of its tags.
  • Tests kill the surviving mutants above (or each equivalent one is documented as such).

nik

Activity

  1. added
    size: S
    rules
    on Nov 2, 2026
  2. added theissue type on Nov 2, 2026
  3. nc9 commented on Nov 4, 2026

    @nc9
    ContributorAuthor

    Acceptance check against v0.0.162 (7c31d5b). The tests shipped in v0.0.161: b576fa9 (the cut was rewritten on the tokenizer, so the hand-written reader these mutants targeted no longer exists) and 84b1871 (injected parse function in place of module mocking).

    # Criterion Result Evidence
    1 The 20,000 limit pinned as a literal (19,999, 20,000, 20,001) PASS huge-class-1557.test.ts "19,999 and 20,000 tokens are kept whole, 20,001 is cut to 20,000" with LIMIT_20K = 20_000, plus expect(MAX_CLASS_TOKENS).toBe(20_000).
    2 A second throw reaches the empty-document fallback, asserted with the document and the notice, without a non-string input PASS (with a note) parse-contained-1557.test.ts "a retry that throws again falls back to the empty document, with a notice": the parse function is injected, the page and the cut page throw, and the test asserts 3 calls, an empty document and the "audited empty" notice. It is a stub, not a page that overflows twice; after the cut a class can no longer exceed 20,000 tokens, so I found no page that does.
    3 Only a RangeError triggers the retry PASS "an error that is not a RangeError is not retried: the empty document, with its message" (2 calls).
    4 The dead loop asserts for each of its tags PASS "each of single quotes, no quotes and upper case is asserted" builds an expected list for the three tags and compares each.
    5 Tests kill the surviving mutants (or document equivalents) PASS I applied mutants to dom.ts on the tag and ran the test files; each one fails a named test: limit 25,000 (2 fail in huge-class-1557), retry on any error, retry when nothing was cut, a second throw propagating (1 fail each in parse-contained-1557), whitespace as space only (tabs, newlines, form feeds case), whitespace as JavaScript \s (NBSP and U+2003/U+FEFF/VT cases), every class per tag instead of the first (3 fail: duplicate-class cases), entity start unread (6 fail). The raw-text element skip, <SCRIPT> closer, unterminated quote and comment-offset mutants target the removed hand-written reader; the replacement is tested by the same shapes as table cases in class-cut-differential.test.ts ("title after an abrupt comment holds text", "SCRIPT in capitals closes on </script>", "an unterminated quote at the end of the page").

    Ran: huge-class-1557.test.ts (12 pass), parse-contained-1557.test.ts (6), class-cut-differential.test.ts (63).

    Ticked 1 to 5 and closing.

    nik

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    rulessize: S

    Type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions