Closed Bug 2078296 Opened 1 month ago Closed 1 month ago

[wpt-sync] Sync PR 63278 - Sanitizer: place children of replaceWithChildren elements correctly

Categories

(Core :: DOM: Core & HTML, task, P4)

task

Tracking

()

RESOLVED FIXED
160 Branch
Tracking Status
firefox160 --- fixed

People

(Reporter: wpt-sync, Unassigned)

References

()

Details

(Whiteboard: [wptsync downstream])

Attachments

(1 file)

Sync web-platform-tests PR 63278 into mozilla-central (this bug is closed when the sync is complete).

PR: https://github.com/web-platform-tests/wpt/pull/63278
Details from upstream follow.

Noam Rosenthal <nrosenthal@chromium.org> wrote:

Sanitizer: place children of replaceWithChildren elements correctly

When the streaming sanitizer replaces an open element with its children
(replaceWithChildrenElements), nodes parsed under it have to be inserted
where that element would have been, not merely under its parent. This
went wrong in a few cases exercised by setHTML()/setHTMLUnsafe():

  • Foster parenting: an unwrapped element that was itself foster-parented
    (e.g. \<table>\<div>…\</div>\<td>) lost its insertion point, so its
    children ended up after the table instead of before it; and a table
    whose parent is unwrapped foster-parented text into the wrong node.
  • \<template>: a template has no light-tree children, so replacing it
    with its children must drop its contents rather than hoist them into
    the parent. This matches Sanitizer::ReplaceWithChildren for already
    parsed trees and the existing sanitizer-api tree-construction cases
    (whose failing baseline is now removed).
  • A declarative shadow root inside an unwrapped element must not be
    attached on behalf of that element.
  • OwnerDocumentForCurrentNode and the custom element registry lookup now
    resolve through unwrapped elements to the real intended parent.

HTMLStackItem now records the replaced insertion location (parent and
next child) when a foster-parented element is unwrapped, and
HTMLConstructionSite::AdjustInsertionLocation / FindFosterSite /
CreateElement consult it. ShouldInsertChild takes the adjusted location.

New sanitizer-api WPT coverage uses setHTML()/setHTMLUnsafe(). The
streamHTML() counterparts (stream-html-sanitizer.html, plus the scoped
custom element registry case in stream-html-custom-element.html, which
setHTMLUnsafe() cannot exercise yet, see crbug.com/569832084) are
included too, since they are fixed by this same change.

Bug: 569831431, 491743369
Change-Id: I75d3930029c7d68fad8b7dea4c6e4d85f831d628
Reviewed-on: https://chromium-review.googlesource.com/8512657
WPT-Export-Revision: 2f6cb80ce9ce9fc06c9ff0191573a5814da04795

Component: web-platform-tests → DOM: Core & HTML
Product: Testing → Core
Attached file Notable wpt changes —

CI Results

Ran 11 Firefox configurations based on mozilla-central, and Firefox, and Chrome on GitHub CI

Total 70 tests

Status Summary

Firefox

OK : 4[GitHub] 69[Gecko-android-em-14-x86_64-debug-geckoview, Gecko-android-em-14-x86_64-lite-opt-geckoview, Gecko-android-em-14-x86_64-opt-geckoview, Gecko-linux2404-64-debug, Gecko-linux2404-64-opt, Gecko-windows11-32-25h2-debug, Gecko-windows11-32-25h2-opt, Gecko-windows11-64-25h2-debug, Gecko-windows11-64-25h2-opt]
PASS: 1[Gecko-linux2204-64-wayland-debug, Gecko-linux2204-64-wayland-opt] 111[GitHub] 1991[Gecko-android-em-14-x86_64-debug-geckoview, Gecko-android-em-14-x86_64-lite-opt-geckoview, Gecko-android-em-14-x86_64-opt-geckoview, Gecko-linux2404-64-debug, Gecko-linux2404-64-opt, Gecko-windows11-32-25h2-debug, Gecko-windows11-32-25h2-opt, Gecko-windows11-64-25h2-debug, Gecko-windows11-64-25h2-opt]
FAIL: 294[GitHub] 1674[Gecko-android-em-14-x86_64-debug-geckoview, Gecko-android-em-14-x86_64-lite-opt-geckoview, Gecko-android-em-14-x86_64-opt-geckoview, Gecko-linux2404-64-debug, Gecko-linux2404-64-opt, Gecko-windows11-32-25h2-debug, Gecko-windows11-32-25h2-opt, Gecko-windows11-64-25h2-debug, Gecko-windows11-64-25h2-opt]

Chrome

OK : 4
PASS: 349
FAIL: 56

Links

Gecko CI (Treeherder)
GitHub PR Head
GitHub PR Base

Details

(See attachment for full changes)

Status: NEW → RESOLVED
Closed: 1 month ago
Resolution: --- → FIXED
Target Milestone: --- → 160 Branch
You need to log in before you can comment on or make changes to this bug.

Attachment

General

Created:
Updated:
Size: