forked from web-platform-tests/wpt
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
WebKit export of https://bugs.webkit.org/show_bug.cgi?id=197960 (web-…
- Loading branch information
1 parent
b91acab
commit 5fdf998
Showing
3 changed files
with
46 additions
and
0 deletions.
There are no files selected for viewing
26 changes: 26 additions & 0 deletions
26
custom-elements/form-associated/ElementInternals-target-element-is-held-strongly.html
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
<!DOCTYPE html> | ||
<title>Target element of ElementsInternals is held strongly and doesn't get GCed if there are no other references</title> | ||
<body> | ||
<script src="/resources/testharness.js"></script> | ||
<script src="/resources/testharnessreport.js"></script> | ||
<script src="../resources/garbage-collect.js"></script> | ||
|
||
<script> | ||
customElements.define("x-foo", class extends HTMLElement {}); | ||
|
||
promise_test(async t => { | ||
const elementInternals = []; | ||
|
||
for (let i = 0; i < 1e5; i++) { | ||
const targetElement = document.createElement("x-foo"); | ||
targetElement.attachShadow({ mode: "open" }); | ||
elementInternals.push(targetElement.attachInternals()); | ||
} | ||
|
||
await maybeGarbageCollectAsync(); | ||
await new Promise(r => t.step_timeout(r, 100)); | ||
|
||
const allShadowRootsAreAlive = elementInternals.every(eI => eI.shadowRoot instanceof ShadowRoot); | ||
assert_true(allShadowRootsAreAlive); | ||
}); | ||
</script> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
async function maybeGarbageCollectAsync() { | ||
if (typeof TestUtils !== 'undefined' && TestUtils.gc) { | ||
await TestUtils.gc(); | ||
} else if (self.gc) { | ||
// Use --expose_gc for V8 (and Node.js) | ||
// to pass this flag at chrome launch use: --js-flags="--expose-gc" | ||
// Exposed in SpiderMonkey shell as well | ||
await self.gc(); | ||
} else if (self.GCController) { | ||
// Present in some WebKit development environments | ||
await GCController.collect(); | ||
} else { | ||
/* eslint-disable no-console */ | ||
console.warn('Tests are running without the ability to do manual ' + | ||
'garbage collection. They will still work, but ' + | ||
'coverage will be suboptimal.'); | ||
/* eslint-enable no-console */ | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters