Update vendors.

Former-commit-id: 25cce48fee2dfb010eb6a9c2e4235890f20b19aa
This commit is contained in:
John-David Dalton
2013-02-21 08:40:09 -08:00
parent f6e724c4c5
commit 71a207079f
2 changed files with 73 additions and 46 deletions

View File

@@ -25,6 +25,9 @@
/** Detect Java environment */ /** Detect Java environment */
var java = /Java/.test(getClassOf(window.java)) && window.java; var java = /Java/.test(getClassOf(window.java)) && window.java;
/** Detect Rhino */
var rhino = java && getClassOf(window.environment) == 'Environment';
/** A character to represent alpha */ /** A character to represent alpha */
var alpha = java ? 'a' : '\u03b1'; var alpha = java ? 'a' : '\u03b1';
@@ -597,7 +600,7 @@
arch = data.getProperty('os.arch'); arch = data.getProperty('os.arch');
os = os || data.getProperty('os.name') + ' ' + data.getProperty('os.version'); os = os || data.getProperty('os.name') + ' ' + data.getProperty('os.version');
} }
if (typeof exports == 'object' && exports) { if (freeExports) {
// if `thisBinding` is the [ModuleScope] // if `thisBinding` is the [ModuleScope]
if (thisBinding == oldWin && typeof system == 'object' && (data = [system])[0]) { if (thisBinding == oldWin && typeof system == 'object' && (data = [system])[0]) {
os || (os = data[0].os || null); os || (os = data[0].os || null);
@@ -610,13 +613,18 @@
name = 'Narwhal'; name = 'Narwhal';
} }
} }
} else if (typeof process == 'object' && (data = process)) { }
else if (typeof process == 'object' && (data = process)) {
name = 'Node.js'; name = 'Node.js';
arch = data.arch; arch = data.arch;
os = data.platform; os = data.platform;
version = /[\d.]+/.exec(data.version)[0]; version = /[\d.]+/.exec(data.version)[0];
} }
} else if (getClassOf(window.environment) == 'Environment') { else if (rhino) {
name = 'Rhino';
}
}
else if (rhino) {
name = 'Rhino'; name = 'Rhino';
} }
} }

View File

@@ -7,12 +7,24 @@
;(function(window) { ;(function(window) {
'use strict'; 'use strict';
/** Detect free variable `exports` */
var freeExports = typeof exports == 'object' && exports;
/** Detect free variable `global` and use it as `window` */
var freeGlobal = typeof global == 'object' && global;
if (freeGlobal.global === freeGlobal) {
window = freeGlobal;
}
/*--------------------------------------------------------------------------*/
/** /**
* Timeout fallbacks based on the work of Andrea Giammarchi and Weston C. * Installs the CLI boilerplate additions on the `context` object.
* 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 * @private
* @param {Object} context The context object.
*/ */
(function() { function runInContext(context) {
/** /**
* Schedules timer-based callbacks. * Schedules timer-based callbacks.
@@ -29,7 +41,7 @@
// https://bugzilla.mozilla.org/show_bug.cgi?id=775566 // https://bugzilla.mozilla.org/show_bug.cgi?id=775566
var task = ids[++counter] = new JavaAdapter(java.util.TimerTask, { var task = ids[++counter] = new JavaAdapter(java.util.TimerTask, {
'run': function() { 'run': function() {
fn.apply(window, args); fn.apply(context, args);
} }
}); });
// support non-functions // support non-functions
@@ -53,7 +65,7 @@
/** /**
* Clears the delay set by `setInterval` or `setTimeout`. * Clears the delay set by `setInterval` or `setTimeout`.
* *
* @memberOf window * @memberOf context
* @param {Number} id The ID of the timeout to be cleared. * @param {Number} id The ID of the timeout to be cleared.
*/ */
function clearTimer(id) { function clearTimer(id) {
@@ -67,7 +79,7 @@
/** /**
* Executes a code snippet or function repeatedly, with a delay between each call. * Executes a code snippet or function repeatedly, with a delay between each call.
* *
* @memberOf window * @memberOf context
* @param {Function|String} fn The function to call or string to evaluate. * @param {Function|String} fn The function to call or string to evaluate.
* @oaram {Number} delay The number of milliseconds to delay each `fn` call. * @oaram {Number} delay The number of milliseconds to delay each `fn` call.
* @param [arg1, arg2, ...] Arguments to invoke `fn` with. * @param [arg1, arg2, ...] Arguments to invoke `fn` with.
@@ -80,7 +92,7 @@
/** /**
* Executes a code snippet or a function after specified delay. * Executes a code snippet or a function after specified delay.
* *
* @memberOf window * @memberOf context
* @param {Function|String} fn The function to call or string to evaluate. * @param {Function|String} fn The function to call or string to evaluate.
* @oaram {Number} delay The number of milliseconds to delay the `fn` call. * @oaram {Number} delay The number of milliseconds to delay the `fn` call.
* @param [arg1, arg2, ...] Arguments to invoke `fn` with. * @param [arg1, arg2, ...] Arguments to invoke `fn` with.
@@ -90,29 +102,17 @@
return schedule(fn, delay, slice.call(arguments, 2)); return schedule(fn, delay, slice.call(arguments, 2));
} }
try { /*------------------------------------------------------------------------*/
var counter = 0,
ids = {},
slice = Array.prototype.slice,
timer = new java.util.Timer;
window.clearInterval = /** Add `console.log()` support for Narwhal, Rhino, and RingoJS */
window.clearTimeout = clearTimer; var console = context.console || (context.console = { 'log': context.print });
window.setInterval = setInterval;
window.setTimeout = setTimeout;
} catch(e) { }
}());
/*--------------------------------------------------------------------------*/ /** Shorten `context.QUnit.QUnit` to `context.QUnit` */
var QUnit = context.QUnit = context.QUnit.QUnit || context.QUnit;
(function() {
/** Used as a horizontal rule in console output */ /** Used as a horizontal rule in console output */
var hr = '----------------------------------------'; var hr = '----------------------------------------';
/** Shorten `window.QUnit.QUnit` to `window.QUnit` */
window.QUnit && (QUnit = QUnit.QUnit || QUnit);
/** /**
* A logging callback triggered when all testing is completed. * A logging callback triggered when all testing is completed.
* *
@@ -134,14 +134,14 @@
console.log(' Finished in ' + details.runtime + ' milliseconds.'); console.log(' Finished in ' + details.runtime + ' milliseconds.');
console.log(hr); console.log(hr);
// exit out of Rhino // exit out of Narhwal, Rhino, or Ringo
try { try {
quit(); quit();
} catch(e) { } } catch(e) { }
// exit out of Node.js or PhantomJS // exit out of Node.js or PhantomJS
try { try {
var process = window.process || window.phantom; var process = context.process || context.phantom;
if (details.failed) { if (details.failed) {
console.error('Error: ' + details.failed + ' of ' + details.total + ' tests failed.'); console.error('Error: ' + details.failed + ' of ' + details.total + ' tests failed.');
process.exit(1); process.exit(1);
@@ -247,23 +247,42 @@
*/ */
'assertions': [] 'assertions': []
}; };
}());
/*------------------------------------------------------------------------*/
// 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
try {
var counter = 0,
ids = {},
slice = Array.prototype.slice,
timer = new java.util.Timer;
context.clearInterval =
context.clearTimeout = clearTimer;
context.setInterval = setInterval;
context.setTimeout = setTimeout;
} catch(e) { }
// expose shortcuts
// exclude `module` because some environments have it as a built-in object
('asyncTest deepEqual equal equals expect notDeepEqual notEqual notStrictEqual ' +
'ok raises same start stop strictEqual test throws').replace(/\S+/g, function(methodName) {
context[methodName] = QUnit[methodName];
});
// must call `QUnit.start()` in the test file if using QUnit < 1.3.0 with
// Node.js or any version of QUnit with Narwhal, PhantomJS, Rhino, or RingoJS
QUnit.init();
}
/*--------------------------------------------------------------------------*/ /*--------------------------------------------------------------------------*/
// expose shortcuts // expose QUnit CLIB
// exclude `module` because some environments have it as a built-in object if (freeExports) {
('asyncTest deepEqual equal equals expect notDeepEqual notEqual notStrictEqual ' + freeExports.runInContext = runInContext;
'ok raises same start stop strictEqual test throws').replace(/\S+/g, function(methodName) { } else {
window[methodName] = QUnit[methodName]; runInContext(window);
});
// add `console.log()` support for Narwhal, Rhino, and RingoJS
if (!window.console && window.print) {
window.console = { 'log': window.print };
} }
// must call `QUnit.start()` in the test file if using QUnit < 1.3.0 with }(this));
// Node.js or any version of QUnit with Narwhal, PhantomJS, Rhino, or RingoJS
QUnit.init();
}(typeof global == 'object' && global || this));