← Back to index

DOM-based test cases — insertAdjacentHTML

High: 0 Medium: 0 Low: 0 Safe: 0 Total: 0

Use these fixtures to exercise DOM sinks that rely on insertAdjacentHTML. Inline cases run automatically; external ones are opt-in.

Use query payload

Inline scenarios

INLINE-1 (High): Query / hash → insertAdjacentHTML
// inline-script[#1]
(function(){
  const target = 'inline-insertadjacent-target';
  function render(payload) {
    insertAdjacentHtmlSink(payload, target);
  }
  const params = new URLSearchParams(location.search);
  if (params.has('payload')) render(params.get('payload'));
  if (location.hash) {
    try { render(decodeURIComponent(location.hash.slice(1))); }
    catch (err) { render(location.hash.slice(1)); }
  }
})();
  • Waiting for payload…
INLINE-2 (High): Field value → insertAdjacentHTML
// inline-script[#2]
function inlineInsertAdjacentFromField(fieldId, targetId) {
  const el = document.getElementById(fieldId);
  if (!el) return;
  insertAdjacentHtmlSink(el.value, targetId);
}
INLINE-3 (Safe): Encode before inserting
// inline-script[#3]
(function(){
  const params = new URLSearchParams(location.search);
  const safe = params.get('safe');
  const target = document.getElementById('inline-safe-target');
  if (!target || !safe) return;
  target.textContent = safe;
})();
Waiting for safe payload…

External scenarios (click to run)

Direct DOM sources
onclick="extInsertAdjacentFromHash()"
onclick="extInsertAdjacentFromSearch()"
onclick="extInsertAdjacentFromWindowName()"
onclick="extInsertAdjacentFromReferrer()"
  • External DOM source target
Storage & cookies
onclick="extInsertAdjacentFromCookie()"
onclick="extInsertAdjacentFromLocalStorage()"
onclick="extInsertAdjacentFromSessionStorage()"
  • External storage target