haikuwebkit/LayoutTests/webanimations/no-css-animation-on-noscrip...

29 lines
514 B
HTML
Raw Permalink Normal View History

[Web Animations] Stop creating CSS Animations for <noscript> elements https://bugs.webkit.org/show_bug.cgi?id=205925 <rdar://problem/58158479> Reviewed by Antti Koivisto. Source/WebCore: Test: webanimations/no-css-animation-on-noscript.html It makes no sense to create CSS Animations for a <noscript> element and it has the side effect of potential crashes. Indeed, AnimationTimeline::updateCSSAnimationsForElement() may be called without a currentStyle and so we never have a list of previously-applied animations to compare to the list of animations in afterChangeStyle. So on each call we end up creating a new CSSAnimation and the previous animation for the same name is never explicitly removed from the effect stack and is eventually destroyed and the WeakPtr for it in the stack ends up being null, which would cause a crash under KeyframeEffectStack::ensureEffectsAreSorted(). We now prevent elements such as <noscript> from being considered for CSS Animations in TreeResolver::resolveElement(). * dom/Element.cpp: (WebCore::Element::rendererIsNeeded): * dom/Element.h: (WebCore::Element::rendererIsEverNeeded): * html/HTMLElement.cpp: (WebCore::HTMLElement::rendererIsEverNeeded): (WebCore::HTMLElement::rendererIsNeeded): Deleted. * html/HTMLElement.h: * style/StyleTreeResolver.cpp: (WebCore::Style::TreeResolver::resolveElement): LayoutTests: Add a new test that checks that setting the `animation` property on a <noscript> element does not yield the creation of a CSSAnimation object. * webanimations/no-css-animation-on-noscript-expected.txt: Added. * webanimations/no-css-animation-on-noscript.html: Added. Canonical link: https://commits.webkit.org/219060@main git-svn-id: https://svn.webkit.org/repository/webkit/trunk@254201 268f45cc-cd09-0410-ab3c-d52691b4dbfc
2020-01-08 16:30:39 +00:00
<!DOCTYPE html>
<html>
<head>
<style>
noscript {
animation: animation 1s infinite;
}
@keyframes animation {
to { margin-left: "100px" };
}
</style>
</head>
<body>
<script src="../resources/testharness.js"></script>
<script src="../resources/testharnessreport.js"></script>
<noscript>Hello World</noscript>
<script>
test(() => {
assert_equals(document.querySelector("noscript").getAnimations().length, 0);
}, "A CSS Animation cannot be created on a <noscript> element.");
</script>
</body>
</html>