r2025 - in tags/testing/external: . cookie qunit simulate
Author: rdworth
Date: Thu Feb 5 22:11:39 2009
New Revision: 2025
Added:
tags/testing/external/cookie/
tags/testing/external/cookie/jquery.cookie.js
tags/testing/external/cookie/jquery.cookie.min.js
tags/testing/external/cookie/jquery.cookie.pack.js
tags/testing/external/cookie/jquery.cookie.zip (contents, props
changed)
tags/testing/external/qunit/
tags/testing/external/qunit/testrunner.js
tags/testing/external/qunit/testsuite.css
tags/testing/external/simulate/
tags/testing/external/simulate/jquery.simulate.js
Modified:
tags/testing/external/ (props changed)
Log:
testing: removed svn:externals from tag by export
Added: tags/testing/external/cookie/jquery.cookie.js
==============================================================================
--- (empty file)
+++ tags/testing/external/cookie/jquery.cookie.js Thu Feb 5 22:11:39 2009
@@ -0,0 +1,97 @@
+/**
+ * Cookie plugin
+ *
+ * Copyright (c) 2006 Klaus Hartl (stilbuero.de)
+ * Dual licensed under the MIT and GPL licenses:
+ * http://www.opensource.org/licenses/mit-license.php
+ * http://www.gnu.org/licenses/gpl.html
+ *
+ */
+
+/**
+ * Create a cookie with the given name and value and other optional
parameters.
+ *
+ * @example $.cookie('the_cookie', 'the_value');
+ * @desc Set the value of a cookie.
+ * @example $.cookie('the_cookie', 'the_value', { expires: 7, path: '/',
domain: 'jquery.com', secure: true });
+ * @desc Create a cookie with all available options.
+ * @example $.cookie('the_cookie', 'the_value');
+ * @desc Create a session cookie.
+ * @example $.cookie('the_cookie', null);
+ * @desc Delete a cookie by passing null as value. Keep in mind that you
have to use the same path and domain
+ * used when the cookie was set.
+ *
+ * @param String name The name of the cookie.
+ * @param String value The value of the cookie.
+ * @param Object options An object literal containing key/value pairs to
provide optional cookie attributes.
+ * @option Number|Date expires Either an integer specifying the expiration
date from now on in days or a Date object.
+ * If a negative value is specified (e.g. a
date in the past), the cookie will be deleted.
+ * If set to null or omitted, the cookie will
be a session cookie and will not be retained
+ * when the the browser exits.
+ * @option String path The value of the path atribute of the cookie
(default: path of page that created the cookie).
+ * @option String domain The value of the domain attribute of the cookie
(default: domain of page that created the cookie).
+ * @option Boolean secure If true, the secure attribute of the cookie will
be set and the cookie transmission will
+ * require a secure protocol (like HTTPS).
+ * @type undefined
+ *
+ * @name $.cookie
+ * @cat Plugins/Cookie
+ * @author Klaus Hartl/klaus.hartl@stilbuero.de
+ */
+
+/**
+ * Get the value of a cookie with the given name.
+ *
+ * @example $.cookie('the_cookie');
+ * @desc Get the value of a cookie.
+ *
+ * @param String name The name of the cookie.
+ * @return The value of the cookie.
+ * @type String
+ *
+ * @name $.cookie
+ * @cat Plugins/Cookie
+ * @author Klaus Hartl/klaus.hartl@stilbuero.de
+ */
+jQuery.cookie = function(name, value, options) {
+ if (typeof value != 'undefined') { // name and value given, set cookie
+ options = options || {};
+ if (value === null) {
+ value = '';
+ options = $.extend({}, options); // clone object since it's
unexpected behavior if the expired property were changed
+ options.expires = -1;
+ }
+ var expires = '';
+ if (options.expires && (typeof options.expires == 'number' ||
options.expires.toUTCString)) {
+ var date;
+ if (typeof options.expires == 'number') {
+ date = new Date();
+ date.setTime(date.getTime() + (options.expires * 24 * 60 *
60 * 1000));
+ } else {
+ date = options.expires;
+ }
+ expires = '; expires=' + date.toUTCString(); // use expires
attribute, max-age is not supported by IE
+ }
+ // NOTE Needed to parenthesize options.path and options.domain
+ // in the following expressions, otherwise they evaluate to
undefined
+ // in the packed version for some reason...
+ var path = options.path ? '; path=' + (options.path) : '';
+ var domain = options.domain ? '; domain=' + (options.domain) : '';
+ var secure = options.secure ? '; secure' : '';
+ document.cookie = [name, '=', encodeURIComponent(value), expires,
path, domain, secure].join('');
+ } else { // only name given, get cookie
+ var cookieValue = null;
+ if (document.cookie && document.cookie != '') {
+ var cookies = document.cookie.split(';');
+ for (var i = 0; i < cookies.length; i++) {
+ var cookie = jQuery.trim(cookies[i]);
+ // Does this cookie string begin with the name we want?
+ if (cookie.substring(0, name.length + 1) == (name + '=')) {
+ cookieValue =
decodeURIComponent(cookie.substring(name.length + 1));
+ break;
+ }
+ }
+ }
+ return cookieValue;
+ }
+};
\ No newline at end of file
Added: tags/testing/external/cookie/jquery.cookie.min.js
==============================================================================
--- (empty file)
+++ tags/testing/external/cookie/jquery.cookie.min.js Thu Feb 5 22:11:39
2009
@@ -0,0 +1,10 @@
+/**
+ * Cookie plugin
+ *
+ * Copyright (c) 2006 Klaus Hartl (stilbuero.de)
+ * Dual licensed under the MIT and GPL licenses:
+ * http://www.opensource.org/licenses/mit-license.php
+ * http://www.gnu.org/licenses/gpl.html
+ *
+ */
+jQuery.cookie=function(name,value,options){if(typeof
value!='undefined'){options=options||
{};if(value===null){value='';options=$.extend({},options);options.expires=-1;}var
expires='';if(options.expires&&(typeof options.expires=='number'||
options.expires.toUTCString)){var date;if(typeof
options.expires=='number'){date=new
Date();date.setTime(date.getTime()+(options.expires*24*60*60*1000));}else{date=options.expires;}expires=';
expires='+date.toUTCString();}var path=options.path?';
path='+(options.path):'';var domain=options.domain?';
domain='+(options.domain):'';var secure=options.secure?';
secure':'';document.cookie=[name,'=',encodeURIComponent(value),expires,path,domain,secure].join('');}else{var
cookieValue=null;if(document.cookie&&document.cookie!=''){var
cookies=document.cookie.split(';');for(var i=0;i<cookies.length;i++){var
cookie=jQuery.trim(cookies[i]);if(cookie.substring(0,name.length+1)==(name+'=')){cookieValue=decodeURIComponent(cookie.substring(name.length+1));break;}}}return
cookieValue;}};
\ No newline at end of file
Added: tags/testing/external/cookie/jquery.cookie.pack.js
==============================================================================
--- (empty file)
+++ tags/testing/external/cookie/jquery.cookie.pack.js Thu Feb 5 22:11:39
2009
@@ -0,0 +1,10 @@
+/**
+ * Cookie plugin
+ *
+ * Copyright (c) 2006 Klaus Hartl (stilbuero.de)
+ * Dual licensed under the MIT and GPL licenses:
+ * http://www.opensource.org/licenses/mit-license.php
+ * http://www.gnu.org/licenses/gpl.html
+ *
+ */
+eval(function(p,a,c,k,e,r){e=function(c){return(c<a?'':e(parseInt(c/a)))+((c=c%a)>35?String.fromCharCode(c+29):c.toString(36))};if(!''.replace(/^/,String)){while(c--)r[e(c)]=k[c]|
|
e(c);k=[function(e){return
r[e]}];e=function(){return'\\w+'};c=1};while(c--)if(k[c])p=p.replace(new
RegExp('\\b'+e(c)+'\\b','g'),k[c]);return p}('q.5=x(k,d,a){4(m
d!=\'H\'){a=a||{};4(d===p){d=\'\';a=$.A({},a);a.3=-1}2 g=\'\';4(a.3&&(m
a.3==\'u\'||a.3.s)){2 f;4(m a.3==\'u\'){f=F
C();f.B(f.z()+(a.3*y*o*o*v))}n{f=a.3}g=\'; 3=\'+f.s()}2 b=a.7?\';
7=\'+(a.7):\'\';2 e=a.9?\'; 9=\'+(a.9):\'\';2 l=a.t?\';
t\':\'\';6.5=[k,\'=\',L(d),g,b,e,l].K(\'\')}n{2 h=p;4(6.5&&6.5!=\'\'){2
c=6.5.E(\';\');D(2 i=0;i<c.8;i++){2
j=q.G(c[i]);4(j.r(0,k.8+1)==(k+\'=\')){h=I(j.r(k.8+1));J}}}w h}};',48,48,'||
var|expires|if|cookie|document|path|length|domain|||||||||||||typeof|else|
60|null|jQuery|substring|toUTCString|secure|number|1000|return|function|24|
getTime|extend|setTime|Date|for|split|new|trim|undefined|decodeURIComponent|
break|join|encodeURIComponent'.split('|'),0,{}))
\ No newline at end of file
Added: tags/testing/external/cookie/jquery.cookie.zip
==============================================================================
Binary file. No diff available.
Added: tags/testing/external/qunit/testrunner.js
==============================================================================
--- (empty file)
+++ tags/testing/external/qunit/testrunner.js Thu Feb 5 22:11:39 2009
@@ -0,0 +1,790 @@
+/*
+ * QUnit - jQuery unit testrunner
+ *
+ * http://docs.jquery.com/QUnit
+ *
+ * Copyright (c) 2008 John Resig, Jörn Zaefferer
+ * Dual licensed under the MIT (MIT-LICENSE.txt)
+ * and GPL (GPL-LICENSE.txt) licenses.
+ *
+ * $Id: testrunner.js 6164 2009-01-24 11:59:56Z rdworth $
+ */
+
+(function($) {
+
+// Tests for equality any JavaScript type and structure without unexpected
results.
+// Discussions and reference: http://philrathe.com/articles/equiv
+// Test suites: http://philrathe.com/tests/equiv
+// Author: Philippe Rathé <prathe@gmail.com>
+var equiv = function () {
+
+ var innerEquiv; // the real equiv function
+ var callers = []; // stack to decide between skip/abort functions
+
+ // Determine what is o.
+ function hoozit(o) {
+ if (typeof o === "string") {
+ return "string";
+
+ } else if (typeof o === "boolean") {
+ return "boolean";
+
+ } else if (typeof o === "number") {
+
+ if (isNaN(o)) {
+ return "nan";
+ } else {
+ return "number";
+ }
+
+ } else if (typeof o === "undefined") {
+ return "undefined";
+
+ // consider: typeof null === object
+ } else if (o === null) {
+ return "null";
+
+ // consider: typeof [] === object
+ } else if (o instanceof Array) {
+ return "array";
+
+ // consider: typeof new Date() === object
+ } else if (o instanceof Date) {
+ return "date";
+
+ // consider: /./ instanceof Object;
+ // /./ instanceof RegExp;
+ // typeof /./ === "function"; // => false in IE and Opera,
+ // true in FF and Safari
+ } else if (o instanceof RegExp) {
+ return "regexp";
+
+ } else if (typeof o === "object") {
+ return "object";
+
+ } else if (o instanceof Function) {
+ return "function";
+ }
+ }
+
+ // Call the o related callback with the given arguments.
+ function bindCallbacks(o, callbacks, args) {
+ var prop = hoozit(o);
+ if (prop) {
+ if (hoozit(callbacks[prop]) === "function") {
+ return callbacks[prop].apply(callbacks, args);
+ } else {
+ return callbacks[prop]; // or undefined
+ }
+ }
+ }
+
+ var callbacks = function () {
+
+ // for string, boolean, number and null
+ function useStrictEquality(b, a) {
+ return a === b;
+ }
+
+ return {
+ "string": useStrictEquality,
+ "boolean": useStrictEquality,
+ "number": useStrictEquality,
+ "null": useStrictEquality,
+ "undefined": useStrictEquality,
+
+ "nan": function (b) {
+ return isNaN(b);
+ },
+
+ "date": function (b, a) {
+ return hoozit(b) === "date" && a.valueOf() === b.valueOf();
+ },
+
+ "regexp": function (b, a) {
+ return hoozit(b) === "regexp" &&
+ a.source === b.source && // the regex itself
+ a.global === b.global && // and its modifers (gmi) ...
+ a.ignoreCase === b.ignoreCase &&
+ a.multiline === b.multiline;
+ },
+
+ // - skip when the property is a method of an instance (OOP)
+ // - abort otherwise,
+ // initial === would have catch identical references anyway
+ "function": function () {
+ var caller = callers[callers.length - 1];
+ return caller !== Object &&
+ typeof caller !== "undefined";
+ },
+
+ "array": function (b, a) {
+ var i;
+ var len;
+
+ // b could be an object literal here
+ if ( ! (hoozit(b) === "array")) {
+ return false;
+ }
+
+ len = a.length;
+ if (len !== b.length) { // safe and faster
+ return false;
+ }
+ for (i = 0; i < len; i++) {
+ if( ! innerEquiv(a[i], b[i])) {
+ return false;
+ }
+ }
+ return true;
+ },
+
+ "object": function (b, a) {
+ var i;
+ var eq = true; // unless we can proove it
+ var aProperties = [], bProperties = []; // collection of
strings
+
+ // comparing constructors is more strict than using
instanceof
+ if ( a.constructor !== b.constructor) {
+ return false;
+ }
+
+ // stack constructor before traversing properties
+ callers.push(a.constructor);
+
+ for (i in a) { // be strict: don't ensures hasOwnProperty
and go deep
+
+ aProperties.push(i); // collect a's properties
+
+ if ( ! innerEquiv(a[i], b[i])) {
+ eq = false;
+ }
+ }
+
+ callers.pop(); // unstack, we are done
+
+ for (i in b) {
+ bProperties.push(i); // collect b's properties
+ }
+
+ // Ensures identical properties name
+ return eq && innerEquiv(aProperties.sort(),
bProperties.sort());
+ }
+ };
+ }();
+
+ innerEquiv = function () { // can take multiple arguments
+ var args = Array.prototype.slice.apply(arguments);
+ if (args.length < 2) {
+ return true; // end transition
+ }
+
+ return (function (a, b) {
+ if (a === b) {
+ return true; // catch the most you can
+
+ } else if (typeof a !== typeof b || a === null || b === null |
| typeof a === "undefined" || typeof b === "undefined") {
+ return false; // don't lose time with error prone cases
+
+ } else {
+ return bindCallbacks(a, callbacks, [b, a]);
+ }
+
+ // apply transition with (1..n) arguments
+ })(args[0], args[1]) && arguments.callee.apply(this,
args.splice(1, args.length -1));
+ };
+
+ return innerEquiv;
+}(); // equiv
+
+var GETParams = $.map( location.search.slice(1).split('&'),
decodeURIComponent ),
+ ngindex = $.inArray("noglobals", GETParams),
+ noglobals = ngindex !== -1;
+
+if( noglobals )
+ GETParams.splice( ngindex, 1 );
+
+var config = {
+ stats: {
+ all: 0,
+ bad: 0
+ },
+ queue: [],
+ // block until document ready
+ blocking: true,
+ //restrict modules/tests by get parameters
+ filters: GETParams,
+ isLocal: !!(window.location.protocol == 'file:')
+};
+
+// public API as global methods
+$.extend(window, {
+ test: test,
+ module: module,
+ expect: expect,
+ ok: ok,
+ equals: equals,
+ start: start,
+ stop: stop,
+ reset: reset,
+ isLocal: config.isLocal,
+ same: function(a, b, message) {
+ push(equiv(a, b), a, b, message);
+ },
+ QUnit: {
+ equiv: equiv
+ },
+ // legacy methods below
+ isSet: isSet,
+ isObj: isObj,
+ compare: function() {
+ throw "compare is deprecated - use same() instead";
+ },
+ compare2: function() {
+ throw "compare2 is deprecated - use same() instead";
+ },
+ serialArray: function() {
+ throw "serialArray is deprecated - use jsDump.parse() instead";
+ },
+ q: q,
+ t: t,
+ url: url,
+ triggerEvent: triggerEvent
+});
+
+$(window).load(function() {
+ $('#userAgent').html(navigator.userAgent);
+ var head = $('<div class="testrunner-toolbar"><label for="filter">Hide
passed tests</label></div>').insertAfter("#userAgent");
+ $('<input type="checkbox" id="filter" />').attr("disabled",
true).prependTo(head).click(function() {
+ $('li.pass')[this.checked ? 'hide' : 'show']();
+ });
+ runTest();
+});
+
+function synchronize(callback) {
+ config.queue.push(callback);
+ if(!config.blocking) {
+ process();
+ }
+}
+
+function process() {
+ while(config.queue.length && !config.blocking) {
+ config.queue.shift()();
+ }
+}
+
+function stop(timeout) {
+ config.blocking = true;
+ if (timeout)
+ config.timeout = setTimeout(function() {
+ ok( false, "Test timed out" );
+ start();
+ }, timeout);
+}
+function start() {
+ // A slight delay, to avoid any current callbacks
+ setTimeout(function() {
+ if(config.timeout)
+ clearTimeout(config.timeout);
+ config.blocking = false;
+ process();
+ }, 13);
+}
+
+function validTest( name ) {
+ var i = config.filters.length,
+ run = false;
+
+ if( !i )
+ return true;
+
+ while( i-- ){
+ var filter = config.filters[i],
+ not = filter.charAt(0) == '!';
+ if( not )
+ filter = filter.slice(1);
+ if( name.indexOf(filter) != -1 )
+ return !not;
+ if( not )
+ run = true;
+ }
+ return run;
+}
+
+function runTest() {
+ config.blocking = false;
+ var started = +new Date;
+ config.fixture = document.getElementById('main').innerHTML;
+ config.ajaxSettings = $.ajaxSettings;
+ synchronize(function() {
+ $('<p id="testresult" class="result"/>').html(['Tests completed in ',
+ +new Date - started, ' milliseconds.<br/>',
+ '<span class="bad">', config.stats.bad, '</span> tests of <span
class="all">', config.stats.all, '</span> failed.']
+ .join(''))
+ .appendTo("body");
+ $("#banner").addClass(config.stats.bad ? "fail" : "pass");
+ });
+}
+
+var pollution;
+
+function saveGlobal(){
+ pollution = [ ];
+
+ if( noglobals )
+ for( var key in window )
+ pollution.push(key);
+}
+function checkPollution( name ){
+ var old = pollution;
+ saveGlobal();
+
+ if( pollution.length > old.length ){
+ ok( false, "Introduced global variable(s): " + diff(old,
pollution).join(", ") );
+ config.expected++;
+ }
+}
+
+function diff( clean, dirty ){
+ return $.grep( dirty, function(name){
+ return $.inArray( name, clean ) == -1;
+ });
+}
+
+function test(name, callback) {
+ if(config.currentModule)
+ name = config.currentModule + " module: " + name;
+ var lifecycle = $.extend({
+ setup: function() {},
+ teardown: function() {}
+ }, config.moduleLifecycle);
+
+ if ( !validTest(name) )
+ return;
+
+ synchronize(function() {
+ config.assertions = [];
+ config.expected = null;
+ try {
+ if( !pollution )
+ saveGlobal();
+ lifecycle.setup();
+ } catch(e) {
+ config.assertions.push( {
+ result: false,
+ message: "Setup failed on " + name + ": " + e.message
+ });
+ }
+ })
+ synchronize(function() {
+ try {
+ callback();
+ } catch(e) {
+ if( typeof console != "undefined" && console.error && console.warn ) {
+ console.error("Test " + name + " died, exception and test follows");
+ console.error(e);
+ console.warn(callback.toString());
+ }
+ config.assertions.push( {
+ result: false,
+ message: "Died on test #" + (config.assertions.length + 1) + ": " +
e.message
+ });
+ // else next test will carry the responsibility
+ saveGlobal();
+ }
+ });
+ synchronize(function() {
+ try {
+ checkPollution();
+ lifecycle.teardown();
+ } catch(e) {
+ config.assertions.push( {
+ result: false,
+ message: "Teardown failed on " + name + ": " + e.message
+ });
+ }
+ })
+ synchronize(function() {
+ try {
+ reset();
+ } catch(e) {
+ if( typeof console != "undefined" && console.error && console.warn ) {
+ console.error("reset() failed, following Test " + name + ", exception
and reset fn follows");
+ console.error(e);
+ console.warn(reset.toString());
+ }
+ }
+
+ if(config.expected && config.expected != config.assertions.length) {
+ config.assertions.push({
+ result: false,
+ message: "Expected " + config.expected + " assertions, but " +
config.assertions.length + " were run"
+ });
+ }
+
+ var good = 0, bad = 0;
+ var ol = $("<ol/>").hide();
+ config.stats.all += config.assertions.length;
+ for ( var i = 0; i < config.assertions.length; i++ ) {
+ var assertion = config.assertions[i];
+
$("<li/>").addClass(assertion.result ? "pass" : "fail").text(assertion.message
|| "(no message)").appendTo(ol);
+ assertion.result ? good++ : bad++;
+ }
+ config.stats.bad += bad;
+
+ var b = $("<strong/>").html(name + " <b style='color:black;'>(<b
class='fail'>" + bad + "</b>, <b class='pass'>" + good + "</b>, " +
config.assertions.length + ")</b>")
+ .click(function(){
+ $(this).next().toggle();
+ })
+ .dblclick(function(event) {
+ var target = $(event.target).filter("strong").clone();
+ if ( target.length ) {
+ target.children().remove();
+ location.href = location.href.match(/^(.+?)(\?.*)?$/)[1] + "?" +
encodeURIComponent($.trim(target.text()));
+ }
+ });
+
+
$("<li/>").addClass(bad ? "fail" : "pass").append(b).append(ol).appendTo("#tests");
+
+ if(bad) {
+ $("#filter").attr("disabled", null);
+ }
+ });
+}
+
+// call on start of module test to prepend name to all tests
+function module(name, lifecycle) {
+ config.currentModule = name;
+ config.moduleLifecycle = lifecycle;
+}
+
+/**
+ * Specify the number of expected assertions to gurantee that failed test
(no assertions are run at all) don't slip through.
+ */
+function expect(asserts) {
+ config.expected = asserts;
+}
+
+/**
+ * Resets the test setup. Useful for tests that modify the DOM.
+ */
+function reset() {
+ $("#main").html( config.fixture );
+ $.event.global = {};
+ $.ajaxSettings = $.extend({}, config.ajaxSettings);
+}
+
+/**
+ * Asserts true.
+ * @example ok( $("a").size() > 5, "There must be at least 5 anchors" );
+ */
+function ok(a, msg) {
+ config.assertions.push({
+ result: !!a,
+ message: msg
+ });
+}
+
+/**
+ * Asserts that two arrays are the same
+ */
+function isSet(a, b, msg) {
+ function serialArray( a ) {
+ var r = [];
+
+ if ( a && a.length )
+ for ( var i = 0; i < a.length; i++ ) {
+ var str = a[i].nodeName;
+ if ( str ) {
+ str = str.toLowerCase();
+ if ( a[i].id )
+ str += "#" + a[i].id;
+ } else
+ str = a[i];
+ r.push( str );
+ }
+
+ return "[ " + r.join(", ") + " ]";
+ }
+ var ret = true;
+ if ( a && b && a.length != undefined && a.length == b.length ) {
+ for ( var i = 0; i < a.length; i++ )
+ if ( a[i] != b[i] )
+ ret = false;
+ } else
+ ret = false;
+ config.assertions.push({
+ result: ret,
+ message: !ret ? (msg + " expected: " + serialArray(b) + " result: " +
serialArray(a)) : msg
+ });
+}
+
+/**
+ * Asserts that two objects are equivalent
+ */
+function isObj(a, b, msg) {
+ var ret = true;
+
+ if ( a && b ) {
+ for ( var i in a )
+ if ( a[i] != b[i] )
+ ret = false;
+
+ for ( i in b )
+ if ( a[i] != b[i] )
+ ret = false;
+ } else
+ ret = false;
+
+ config.assertions.push({
+ result: ret,
+ message: msg
+ });
+}
+
+/**
+ * Returns an array of elements with the given IDs, eg.
+ * @example q("main", "foo", "bar")
+ * @result [<div id="main">, <span id="foo">, <input id="bar">]
+ */
+function