Fix phantomjs browser tests.

This commit is contained in:
John-David Dalton
2013-11-30 19:57:42 -06:00
parent 29f4fd40ed
commit 88ab9d0756
3 changed files with 19 additions and 23 deletions

View File

@@ -5,10 +5,8 @@ node_js:
- "0.10"
env:
global:
- BIN="node" BUILD=false COMPAT=false MAKE=false OPTION="" SAUCE_LABS=false
- SAUCE_USERNAME="lodash"
- secure: "KtDS/UyWv11g9SWk8ylg7VKhMXxGIA06Pe6vBvIm+uhiMgRhUcy78TbFYwspa1wZbIzAoOfYsAXkwu4f8KHsnu80dnUeBzlnW825H6G2xMSU7Zox9aooznVFh3GIFGc+K5zfr78KWK/7lcH6FiVstodup7U5K6GTjgKHqFAHIUE="
- secure: "rYIm0IRvJg4KT+ODO3E3AChRBmq4ruKc6wPDlvPzmtWoa1zChFKwo9kERSFxQ9F+1xMo18NnYiJl6MD6oXQaXwYQF1eULr+yNCAT6GsiiWN40xVyxmdk3wgdcpvotqvTebooMaf/Ey5n6y4s07iAzMXxjWAcsWjb9xWMmtn9ssc="
- BIN="node" BUILD=false COMPAT=false MAKE=false OPTION="" SAUCE_LABS=false SAUCE_USERNAME="lodash"
- secure: "tg1JFsIFnxzLaTboFPOnm+aJCuMm5+JdhLlESlqg9x3fwro++7KCnwHKLNovhchaPe4otC43ZMB/nfWhDnDm11dKbm/V6HlTkED+dadTsaLxVDg6J+7yK41QhokBPJOxLV78iDaNaAQVYEirAgZ0yn8kFubxmNKV+bpCGQNc9yU="
matrix:
- BUILD="compat"
- BUILD="modern"

View File

@@ -116,16 +116,7 @@
page.onInitialized = function() {
page.evaluate(function() {
document.addEventListener('DOMContentLoaded', function() {
var xhr = new XMLHttpRequest;
xhr.open('get', '../vendor/qunit-clib/qunit-clib.js');
xhr.onload = function() {
var script = document.createElement('script');
script.text = xhr.responseText;
document.head.appendChild(script);
QUnit.done(callPhantom);
};
xhr.send(null);
QUnit.done(callPhantom);
});
});
};

View File

@@ -129,9 +129,14 @@
modulePrinted;
/** Object shortcuts */
var phantom = context.phantom,
var console = context.console,
phantom = context.phantom,
process = phantom || context.process,
document = !phantom && context.document;
/** Detects if running in a PhantomJS web page */
var isPhantomPage = typeof context.callPhantom == 'function';
/** Used to display the wait throbber */
var throbberId,
throbberDelay = 500,
@@ -369,11 +374,8 @@
/*------------------------------------------------------------------------*/
// add CLI extras
if (!document) {
/** Add `console.log()` support for Narwhal, Rhino, and RingoJS */
var console = context.console || (context.console = { 'log': context.print });
// add logging extras
if (isPhantomPage || !document) {
/**
* A logging callback triggered when all testing is completed.
@@ -399,7 +401,6 @@
// exit out of Node.js or PhantomJS
try {
var process = context.process || context.phantom;
if (details.failed) {
process.exit(1);
} else {
@@ -508,9 +509,12 @@
return func(object);
};
}());
}
/*----------------------------------------------------------------------*/
/*------------------------------------------------------------------------*/
// add CLI extras
if (!document) {
// Timeout fallbacks based on the work of Andrea Giammarchi and Weston C.
// https://github.com/WebReflection/wru/blob/master/src/rhinoTimers.js
// http://stackoverflow.com/questions/2261705/how-to-run-a-javascript-function-asynchronously-without-using-settimeout
@@ -539,6 +543,9 @@
}());
} catch(e) { }
// add `console.log` support to Narwhal, Rhino, and RingoJS
console || (console = context.console = { 'log': context.print });
// expose shortcuts
// exclude `module` because some environments have it as a built-in object
('asyncTest deepEqual equal equals expect notDeepEqual notEqual notStrictEqual ' +
@@ -546,7 +553,7 @@
context[methodName] = QUnit[methodName];
});
// must call `QUnit.start()` in the test file if not loaded in a browser
// must call `QUnit.start` in the test file if not loaded in a browser
QUnit.config.autostart = false;
QUnit.init();
}