Skip to content

Commit

Permalink
Revert "Fixes #432 - Using a setTimeout stub can stop test suite from…
Browse files Browse the repository at this point in the history
… continuing - closes gh-433"

This reverts commit cf41077.
  • Loading branch information
Krinkle committed May 14, 2013
1 parent cf41077 commit b56ea44
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 67 deletions.
7 changes: 3 additions & 4 deletions qunit/qunit.js
Expand Up @@ -20,7 +20,6 @@ var QUnit,
hasOwn = Object.prototype.hasOwnProperty,
// Keep a local reference to Date (GH-283)
Date = window.Date,
setTimeout = window.setTimeout,
defined = {
setTimeout: typeof window.setTimeout !== "undefined",
sessionStorage: (function() {
Expand Down Expand Up @@ -467,7 +466,7 @@ QUnit = {
}
// A slight delay, to avoid any current callbacks
if ( defined.setTimeout ) {
setTimeout(function() {
window.setTimeout(function() {
if ( config.semaphore > 0 ) {
return;
}
Expand All @@ -490,7 +489,7 @@ QUnit = {

if ( config.testTimeout && defined.setTimeout ) {
clearTimeout( config.timeout );
config.timeout = setTimeout(function() {
config.timeout = window.setTimeout(function() {
QUnit.ok( false, "Test timed out" );
config.semaphore = 1;
QUnit.start();
Expand Down Expand Up @@ -1446,7 +1445,7 @@ function process( last ) {
if ( !defined.setTimeout || config.updateRate <= 0 || ( ( new Date().getTime() - start ) < config.updateRate ) ) {
config.queue.shift()();
} else {
setTimeout( next, 13 );
window.setTimeout( next, 13 );
break;
}
}
Expand Down
63 changes: 0 additions & 63 deletions test/test.js
Expand Up @@ -743,69 +743,6 @@ test('Circular reference - test reported by soniciq in #105', function() {
deepEqual(a.children(), [b]);
});

module("Faking setTimeout");
test("QUnit isn't stopped by fake setTimeout", function() {
var innerRunner =
' <html>' +
' <head>' +
' <meta charset="UTF-8">' +
' <title>QUnit Test Suite</title>' +
' <link rel="stylesheet" href="../qunit/qunit.css">' +
' </head>' +
' <body>' +
' <div id="qunit"></div>' +
' <script src="../qunit/qunit.js"></script>' +
' <script type="text/javascript">' +
' QUnit.config.updateRate = 1;' +
' module("Module that mucks with time", {' +
' setup: function() {' +
' this.setTimeout = window.setTimeout;' +
' window.setTimeout = function() {};' +
' },' +
' teardown: function() {' +
' window.setTimeout = this.setTimeout;' +
' }' +
' });' +
' test("just a test", function() { ok(true); });' +
' test("just a test", function() { ok(true); });' +
' </script>' +
' </body>' +
' </html>';

var frame = document.createElement('iframe');

var supportsSrcDoc = 'srcdoc' in frame;
frame.setAttribute('srcdoc', innerRunner);

if (!supportsSrcDoc) {
var url = ":window.frameElement.getAttribute('srcdoc')";
frame.setAttribute('src', "javascript" + url);
}

document.getElementById('qunit-fixture').appendChild(frame);

expect(1);
QUnit.stop();

var start = Date.now();
setTimeout(checkFinished, 25);

function checkFinished() {
var qunitElement = frame.contentDocument.getElementById('qunit');
var completed = /completed/.test(qunitElement && qunitElement.innerHTML);

if (completed) {
ok(true);
QUnit.start();
} else if (Date.now() - start > 1000) {
ok(false, "QUnit was stopped by fake setTimeout!");
QUnit.start();
} else {
setTimeout(checkFinished, 25);
}
}
});

(function() {
var reset = QUnit.reset;
module("reset");
Expand Down

0 comments on commit b56ea44

Please sign in to comment.