Sample
@xmldom/xmldom 0.8.14: DOMException
Verified sample for npm @xmldom/xmldom 0.8.14: DOMException. The contract ran on node 22 · linux debian/x64 · docker and passed.
sha256:bd914768c1f5593678fad0c5f697b185e52a6ef4b1130ec5faa7cb70714d5f24
This network offers one thing: a sample that builds. It ran the sample in a sandbox and kept the signed receipt. It grades nothing and warrants nothing — whether the same code builds where you are is not something it measured.
How many distinct signing keys filed a passing contract receipt. One is the author alone; more than one means somebody else built it too. A key is self-generated with nothing registered behind it, so it counts keys, not people.
MIT-0
Execution evidence
The declared environment and the signed runs are kept apart, so you can see exactly what this sample ran and where.
- Evidence basis
- Signed contract pass
- Verification receipts
- 1
- Signing keys that built it
- 1
Declared environment
node 22.23 linux 24 · ubuntu · glibc 2.39 x64 node 22.23 javascript npm 10
Verification-run environments
| Environment | Contract | Stages | Run |
|---|---|---|---|
| node 22 · linux debian/x64 · docker ed25519:c1973797be207ac4 | PASS | compile:SKIPPED · contract:PASS · load:PASS · resolve:PASS CONTAINER_RUN · node-typescript@1node:22@sha256:8a34c4ab3ea2… |
2026-09-01 |
Case
HOW- Goal
- verify @xmldom/xmldom.DOMException in pkg:npm/%40xmldom/xmldom@0.8.14
- Packages
- Symbols
-
- @xmldom/xmldom.DOMException
- Environment
- node 22.23.2
- Created
- 2026-09-01T11:05:48Z
Contract
- @xmldom/xmldom.DOMException defines standard DOM error code constants including INDEX_SIZE_ERR, HIERARCHY_REQUEST_ERR, INVALID_CHARACTER_ERR, NOT_FOUND_ERR, INUSE_ATTRIBUTE_ERR, and INVALID_STATE_ERR
- @xmldom/xmldom.DOMException instances can be constructed with numeric error codes and descriptive messages
- @xmldom/xmldom.DOMException is thrown with HIERARCHY_REQUEST_ERR when invalid DOM hierarchy insertions are attempted
- @xmldom/xmldom.DOMException is thrown with NOT_FOUND_ERR and INUSE_ATTRIBUTE_ERR during invalid DOM attribute operations
- @xmldom/xmldom.DOMException is thrown with INVALID_CHARACTER_ERR and INVALID_STATE_ERR during invalid CDATA creation and strict XML serialization
Files
- PROMPT.md
- csx.json
- index.js
- package-lock.json
- package.json
- spec.json
- test/contract.cjs
Source
Clean-room public code sample — generation instructions
Write a brand-new, minimal, self-contained code sample in this clean-room directory.
Do not copy, paraphrase, or reference any existing project source. Work only from this spec.
A csx.json manifest scaffold already exists. Do not recreate it from memory. Preserve its case.goal, packages and symbols; fill its empty case.contract with exact assertions and correct its environment, commands and verifierAdapter for the files you generate.
Goal: verify @xmldom/xmldom.DOMException in pkg:npm/%40xmldom/xmldom@0.8.14
Kind: HOW
Use EXACTLY these public packages and versions:
- pkg:npm/%40xmldom/xmldom@0.8.14
Demonstrate these symbols/APIs:
- @xmldom/xmldom.DOMException
Rules:
- One focused purpose; the smallest project that proves the goal.
- Include a contract test (test/contract.*) that runs OFFLINE and exits 0 exactly when the goal behavior works.
- Pin every dependency with a lockfile so resolution is reproducible.
- No secrets, credentials, or tokens. No real URLs (only example.com or localhost). No absolute paths.
- No personal names, emails, company names, or project identifiers of any kind.
- No binaries and no generated output (node_modules, dist, target, venv, .git, .env).
- Keep it under 200 files and 256KB packed.
{"case":{"caseId":"case:sha256:8b384a477f973ddc444a50b24b9194a410014736dd110070eecec263bb9ee703","contract":["@xmldom/xmldom.DOMException defines standard DOM error code constants including INDEX_SIZE_ERR, HIERARCHY_REQUEST_ERR, INVALID_CHARACTER_ERR, NOT_FOUND_ERR, INUSE_ATTRIBUTE_ERR, and INVALID_STATE_ERR","@xmldom/xmldom.DOMException instances can be constructed with numeric error codes and descriptive messages","@xmldom/xmldom.DOMException is thrown with HIERARCHY_REQUEST_ERR when invalid DOM hierarchy insertions are attempted","@xmldom/xmldom.DOMException is thrown with NOT_FOUND_ERR and INUSE_ATTRIBUTE_ERR during invalid DOM attribute operations","@xmldom/xmldom.DOMException is thrown with INVALID_CHARACTER_ERR and INVALID_STATE_ERR during invalid CDATA creation and strict XML serialization"],"goal":"verify @xmldom/xmldom.DOMException in pkg:npm/%40xmldom/xmldom@0.8.14","kind":"HOW","packages":["pkg:npm/%40xmldom/xmldom@0.8.14"],"schemaVersion":1,"symbols":["@xmldom/xmldom.DOMException"]},"contractCommand":["node","test/contract.cjs"],"environment":{"arch":"x64","distro":"ubuntu","ecosystem":"npm","executionContext":"node","language":"javascript","libc":"glibc","libcVersion":"2.39","moduleSystem":"cjs","os":"linux","osVersionBucket":"24","packageManager":"npm","packageManagerVersion":"10.9.8","runtime":"node","runtimeVersion":"22.23.2","schemaVersion":1},"license":"MIT-0","packages":["pkg:npm/%40xmldom/xmldom@0.8.14"],"schemaVersion":1,"subject":"pkg:npm/%40xmldom/xmldom@0.8.14","symbols":["@xmldom/xmldom.DOMException"],"verifierAdapter":"node-typescript@1"}
'use strict';
const { DOMException } = require('@xmldom/xmldom/lib/dom');
/**
* Creates a DOMException instance with a given code and message.
* @param {number} code - DOM Exception numeric code (e.g. DOMException.INDEX_SIZE_ERR)
* @param {string|Error} [message] - Optional descriptive message or cause
* @returns {DOMException}
*/
function createDOMException(code, message) {
return new DOMException(code, message);
}
/**
* Checks if an error is a DOMException with an optional code check.
* @param {*} err
* @param {number} [code]
* @returns {boolean}
*/
function isDOMException(err, code) {
if (!err || !(err instanceof Error)) {
return false;
}
if (typeof err.code !== 'number') {
return false;
}
if (code !== undefined) {
return err.code === code;
}
return true;
}
module.exports = {
DOMException,
createDOMException,
isDOMException
};
{
"name": "sample-xmldom-domexception",
"version": "1.0.0",
"lockfileVersion": 3,
"requires": true,
"packages": {
"": {
"name": "sample-xmldom-domexception",
"version": "1.0.0",
"license": "MIT-0",
"dependencies": {
"@xmldom/xmldom": "0.8.14"
}
},
"node_modules/@xmldom/xmldom": {
"version": "0.8.14",
"resolved": "https://registry.npmjs.org/@xmldom/xmldom/-/xmldom-0.8.14.tgz",
"integrity": "sha512-T4EDRUBVZYRldYApjEJiU0e1stYWaRAX7CuSnKzrpwdZKo53zGV8/pqfzV6FfwNl9YThD2OumQYvqtvjvgG7aQ==",
"deprecated": "this version has critical issues, please update to the latest version",
"license": "MIT",
"engines": {
"node": ">=10.0.0"
}
}
}
}
{
"name": "sample-xmldom-domexception",
"version": "1.0.0",
"private": true,
"description": "verify @xmldom/xmldom.DOMException in pkg:npm/%40xmldom/xmldom@0.8.14",
"main": "index.js",
"scripts": {
"test": "node test/contract.cjs"
},
"dependencies": {
"@xmldom/xmldom": "0.8.14"
},
"license": "MIT-0"
}
{
"schemaVersion": 1,
"goal": "verify @xmldom/xmldom.DOMException in pkg:npm/%40xmldom/xmldom@0.8.14",
"kind": "HOW",
"packages": [
"pkg:npm/%40xmldom/xmldom@0.8.14"
],
"symbols": [
"@xmldom/xmldom.DOMException"
]
}
'use strict';
const assert = require('assert');
const { DOMParser, XMLSerializer } = require('@xmldom/xmldom');
const { DOMException } = require('@xmldom/xmldom/lib/dom');
const { createDOMException, isDOMException } = require('../index.js');
function run() {
// 1. Verify standard DOMException constants and numeric codes
assert.strictEqual(typeof DOMException, 'function', 'DOMException should be a constructor function');
assert.strictEqual(DOMException.INDEX_SIZE_ERR, 1, 'INDEX_SIZE_ERR should be 1');
assert.strictEqual(DOMException.DOMSTRING_SIZE_ERR, 2, 'DOMSTRING_SIZE_ERR should be 2');
assert.strictEqual(DOMException.HIERARCHY_REQUEST_ERR, 3, 'HIERARCHY_REQUEST_ERR should be 3');
assert.strictEqual(DOMException.WRONG_DOCUMENT_ERR, 4, 'WRONG_DOCUMENT_ERR should be 4');
assert.strictEqual(DOMException.INVALID_CHARACTER_ERR, 5, 'INVALID_CHARACTER_ERR should be 5');
assert.strictEqual(DOMException.NO_DATA_ALLOWED_ERR, 6, 'NO_DATA_ALLOWED_ERR should be 6');
assert.strictEqual(DOMException.NO_MODIFICATION_ALLOWED_ERR, 7, 'NO_MODIFICATION_ALLOWED_ERR should be 7');
assert.strictEqual(DOMException.NOT_FOUND_ERR, 8, 'NOT_FOUND_ERR should be 8');
assert.strictEqual(DOMException.NOT_SUPPORTED_ERR, 9, 'NOT_SUPPORTED_ERR should be 9');
assert.strictEqual(DOMException.INUSE_ATTRIBUTE_ERR, 10, 'INUSE_ATTRIBUTE_ERR should be 10');
assert.strictEqual(DOMException.INVALID_STATE_ERR, 11, 'INVALID_STATE_ERR should be 11');
assert.strictEqual(DOMException.SYNTAX_ERR, 12, 'SYNTAX_ERR should be 12');
assert.strictEqual(DOMException.INVALID_MODIFICATION_ERR, 13, 'INVALID_MODIFICATION_ERR should be 13');
assert.strictEqual(DOMException.NAMESPACE_ERR, 14, 'NAMESPACE_ERR should be 14');
assert.strictEqual(DOMException.INVALID_ACCESS_ERR, 15, 'INVALID_ACCESS_ERR should be 15');
// 2. Direct instantiation and helper verification
const ex = new DOMException(DOMException.INDEX_SIZE_ERR, 'index out of bounds');
assert(ex instanceof Error, 'DOMException instance should inherit from Error');
assert.strictEqual(ex.code, DOMException.INDEX_SIZE_ERR, 'Exception code should match INDEX_SIZE_ERR');
assert(ex.message.includes('Index size error'), 'Exception message should contain standard message prefix');
assert(ex.message.includes('index out of bounds'), 'Exception message should contain custom detail');
const helperEx = createDOMException(DOMException.NOT_FOUND_ERR, 'item not located');
assert(isDOMException(helperEx), 'Helper isDOMException should return true for DOMException');
assert(isDOMException(helperEx, DOMException.NOT_FOUND_ERR), 'isDOMException should verify exact code');
assert(!isDOMException(helperEx, DOMException.SYNTAX_ERR), 'isDOMException should reject mismatched code');
assert(!isDOMException(new Error('plain error')), 'isDOMException should return false for plain error without code');
// 3. Verify HIERARCHY_REQUEST_ERR thrown by invalid DOM hierarchy insertion
const doc = new DOMParser().parseFromString('<root id="r1"><child id="c1"/></root>', 'text/xml');
const secondRoot = doc.createElement('secondRoot');
let hierarchyThrown = false;
try {
doc.appendChild(secondRoot);
} catch (err) {
hierarchyThrown = true;
assert(isDOMException(err, DOMException.HIERARCHY_REQUEST_ERR), 'doc.appendChild multiple root elements should throw HIERARCHY_REQUEST_ERR');
assert(err.message.includes('Hierarchy request error'), 'Message should indicate hierarchy request error');
}
assert(hierarchyThrown, 'Hierarchy violation must throw');
// 4. Verify NOT_FOUND_ERR and INUSE_ATTRIBUTE_ERR on DOM attribute operations
const root = doc.documentElement;
const child = root.firstChild;
const unattachedAttr = doc.createAttribute('orphan');
let notFoundThrown = false;
try {
root.removeAttributeNode(unattachedAttr);
} catch (err) {
notFoundThrown = true;
assert(isDOMException(err, DOMException.NOT_FOUND_ERR), 'removeAttributeNode with unattached attr should throw NOT_FOUND_ERR');
}
assert(notFoundThrown, 'removeAttributeNode on unattached attribute must throw');
const rootIdAttr = root.getAttributeNode('id');
assert(rootIdAttr, 'Root element should have id attribute node');
let inUseThrown = false;
try {
child.setAttributeNode(rootIdAttr);
} catch (err) {
inUseThrown = true;
assert(isDOMException(err, DOMException.INUSE_ATTRIBUTE_ERR), 'setAttributeNode with already attached attr should throw INUSE_ATTRIBUTE_ERR');
}
assert(inUseThrown, 'setAttributeNode on attached attribute must throw');
// 5. Verify INVALID_CHARACTER_ERR on CDATA and INVALID_STATE_ERR on XMLSerializer
let cdataThrown = false;
try {
doc.createCDATASection('data containing ]]> sequence');
} catch (err) {
cdataThrown = true;
assert(isDOMException(err, DOMException.INVALID_CHARACTER_ERR), 'createCDATASection with ]]> should throw INVALID_CHARACTER_ERR');
}
assert(cdataThrown, 'createCDATASection with illegal sequence must throw');
const serializer = new XMLSerializer();
const commentDoc = new DOMParser().parseFromString('<root/>', 'text/xml');
const invalidComment = commentDoc.createComment('invalid --> comment');
commentDoc.documentElement.appendChild(invalidComment);
let serializeThrown = false;
try {
serializer.serializeToString(commentDoc, false, null, { requireWellFormed: true });
} catch (err) {
serializeThrown = true;
assert(isDOMException(err, DOMException.INVALID_STATE_ERR), 'serializeToString with requireWellFormed on invalid comment should throw INVALID_STATE_ERR');
}
assert(serializeThrown, 'serializeToString on ill-formed content with requireWellFormed must throw');
console.log('Contract tests passed successfully.');
}
try {
run();
process.exit(0);
} catch (err) {
console.error('Contract test failed:', err);
process.exit(1);
}
Origin Seeder
anonymous