<!DOCTYPE html>
<html>
<head>
<script src="../../resources/js-test-pre.js"></script>
</head>
<body>
<span id="e"></span>
<span id="f"></span>
<script>
description("Tests adding one callback within another");

var e = document.getElementById("e");
var sameFrame;
window.requestAnimationFrame(function() {
    sameFrame = true;
}, e);
window.requestAnimationFrame(function() {
    window.requestAnimationFrame(function() {
        shouldBeFalse("sameFrame");
    }, e);
}, e);
window.requestAnimationFrame(function() {
    sameFrame = false;
}, e);

// This should fire the three already registered callbacks, but not the one dynamically registered.
if (window.testRunner)
    testRunner.displayAndTrackRepaints();
// This should fire the dynamically registered callback.
if (window.testRunner)
    testRunner.displayAndTrackRepaints();

if (window.testRunner)
    testRunner.waitUntilDone();

setTimeout(function() {
    isSuccessfullyParsed();
    if (window.testRunner)
        testRunner.notifyDone();
}, 200);
</script>
</body>
</html>
