chromium/third_party/blink/web_tests/external/wpt/html/browsers/the-window-object/named-access-on-the-window-object/doc-no-window.html

<!DOCTYPE html>
<meta charset="utf-8">
<title>Named access on the window object - Document without window</title>
<link rel="author" title="Matthew Phillips" href="mailto:[email protected]">
<link rel="help" href="https://html.spec.whatwg.org/#named-access-on-the-window-object">
<script src="/resources/testharness.js"></script>
<script src="/resources/testharnessreport.js"></script>

<body>
<script>
"use strict";

test(() => {
  const doc = document.implementation.createHTMLDocument();
  // Sanity check
  assert_equals(doc.defaultView, null);

  const img = doc.createElement("img");
  img.setAttribute("id", "foo");
  doc.body.appendChild(img);
  assert_true(Boolean(img.parentNode));

  img.setAttribute("id", "bar");
  assert_equals(img.getAttribute("id"), "bar");

  doc.body.removeChild(img);
  assert_false(Boolean(img.parentNode));
}, "A document without a Window must not cause errors");
</script>