<!DOCTYPE html>
<html>
<head>
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0, maximum-scale=1.0, shrink-to-fit=no, user-scalable=0"/>
    <link type="text/css" rel=stylesheet href="/qunit-1.20.0.css">

    <script type="text/javascript">
        // HACK: (ie9 only) we have discovered an issue with the window.setTimeout function in IE9 on a
        // Saucelabs virtual machine: sometimes, async functions are called earlier than they should be.
        // For example, a QUnit call window.setTimeout(timeoutExceededHandler, 30000) raises the handler in less
        // than a second. It seems that this behavior depends on how fast the VM or the browser are performing.
        (function (window) {
            var userAgent = navigator.userAgent.toLowerCase();
            var isIE9     = userAgent.indexOf('msie 9') > -1;

            if (!isIE9)
                return;

            var nativeSetTimeout   = window.setTimeout;
            var nativeClearTimeout = window.clearTimeout;
            var overriddenTimeouts = {};
            var eval               = window.eval;

            window.setTimeout = function () {
                var fn              = arguments[0];
                var expectedDelay   = arguments[1];
                var fnArgs          = Array.prototype.slice.call(arguments, 2);
                var originalTimeout = 0;

                var startTime = Date.now();

                function execute () {
                    var now         = Date.now();
                    var timeoutDiff = expectedDelay - (now - startTime);

                    if (timeoutDiff > 200) {
                        startTime     = now;
                        expectedDelay = timeoutDiff;

                        overriddenTimeouts[originalTimeout] = nativeSetTimeout.call(window, execute, expectedDelay);
                    }
                    else {
                        if (overriddenTimeouts[originalTimeout])
                            delete overriddenTimeouts[originalTimeout];

                        if (typeof fn === 'string')
                            return eval(fn);

                        fn.apply(window, fnArgs);
                    }
                }

                originalTimeout = nativeSetTimeout.call(window, execute, expectedDelay);

                return originalTimeout;
            };

            window.clearTimeout = function (timeout) {
                if (overriddenTimeouts[timeout])
                    timeout = overriddenTimeouts[timeout];

                nativeClearTimeout.call(window, timeout);
            }
        })(window);
    </script>

    <script type="text/javascript" src="/jquery.js"></script>
    <script type="text/javascript" src="/qunit-1.20.0.js"></script>

    <script type="text/javascript">
        (function () {
            {{{globals}}}
        })();
    </script>

    <script type="text/javascript">
        (function () {
            {{{qunitSetup}}}
        })();
    </script>

    <script type="text/javascript">
        (function () {
            {{{storeGlobals}}}
        })();
    </script>

    {{# css}}
        <link rel="stylesheet" type="text/css" href="{{{src}}}">
    {{/css}}

    {{# scripts}}
        <script type="text/javascript" src="{{{src}}}"></script>
    {{/scripts}}

    <script type="text/javascript">
        (function () {
            {{{restoreGlobals}}}
        })();
    </script>
</head>
<body>
<ol id=qunit-tests></ol>

{{{ markup }}}

<script type="text/javascript">
    (function () {
        {{{ test }}}
    })();
</script>
</body>
</html>
