haikuwebkit/LayoutTests/fast/dom/set-outer-html-special-case...

28 lines
1.1 KiB
HTML
Raw Permalink Normal View History

Relax "parent must be an HTMLElement" restriction in outerHTML setter https://bugs.webkit.org/show_bug.cgi?id=226808 Reviewed by Ryosuke Niwa. Source/WebCore: Made the following change to our outerHTML setter for better compatibility and to better match the specification [1]: - Stop throwing an exception when the parent is not an HTML element. This new behavior matches the specification, Blink and Gecko behavior. I did not fully align us with the specification because we are mostly aligned with Blink at the moment. In particular: - The specification says the outerHTML setter should be a no-op when the parent is null. Firefox matches the specification but WebKit & Blink throw a NoModificationAllowedError. - The specification says we should allow setting outerHTML if the parent is a DocumentFragment. Firefox allows this but WebKit & Blink throw a NoModificationAllowedError. - WebKit & Blink have some Text node merging logic that is not present in the specification and which Gecko doesn't implement. [1] https://w3c.github.io/DOM-Parsing/#dom-element-outerhtml Test: fast/dom/set-outer-html-special-cases.html * dom/Element.cpp: (WebCore::Element::setOuterHTML): LayoutTests: * fast/dom/set-outer-html-special-cases-expected.txt: Added. * fast/dom/set-outer-html-special-cases.html: Added. Add layout test coverage * fast/dynamic/outerHTML-no-element-expected.txt: Rebaseline test due to different exception message. * platform/mac-wk1/imported/w3c/web-platform-tests/mathml/relations/css-styling/padding-border-margin/margin-003-expected.txt: * platform/mac-wk2/imported/w3c/web-platform-tests/mathml/relations/css-styling/padding-border-margin/margin-003-expected.txt: Rebaseline WPT test. This is actually a progression because we're no longer throwing. However, the test is still failing later on. Canonical link: https://commits.webkit.org/238774@main git-svn-id: https://svn.webkit.org/repository/webkit/trunk@278821 268f45cc-cd09-0410-ab3c-d52691b4dbfc
2021-06-13 19:16:48 +00:00
<html>
<head>
<script src="../../resources/js-test.js"></script>
<script>
description("Tests some special cases of the outerHTML setter.");
function runTest()
{
// Parent does not need to be a HTML element.
document.getElementById('testSVG').outerHTML = '<g></g>';
shouldBeEqualToString("document.getElementById('svgElement').innerHTML", "<g></g>");
// We should throw a NoModificationAllowedError if the parent is a Document.
shouldThrowErrorName("document.documentElement.outerHTML = ''", "NoModificationAllowedError");
// We currently throw an exception when the parent is null, as does Blink. Gecko and the specification
// say this should be a no-op though.
a = document.createElement("a");
shouldBe("a.parentNode", "null");
shouldThrowErrorName("a.outerHTML = ''", "NoModificationAllowedError");
}
</script>
</head>
<body onload="runTest()">
<svg xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" id="svgElement"><symbol id="testSVG"></symbol></svg>
</body>
</html>