diff --git a/testing/web-platform/tests/html/dom/elements/global-attributes/dir-assorted.window.js b/testing/web-platform/tests/html/dom/elements/global-attributes/dir-assorted.window.js index a4b30f0e4ac7..d65cba7421cb 100644 --- a/testing/web-platform/tests/html/dom/elements/global-attributes/dir-assorted.window.js +++ b/testing/web-platform/tests/html/dom/elements/global-attributes/dir-assorted.window.js @@ -18,6 +18,8 @@ test(() => { const ele2 = document.createElement("foobar"); ele.append(ele2); assert_true(ele2.matches(":dir(rtl)")); + ele.dir = "ltr"; + assert_true(ele2.matches(":dir(ltr)"), "direction after dynamic change"); }, "Element without direction has parent element direction"); test(() => { @@ -26,6 +28,8 @@ test(() => { const ele2 = document.createElementNS("foobar", "foobar"); ele.append(ele2); assert_true(ele2.matches(":dir(rtl)")); + ele.dir = "ltr"; + assert_true(ele2.matches(":dir(ltr)"), "direction after dynamic change"); }, "Non-HTML element without direction has parent element direction"); test(() => { @@ -45,3 +49,17 @@ test(() => { container1.remove(); }, "dir inheritance is correct after insertion and removal from document"); + +test(() => { + const ele = document.createElement("foobar"); + ele.dir = "auto"; + const ele2 = document.createElementNS("foobar", "foobar"); + ele.append(ele2); + const text = document.createTextNode("\u05D0\u05D1\u05D2"); + ele2.append(text); + assert_true(ele.matches(":dir(rtl)"), "is RTL before change"); + assert_true(ele2.matches(":dir(rtl)"), "child is RTL before change"); + text.data = "ABC"; + assert_true(ele.matches(":dir(ltr)"), "is LTR after change"); + assert_true(ele2.matches(":dir(ltr)"), "child is LTR after change"); +}, "Non-HTML element text contents influence dir=auto"); diff --git a/testing/web-platform/tests/html/dom/elements/global-attributes/dir-auto-dynamic-changes.window.js b/testing/web-platform/tests/html/dom/elements/global-attributes/dir-auto-dynamic-changes.window.js index 5df996d285f4..a0cf4aae7bad 100644 --- a/testing/web-platform/tests/html/dom/elements/global-attributes/dir-auto-dynamic-changes.window.js +++ b/testing/web-platform/tests/html/dom/elements/global-attributes/dir-auto-dynamic-changes.window.js @@ -134,6 +134,8 @@ test(() => { text.innerText = "\u05D0"; assert_false(tree.matches(":dir(ltr)"), "node tree ancestor before fifth text change"); assert_false(slot.matches(":dir(ltr)"), "slot before fifth text change"); + + tree.remove(); }, "text changes affecting both slot and ancestor with dir=auto"); test(() => { @@ -166,4 +168,109 @@ test(() => { assert_true(tree.matches(":dir(ltr)"), "after change 7"); aleph1.dir = "invalid"; assert_false(tree.matches(":dir(ltr)"), "after change 8"); + + tree.remove(); }, "dynamic changes to subtrees excluded as a result of the dir attribute"); + +test(() => { + let tree = setup_tree(` +