1
0
Fork 0
firefox/testing/web-platform/tests/dom/nodes/attributes-namednodemap-cross-document.window.js
Daniel Baumann 5e9a113729
Adding upstream version 140.0.
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
2025-06-25 09:37:52 +02:00

31 lines
1.1 KiB
JavaScript

"use strict";
test(() => {
const element = document.createElement("div");
element.setAttribute("x", "first");
const attribute = element.attributes[0];
assert_equals(attribute.ownerDocument, document);
const otherDocument = new Document();
const otherElement = otherDocument.createElement("other");
assert_throws_dom("InUseAttributeError", () => otherElement.attributes.setNamedItem(attribute));
element.removeAttribute("x");
otherElement.attributes.setNamedItem(attribute);
assert_equals(attribute.ownerDocument, otherDocument);
}, "Moving an attribute between documents");
test(() => {
const element = document.createElement("div");
element.setAttribute("x", "first");
const attribute = element.attributes[0];
element.removeAttribute("x");
const otherDocument = new Document();
const otherElement = otherDocument.createElement("other");
otherElement.setAttribute("x", "second");
otherElement.attributes.setNamedItem(attribute);
assert_equals(attribute.ownerDocument, otherDocument);
assert_equals(otherElement.getAttribute("x"), "first");
}, "Replacing an attribute across documents");