The testcase has an svg-as-image inside an svg-as-image. At shutdown the viewer of the inner svg-as-image is destroyed (via the shutdown observer) first. Then the outer svg-as-image destroys its viewer which tries to unregister all image requests from the refresh driver. So it unregisters the inner svg-as-image, which calls GetAnimated.
This patch gives ns{I,}Document the ability to track use counters and
also to send those to telemetry at document destruction time. We push
things to telemetry lazily because we're can't definitively say whether
something has been used until the document is torn down.