Closed Bug 2087385 Opened 1 month ago Closed 18 days ago

[wpt-sync] Sync PR 64228 - Harden Element attribute mutation methods against re-entrant changes

Categories

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

task

Tracking

()

RESOLVED FIXED
162 Branch
Tracking Status
firefox162 --- fixed

People

(Reporter: wpt-sync, Unassigned)

References

()

Details

(Whiteboard: [wptsync downstream])

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

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

Mason Freed <masonf@chromium.org> wrote:

Harden Element attribute mutation methods against re-entrant changes

Element::WillModifyAttribute() can run script both by pausing in the
debugger (via probe::WillModifyDOMAttr) and when UpdateName() lazily
initializes a frame's WindowProxy and synchronously invokes a
page-defined setter (e.g. via chrome.loadTimes). If script mutates the
element's attributes and reallocates or re-indexes
UniqueElementData::attribute_vector_, references and indices into the
attribute storage acquired before WillModifyAttribute() become invalid.

While https://crrev.com/c/8510124 already hardened
SetAttributeInternal() and RemoveAttributeInternal(), this CL:

  1. Checks in AppendAttributeInternal() whether WillModifyAttribute()
    already added the attribute re-entrantly before appending.
  2. Copies id_attr and class_attr by value in DidMoveToNewDocument()
    before calling SetIdAttribute() / setAttribute().
  3. Updates comments in SetAttributeInternal() and
    RemoveAttributeInternal() and adds regression tests.

Bug: 576203565, 575317938
Change-Id: Ic63c0b5a15568a9c8d2331e7b49dde89e36b5283
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/8633017
Auto-Submit: Mason Freed \<masonf@chromium.org>
Commit-Queue: Mason Freed \<masonf@chromium.org>
Reviewed-by: Joey Arhar \<jarhar@chromium.org>
Cr-Commit-Position: refs/heads/main@{#1727352}

Component: web-platform-tests → DOM: Core & HTML
Product: Testing → Core
Whiteboard: [wptsync downstream] → [wptsync downstream error]
Whiteboard: [wptsync downstream error] → [wptsync downstream]
Whiteboard: [wptsync downstream] → [wptsync downstream error]
Whiteboard: [wptsync downstream error] → [wptsync downstream]
Whiteboard: [wptsync downstream] → [wptsync downstream error]
Whiteboard: [wptsync downstream error] → [wptsync downstream]

CI Results

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

Total 1 tests and 4 subtests

Status Summary

Firefox

OK : 1
PASS: 4

Chrome

OK : 1
PASS: 4

Safari

OK : 1
PASS: 4

Links

GitHub PR Head
GitHub PR Base

Whiteboard: [wptsync downstream] → [wptsync downstream error]
Whiteboard: [wptsync downstream error] → [wptsync downstream]

CI Results

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

Total 1 tests and 4 subtests

Status Summary

Firefox

OK : 1
PASS: 4

Chrome

OK : 1
PASS: 4

Safari

OK : 1
PASS: 4

Links

GitHub PR Head
GitHub PR Base

Pushed by wptsync@mozilla.com: https://github.com/mozilla-firefox/firefox/commit/6e76c2e0f718 https://hg.mozilla.org/integration/autoland/rev/f22e359849b8 [wpt PR 64228] - Harden Element attribute mutation methods against re-entrant changes, a=testonly
Status: NEW → RESOLVED
Closed: 18 days ago
Resolution: --- → FIXED
Target Milestone: --- → 162 Branch
You need to log in before you can comment on or make changes to this bug.