<!DOCTYPE html>
<html>
<body>
<script src="../../resources/js-test-pre.js"></script>
<script>
description("Tests that SVG animations are properly paused in disconnected iframes.");
jsTestIsAsync = true;

window.onload = function() {
    frame = document.getElementById("testFrame");
    grandChildFrame = frame.contentDocument.getElementById("grandChildFrame");
    frameWindow = frame.contentWindow;
    grandChildWindow = grandChildFrame.contentWindow;

    shouldBeFalse("frameWindow.internals.areSVGAnimationsPaused");
    shouldBeFalse("frameWindow.document.getElementsByTagName('svg')[0].animationsPaused()");
    shouldBeFalse("grandChildWindow.internals.areSVGAnimationsPaused");
    shouldBeFalse("grandChildWindow.document.getElementsByTagName('svg')[0].animationsPaused()");

    debug("Removing iframe from the document.");
    frame.remove();

    shouldBeTrue("frameWindow.internals.areSVGAnimationsPaused");
    shouldBeTrue("frameWindow.document.getElementsByTagName('svg')[0].animationsPaused()");
    shouldBeTrue("grandChildWindow.internals.areSVGAnimationsPaused");
    shouldBeTrue("grandChildWindow.document.getElementsByTagName('svg')[0].animationsPaused()");

    debug("Add iframe back into the document.");
    frame.onload = function() {
        shouldBeFalse("frame.contentWindow.internals.areSVGAnimationsPaused");
        shouldBeFalse("frame.contentDocument.getElementsByTagName('svg')[0].animationsPaused()");
        grandChildFrame = frame.contentDocument.getElementById("grandChildFrame");
        grandChildWindow = grandChildFrame.contentWindow;
        shouldBeFalse("grandChildWindow.document.getElementsByTagName('svg')[0].animationsPaused()");
        finishJSTest();
    }
    document.body.appendChild(frame);
}
</script>
<iframe id="testFrame" src="resources/frame-with-svg-animation.html"></iframe>
<script src="../../resources/js-test-post.js"></script>
</body>
</html>
