Auto merge of #16295 - jdm:transition-safety, r=nox

Root nodes for the duration of their CSS transitions

This ensures that we can pass a node address as part of the asynchronous
transition end notification, making it safe to fire the corresponding
DOM event on the node from the script thread. Without explicitly rooting
this node when the transition starts, we risk the node being GCed before
the transition is complete.

---
- [X] `./mach build -d` does not report any errors
- [X] `./mach test-tidy` does not report any errors
- [X] These changes fix #14972
- [X] There are tests for these changes

<!-- Reviewable:start -->
---
This change is [<img src="https://reviewable.io/review_button.svg" height="34" align="absmiddle" alt="Reviewable"/>](https://reviewable.io/reviews/servo/servo/16295)
<!-- Reviewable:end -->
This commit is contained in:
bors-servo 2017-05-15 15:00:19 -05:00 committed by GitHub
commit fa251ec96b
15 changed files with 244 additions and 90 deletions

View file

@ -19897,6 +19897,12 @@
{}
]
],
"mozilla/transitionend_safety.html": [
[
"/_mozilla/mozilla/transitionend_safety.html",
{}
]
],
"mozilla/union.html": [
[
"/_mozilla/mozilla/union.html",
@ -31544,6 +31550,10 @@
"38d8991444d05c40f1d0168bfce8472e378b603c",
"testharness"
],
"mozilla/transitionend_safety.html": [
"778e43b049aa421bad7f86eb03d0955576a84ce0",
"testharness"
],
"mozilla/union.html": [
"47ee847e660eb907a7bd916cf37cf3ceba68ea7d",
"testharness"

View file

@ -0,0 +1,27 @@
<!doctype html>
<meta charset="utf-8">
<title>Asynchronous transitionend event is not a GC hazard</title>
<script src="/resources/testharness.js"></script>
<script src="/resources/testharnessreport.js"></script>
<body>
<script>
async_test(function(t) {
var elem = document.createElement('div');
document.body.appendChild(elem);
elem.textContent = 'hi there';
elem.style.transition = 'color 10ms';
elem.style.color = 'black';
elem.ontransitionend = t.step_func_done();
t.step_timeout(function() {
elem.style.color = 'red';
t.step_timeout(function() {
document.body.removeChild(elem);
elem = null;
window.gc();
}, 0);
}, 0);
}, 'Nodes cannot be GCed while a CSS transition is in effect.');
</script>
</body>