From 0f8db11f53aa3ae96008e562deb316a7adf47eb8 Mon Sep 17 00:00:00 2001 From: John-David Dalton Date: Sat, 3 May 2014 07:55:11 -0700 Subject: [PATCH] Restrict script load error excusal a bit. --- test/asset/test-ui.js | 9 +++++++++ test/backbone.html | 7 +++++-- test/index.html | 7 +++++-- test/underscore.html | 7 +++++-- 4 files changed, 24 insertions(+), 6 deletions(-) diff --git a/test/asset/test-ui.js b/test/asset/test-ui.js index 5b9a72128..c4f038b5d 100644 --- a/test/asset/test-ui.js +++ b/test/asset/test-ui.js @@ -121,6 +121,10 @@ var buildList = span1.lastChild, loaderList = span2.lastChild; + setTimeout(function() { + ui.timing.loadEventEnd = +new Date; + }, 1); + init(); }); @@ -161,6 +165,11 @@ 'loader': loader }; + // expose page load timestamps + ui.timing = { + 'loadEventEnd': 0 + }; + // used to indicate testing a modularized build ui.isModularize = /\b(?:commonjs|(index|main)\.js|lodash-(?:amd|node)|modularize|npm)\b/.test([location.pathname, location.search, ui.buildPath]); diff --git a/test/backbone.html b/test/backbone.html index 10b59cc35..0b0ec233e 100644 --- a/test/backbone.html +++ b/test/backbone.html @@ -64,10 +64,13 @@ mixinPrereqs(_); return; } - // avoid reporting tests to Sauce Labs when errors occur + // avoid reporting tests to Sauce Labs when script load errors occur if (ui.isSauceLabs) { window.onerror = function() { - QUnit.config.done.length = 0; + var loadEventEnd = ui.timing.loadEventEnd; + if (loadEventEnd && (new Date - loadEventEnd > 5000)) { + QUnit.config.done.length = 0; + } }; } var reBasename = /[\w.-]+$/, diff --git a/test/index.html b/test/index.html index 1982ab7eb..8c7def302 100644 --- a/test/index.html +++ b/test/index.html @@ -185,10 +185,13 @@ if (!window.require) { return; } - // avoid reporting tests to Sauce Labs when errors occur + // avoid reporting tests to Sauce Labs when script load errors occur if (ui.isSauceLabs) { window.onerror = function() { - QUnit.config.done.length = 0; + var loadEventEnd = ui.timing.loadEventEnd; + if (loadEventEnd && (new Date - loadEventEnd > 5000)) { + QUnit.config.done.length = 0; + } }; } var reBasename = /[\w.-]+$/, diff --git a/test/underscore.html b/test/underscore.html index ac31ff2cc..58c087665 100644 --- a/test/underscore.html +++ b/test/underscore.html @@ -176,10 +176,13 @@ if (!window.require) { return; } - // avoid reporting tests to Sauce Labs when errors occur + // avoid reporting tests to Sauce Labs when script load errors occur if (ui.isSauceLabs) { window.onerror = function() { - QUnit.config.done.length = 0; + var loadEventEnd = ui.timing.loadEventEnd; + if (loadEventEnd && (new Date - loadEventEnd > 5000)) { + QUnit.config.done.length = 0; + } }; } var reBasename = /[\w.-]+$/,