</>

HTML Viewer - Test Validation Suite

Automated verification for Auto-Fix, Code Splitting, HTML Validation, and Tab Merging

Total Test Cases 45 Across 7 specialized suites
Tests Passed 45 100% assertions green
Tests Failed 0 0 regressions detected
Execution Time ~15ms Zero-dependency native speed

⚡ Live Auto-Fix & Split Sandbox

Inspect complex real-world examples in real time with step-by-step transformations

HTML Editor Tab HTML

        
CSS Editor Tab CSS

        
JS Editor Tab JS

        
Validation & Pipeline Diagnostics STATUS

        

📐 Recommended Testing Strategy for Validation & Auto-Fix Split

Building reliable client-side HTML parsers, splitters, and auto-fixers requires avoiding common traps (like regex over-matching inside strings, destroying structured data, or dropping text content). Below is the recommended multi-layered strategy for robust long-term test coverage:

1. Tag & Lexer Boundary Testing

Verify that void tags (<img>, <input>, <br>) are never flagged as unclosed, while illegal void closing tags (</img>, </input>) are detected and cleaned without touching neighboring tags.

2. Content Masking & Context Isolation

Ensure that anything inside <script> or <style> (such as template strings containing tags or comparison operators like a < b) is masked so it never causes false positive tag mismatch errors.

3. Selective Code Splitting Filters

Test that only executable JavaScript (no-type or type="module") is extracted to the JS tab. External scripts (src="...") and data scripts (type="application/ld+json") must remain in the HTML tab.

4. Idempotency & Fixed-Point Verification

Every auto-fixing operation must be idempotent: fix(fix(code)) === fix(code). The second pass must always produce zero additional changes, preventing infinite oscillation loops.

5. Reversible Round-Trip Integrity

Verify the complete lifecycle: Split(HTML) → [HTML, CSS, JS] → Merge([HTML, CSS, JS]) → Final HTML. The final document must render identically and validate with 0 errors.

6. Non-Destructive Invariants

Verify that text nodes, custom data attributes (data-*), accessibility labels (aria-*), and external CDN resources are never dropped, stripped, or altered during repair or splitting.

') !== -1; }}, { name: "Merges into fragment without head/body tags safely", run: function() { var res = t.mergeHTMLCode('
Hi
', '.box { color: red; }', 'alert(1);'); return res.indexOf('') !== -1 && res.indexOf('') !== -1; }}, { name: "Round-trip split -> merge preserves document integrity & validity", run: function() { var original = '
T