Bug 1696981 [wpt PR 27892] - [Element Reflection] explicitly set attr-element should not prevent GC., a=testonly

Automatic update from web-platform-tests
[Element Reflection] explicitly set attr-element should not prevent GC.

An explicitly set attr-element is an internal reference from one element
to other element(s). This internal reference is then only exposed if
that reference relationship is considered valid, otherwise the accessors
will "lie" and pretend that the underlying reference is not set by
returning appropriate default values.

A relationship can only be valid if the referenced element is inserted
into the DOM, in which case the reference from its DOM parent will keep
it alive.

If a referenced element is not inserted into the DOM, the only way it
can later become a valid and exposed reference is if there is another
valid reference somewhere (e.g. inside Javascript) which will be used to
insert the referenced element into the DOM at a later point.

If a referenced element is not currently within the DOM, then the only
way it can later become valid and exposed is by being inserted into the
DOM, which requires another reference somewhere (e.g. within Javascript)
to be used to insert into the DOM.

This means that if no other references exist, then the referenced
element(s) can be safely garbage collected as this reference is in an
invalid state (referenced element not in DOM), and we can never reach a
valid state (no other references).

Updating internal maps to store WeakMember(s) rather than Member(s).
This necessitated a move from HeapVector to HeapLinkedHashSet, as
HeapVector does not support WeakMember(s) as elements.
The array setters/getters perform conversion between HeapVector and
HeapLinkedHashSet to keep the V8 bindings happy.

Change-Id: If9733a8affaf9b0b74b705115909627c1dd8e173
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2695010
Reviewed-by: Kent Tamura <tkent@chromium.org>
Reviewed-by: Alice Boxhall <aboxhall@chromium.org>
Reviewed-by: Meredith Lane <meredithl@chromium.org>
Commit-Queue: Chris Hall <chrishall@chromium.org>
Cr-Commit-Position: refs/heads/master@{#860058}

--

wpt-commits: 166fdd4a0a8db278e825763791055c8d0b1cf6ef
wpt-pr: 27892
This commit is contained in:
Chris Hall 2021-03-10 21:14:44 +00:00 коммит произвёл moz-wptsync-bot
Родитель 3fa68581cb
Коммит 14c656dbfb
1 изменённых файлов: 13 добавлений и 0 удалений

Просмотреть файл

@ -708,4 +708,17 @@
}, "Cross-document references and moves."); }, "Cross-document references and moves.");
</script> </script>
<!-- TODO(chrishall): add additional GC test covering:
if an element is in an invalid scope but attached to the document, it's
not GC'd;
-->
<!-- TODO(chrishall): add additional GC test covering:
if an element is not attached to the document, but is in a tree fragment
which is not GC'd because there is a script reference to another element
in the tree fragment, and the relationship is valid because it is between
two elements in that tree fragment, the relationship is exposed *and* the
element is not GC'd
-->
</html> </html>