Cleanup phantomjs support in test.js.

This commit is contained in:
John-David Dalton
2013-09-05 20:33:52 -05:00
parent 3560fed86e
commit 720e19a01f

View File

@@ -2,7 +2,8 @@
'use strict'; 'use strict';
/** Object shortcuts */ /** Object shortcuts */
var phantom = root.phantom, var amd = root.define && define.amd,
phantom = root.phantom,
process = root.process, process = root.process,
system = root.system; system = root.system;
@@ -27,7 +28,7 @@
result = (result.length > min && !/test(?:\.js)?$/.test(last)) ? last : '../lodash.js'; result = (result.length > min && !/test(?:\.js)?$/.test(last)) ? last : '../lodash.js';
try { try {
if (typeof define == 'undefined') { if (!amd) {
return require('fs').realpathSync(result); return require('fs').realpathSync(result);
} }
} catch(e) { } } catch(e) { }
@@ -51,7 +52,7 @@
if (phantom && isModularize) { if (phantom && isModularize) {
var page = require('webpage').create(); var page = require('webpage').create();
page.open(filePath, function(status) { page.open(filePath, function(status) {
if (status !== 'success') { if (status != 'success') {
console.log('PhantomJS failed to load page: ' + filePath); console.log('PhantomJS failed to load page: ' + filePath);
phantom.exit(1); phantom.exit(1);
} }
@@ -68,17 +69,11 @@
page.onInitialized = function() { page.onInitialized = function() {
page.evaluate(function() { page.evaluate(function() {
document.addEventListener('DOMContentLoaded', function() { document.addEventListener('DOMContentLoaded', function() {
var xhr = new XMLHttpRequest; var script = document.createElement('script');
xhr.open('GET', '../vendor/qunit-clib/qunit-clib.js'); script.src = '../vendor/qunit-clib/qunit-clib.js';
xhr.onload = function() { document.head.appendChild(script);
var script = document.createElement('script'); QUnit.done(callPhantom);
script.text = xhr.responseText; });
document.head.appendChild(script);
QUnit.done(callPhantom);
};
xhr.send(null);
}, false);
}); });
}; };
@@ -89,14 +84,13 @@
/** Method and object shortcuts */ /** Method and object shortcuts */
var document = !phantom && root.document, var document = !phantom && root.document,
amd = root.define && define.amd,
body = document && document.body, body = document && document.body,
create = Object.create, create = Object.create,
freeze = Object.freeze, freeze = Object.freeze,
push = Array.prototype.push, push = Array.prototype.push,
slice = Array.prototype.slice, slice = Array.prototype.slice,
toString = Object.prototype.toString, toString = Object.prototype.toString,
Worker = !phantom && root.Worker; Worker = document && root.Worker;
/** Detects if running in a PhantomJS web page */ /** Detects if running in a PhantomJS web page */
var isPhantomPage = typeof callPhantom == 'function'; var isPhantomPage = typeof callPhantom == 'function';