+++ /dev/null
-/*\r
- * QUnit - jQuery unit testrunner\r
- * \r
- * http://docs.jquery.com/QUnit\r
- *\r
- * Copyright (c) 2008 John Resig, Jörn Zaefferer\r
- * Dual licensed under the MIT (MIT-LICENSE.txt)\r
- * and GPL (GPL-LICENSE.txt) licenses.\r
- *\r
- * $Id: testrunner.js 6343 2009-05-06 15:09:22Z joern.zaefferer $\r
- */\r
-\r
-(function($) {\r
-\r
-// Tests for equality any JavaScript type and structure without unexpected results.\r
-// Discussions and reference: http://philrathe.com/articles/equiv\r
-// Test suites: http://philrathe.com/tests/equiv\r
-// Author: Philippe Rathé <prathe@gmail.com>\r
-var equiv = function () {\r
-\r
- var innerEquiv; // the real equiv function\r
- var callers = []; // stack to decide between skip/abort functions\r
-\r
- // Determine what is o.\r
- function hoozit(o) {\r
- if (typeof o === "string") {\r
- return "string";\r
-\r
- } else if (typeof o === "boolean") {\r
- return "boolean";\r
-\r
- } else if (typeof o === "number") {\r
-\r
- if (isNaN(o)) {\r
- return "nan";\r
- } else {\r
- return "number";\r
- }\r
-\r
- } else if (typeof o === "undefined") {\r
- return "undefined";\r
-\r
- // consider: typeof null === object\r
- } else if (o === null) {\r
- return "null";\r
-\r
- // consider: typeof [] === object\r
- } else if (o instanceof Array) {\r
- return "array";\r
- \r
- // consider: typeof new Date() === object\r
- } else if (o instanceof Date) {\r
- return "date";\r
-\r
- // consider: /./ instanceof Object;\r
- // /./ instanceof RegExp;\r
- // typeof /./ === "function"; // => false in IE and Opera,\r
- // true in FF and Safari\r
- } else if (o instanceof RegExp) {\r
- return "regexp";\r
-\r
- } else if (typeof o === "object") {\r
- return "object";\r
-\r
- } else if (o instanceof Function) {\r
- return "function";\r
- }\r
- }\r
-\r
- // Call the o related callback with the given arguments.\r
- function bindCallbacks(o, callbacks, args) {\r
- var prop = hoozit(o);\r
- if (prop) {\r
- if (hoozit(callbacks[prop]) === "function") {\r
- return callbacks[prop].apply(callbacks, args);\r
- } else {\r
- return callbacks[prop]; // or undefined\r
- }\r
- }\r
- }\r
-\r
- var callbacks = function () {\r
-\r
- // for string, boolean, number and null\r
- function useStrictEquality(b, a) {\r
- return a === b;\r
- }\r
-\r
- return {\r
- "string": useStrictEquality,\r
- "boolean": useStrictEquality,\r
- "number": useStrictEquality,\r
- "null": useStrictEquality,\r
- "undefined": useStrictEquality,\r
-\r
- "nan": function (b) {\r
- return isNaN(b);\r
- },\r
-\r
- "date": function (b, a) {\r
- return hoozit(b) === "date" && a.valueOf() === b.valueOf();\r
- },\r
-\r
- "regexp": function (b, a) {\r
- return hoozit(b) === "regexp" &&\r
- a.source === b.source && // the regex itself\r
- a.global === b.global && // and its modifers (gmi) ...\r
- a.ignoreCase === b.ignoreCase &&\r
- a.multiline === b.multiline;\r
- },\r
-\r
- // - skip when the property is a method of an instance (OOP)\r
- // - abort otherwise,\r
- // initial === would have catch identical references anyway\r
- "function": function () {\r
- var caller = callers[callers.length - 1];\r
- return caller !== Object &&\r
- typeof caller !== "undefined";\r
- },\r
-\r
- "array": function (b, a) {\r
- var i;\r
- var len;\r
-\r
- // b could be an object literal here\r
- if ( ! (hoozit(b) === "array")) {\r
- return false;\r
- }\r
-\r
- len = a.length;\r
- if (len !== b.length) { // safe and faster\r
- return false;\r
- }\r
- for (i = 0; i < len; i++) {\r
- if( ! innerEquiv(a[i], b[i])) {\r
- return false;\r
- }\r
- }\r
- return true;\r
- },\r
-\r
- "object": function (b, a) {\r
- var i;\r
- var eq = true; // unless we can proove it\r
- var aProperties = [], bProperties = []; // collection of strings\r
-\r
- // comparing constructors is more strict than using instanceof\r
- if ( a.constructor !== b.constructor) {\r
- return false;\r
- }\r
-\r
- // stack constructor before traversing properties\r
- callers.push(a.constructor);\r
-\r
- for (i in a) { // be strict: don't ensures hasOwnProperty and go deep\r
-\r
- aProperties.push(i); // collect a's properties\r
-\r
- if ( ! innerEquiv(a[i], b[i])) {\r
- eq = false;\r
- }\r
- }\r
-\r
- callers.pop(); // unstack, we are done\r
-\r
- for (i in b) {\r
- bProperties.push(i); // collect b's properties\r
- }\r
-\r
- // Ensures identical properties name\r
- return eq && innerEquiv(aProperties.sort(), bProperties.sort());\r
- }\r
- };\r
- }();\r
-\r
- innerEquiv = function () { // can take multiple arguments\r
- var args = Array.prototype.slice.apply(arguments);\r
- if (args.length < 2) {\r
- return true; // end transition\r
- }\r
-\r
- return (function (a, b) {\r
- if (a === b) {\r
- return true; // catch the most you can\r
-\r
- } else if (typeof a !== typeof b || a === null || b === null || typeof a === "undefined" || typeof b === "undefined") {\r
- return false; // don't lose time with error prone cases\r
-\r
- } else {\r
- return bindCallbacks(a, callbacks, [b, a]);\r
- }\r
-\r
- // apply transition with (1..n) arguments\r
- })(args[0], args[1]) && arguments.callee.apply(this, args.splice(1, args.length -1));\r
- };\r
-\r
- return innerEquiv;\r
-}(); // equiv\r
-\r
-var GETParams = $.map( location.search.slice(1).split('&'), decodeURIComponent ),\r
- ngindex = $.inArray("noglobals", GETParams),\r
- noglobals = ngindex !== -1;\r
-\r
-if( noglobals )\r
- GETParams.splice( ngindex, 1 );\r
- \r
-var config = {\r
- stats: {\r
- all: 0,\r
- bad: 0\r
- },\r
- queue: [],\r
- // block until document ready\r
- blocking: true,\r
- //restrict modules/tests by get parameters\r
- filters: GETParams,\r
- isLocal: !!(window.location.protocol == 'file:')\r
-};\r
-\r
-// public API as global methods\r
-$.extend(window, {\r
- test: test,\r
- module: module,\r
- expect: expect,\r
- ok: ok,\r
- equals: equals,\r
- start: start,\r
- stop: stop,\r
- reset: reset,\r
- isLocal: config.isLocal,\r
- same: function(a, b, message) {\r
- push(equiv(a, b), a, b, message);\r
- },\r
- QUnit: {\r
- equiv: equiv,\r
- ok: ok,\r
- done: function(failures, total){},\r
- log: function(result, message){}\r
- },\r
- // legacy methods below\r
- isSet: isSet,\r
- isObj: isObj,\r
- compare: function() {\r
- throw "compare is deprecated - use same() instead";\r
- },\r
- compare2: function() {\r
- throw "compare2 is deprecated - use same() instead";\r
- },\r
- serialArray: function() {\r
- throw "serialArray is deprecated - use jsDump.parse() instead";\r
- },\r
- q: q,\r
- t: t,\r
- url: url,\r
- triggerEvent: triggerEvent\r
-});\r
-\r
-$(window).load(function() {\r
- \r
- if (!$("#header, #banner, #userAgent, #tests").length) {\r
- $('body').prepend(\r
- '<h1 id="header">' + document.title + '</h1>' +\r
- '<h2 id="banner"></h2>' +\r
- '<h2 id="userAgent"></h2>' +\r
- '<ol id="tests"></ol>'\r
- );\r
- }\r
- \r
- $('#userAgent').html(navigator.userAgent);\r
- var head = $('<div class="testrunner-toolbar"><label for="filter-pass">Hide passed tests</label></div>').insertAfter("#userAgent");\r
- $('<input type="checkbox" id="filter-pass" />').attr("disabled", true).prependTo(head).click(function() {\r
- $('li.pass')[this.checked ? 'hide' : 'show']();\r
- });\r
- $('<input type="checkbox" id="filter-missing">').attr("disabled", true).appendTo(head).click(function() {\r
- $("li.fail:contains('missing test - untested code is broken code')").parent('ol').parent('li.fail')[this.checked ? 'hide' : 'show']();\r
- });\r
- $("#filter-missing").after('<label for="filter-missing">Hide missing tests (untested code is broken code)</label>');\r
- runTest(); \r
-});\r
-\r
-function synchronize(callback) {\r
- config.queue.push(callback);\r
- if(!config.blocking) {\r
- process();\r
- }\r
-}\r
-\r
-function process() {\r
- while(config.queue.length && !config.blocking) {\r
- config.queue.shift()();\r
- }\r
-}\r
-\r
-function stop(timeout) {\r
- config.blocking = true;\r
- if (timeout)\r
- config.timeout = setTimeout(function() {\r
- QUnit.ok( false, "Test timed out" );\r
- start();\r
- }, timeout);\r
-}\r
-function start() {\r
- // A slight delay, to avoid any current callbacks\r
- setTimeout(function() {\r
- if(config.timeout)\r
- clearTimeout(config.timeout);\r
- config.blocking = false;\r
- process();\r
- }, 13);\r
-}\r
-\r
-function validTest( name ) {\r
- var i = config.filters.length,\r
- run = false;\r
-\r
- if( !i )\r
- return true;\r
- \r
- while( i-- ){\r
- var filter = config.filters[i],\r
- not = filter.charAt(0) == '!';\r
- if( not ) \r
- filter = filter.slice(1);\r
- if( name.indexOf(filter) != -1 )\r
- return !not;\r
- if( not )\r
- run = true;\r
- }\r
- return run;\r
-}\r
-\r
-function runTest() {\r
- config.blocking = false;\r
- var started = +new Date;\r
- config.fixture = document.getElementById('main').innerHTML;\r
- config.ajaxSettings = $.ajaxSettings;\r
- synchronize(function() {\r
- $('<p id="testresult" class="result"/>').html(['Tests completed in ',\r
- +new Date - started, ' milliseconds.<br/>',\r
- '<span class="bad">', config.stats.bad, '</span> tests of <span class="all">', config.stats.all, '</span> failed.']\r
- .join(''))\r
- .appendTo("body");\r
- $("#banner").addClass(config.stats.bad ? "fail" : "pass");\r
- QUnit.done( config.stats.bad, config.stats.all );\r
- });\r
-}\r
-\r
-var pollution;\r
-\r
-function saveGlobal(){\r
- pollution = [ ];\r
- \r
- if( noglobals )\r
- for( var key in window )\r
- pollution.push(key);\r
-}\r
-function checkPollution( name ){\r
- var old = pollution;\r
- saveGlobal();\r
- \r
- if( pollution.length > old.length ){\r
- ok( false, "Introduced global variable(s): " + diff(old, pollution).join(", ") );\r
- config.expected++;\r
- }\r
-}\r
-\r
-function diff( clean, dirty ){\r
- return $.grep( dirty, function(name){\r
- return $.inArray( name, clean ) == -1;\r
- });\r
-}\r
-\r
-function test(name, callback) {\r
- if(config.currentModule)\r
- name = config.currentModule + " module: <span>" + name + "</span>";\r
- var lifecycle = $.extend({\r
- setup: function() {},\r
- teardown: function() {}\r
- }, config.moduleLifecycle);\r
- \r
- if ( !validTest(name) )\r
- return;\r
- \r
- synchronize(function() {\r
- config.assertions = [];\r
- config.expected = null;\r
- try {\r
- if( !pollution )\r
- saveGlobal();\r
- lifecycle.setup();\r
- } catch(e) {\r
- QUnit.ok( false, "Setup failed on " + name + ": " + e.message );\r
- }\r
- })\r
- synchronize(function() {\r
- try {\r
- callback();\r
- } catch(e) {\r
- if( typeof console != "undefined" && console.error && console.warn ) {\r
- console.error("Test " + name + " died, exception and test follows");\r
- console.error(e);\r
- console.warn(callback.toString());\r
- }\r
- QUnit.ok( false, "Died on test #" + (config.assertions.length + 1) + ": " + e.message );\r
- // else next test will carry the responsibility\r
- saveGlobal();\r
- }\r
- });\r
- synchronize(function() {\r
- try {\r
- checkPollution();\r
- lifecycle.teardown();\r
- } catch(e) {\r
- QUnit.ok( false, "Teardown failed on " + name + ": " + e.message );\r
- }\r
- })\r
- synchronize(function() {\r
- try {\r
- reset();\r
- } catch(e) {\r
- if( typeof console != "undefined" && console.error && console.warn ) {\r
- console.error("reset() failed, following Test " + name + ", exception and reset fn follows");\r
- console.error(e);\r
- console.warn(reset.toString());\r
- }\r
- }\r
- \r
- if(config.expected && config.expected != config.assertions.length) {\r
- QUnit.ok( false, "Expected " + config.expected + " assertions, but " + config.assertions.length + " were run" );\r
- }\r
- \r
- var good = 0, bad = 0;\r
- var ol = $("<ol/>").hide();\r
- config.stats.all += config.assertions.length;\r
- for ( var i = 0; i < config.assertions.length; i++ ) {\r
- var assertion = config.assertions[i];\r
- $("<li/>").addClass(assertion.result ? "pass" : "fail").text(assertion.message || "(no message)").appendTo(ol);\r
- assertion.result ? good++ : bad++;\r
- }\r
- config.stats.bad += bad;\r
- \r
- var b = $("<strong/>").html(name + " <b style='color:black;'>(<b class='fail'>" + bad + "</b>, <b class='pass'>" + good + "</b>, " + config.assertions.length + ")</b>")\r
- .click(function(){\r
- $(this).next().toggle();\r
- })\r
- .dblclick(function(event) {\r
- var target = $(event.target).filter("strong").clone();\r
- if ( target.length ) {\r
- target.children().remove();\r
- location.href = location.href.match(/^(.+?)(\?.*)?$/)[1] + "?" + encodeURIComponent($.trim(target.text()));\r
- }\r
- });\r
- \r
- $("<li/>").addClass(bad ? "fail" : "pass").append(b).append(ol).appendTo("#tests");\r
- \r
- if(bad) {\r
- $("#filter-pass").attr("disabled", null);\r
- $("#filter-missing").attr("disabled", null);\r
- }\r
- });\r
-}\r
-\r
-// call on start of module test to prepend name to all tests\r
-function module(name, lifecycle) {\r
- config.currentModule = name;\r
- config.moduleLifecycle = lifecycle;\r
-}\r
-\r
-/**\r
- * Specify the number of expected assertions to gurantee that failed test (no assertions are run at all) don't slip through.\r
- */\r
-function expect(asserts) {\r
- config.expected = asserts;\r
-}\r
-\r
-/**\r
- * Resets the test setup. Useful for tests that modify the DOM.\r
- */\r
-function reset() {\r
- $("#main").html( config.fixture );\r
- $.event.global = {};\r
- $.ajaxSettings = $.extend({}, config.ajaxSettings);\r
-}\r
-\r
-/**\r
- * Asserts true.\r
- * @example ok( $("a").size() > 5, "There must be at least 5 anchors" );\r
- */\r
-function ok(a, msg) {\r
- QUnit.log(a, msg);\r
-\r
- config.assertions.push({\r
- result: !!a,\r
- message: msg\r
- });\r
-}\r
-\r
-/**\r
- * Asserts that two arrays are the same\r
- */\r
-function isSet(a, b, msg) {\r
- function serialArray( a ) {\r
- var r = [];\r
- \r
- if ( a && a.length )\r
- for ( var i = 0; i < a.length; i++ ) {\r
- var str = a[i].nodeName;\r
- if ( str ) {\r
- str = str.toLowerCase();\r
- if ( a[i].id )\r
- str += "#" + a[i].id;\r
- } else\r
- str = a[i];\r
- r.push( str );\r
- }\r
- \r
- return "[ " + r.join(", ") + " ]";\r
- }\r
- var ret = true;\r
- if ( a && b && a.length != undefined && a.length == b.length ) {\r
- for ( var i = 0; i < a.length; i++ )\r
- if ( a[i] != b[i] )\r
- ret = false;\r
- } else\r
- ret = false;\r
- QUnit.ok( ret, !ret ? (msg + " expected: " + serialArray(b) + " result: " + serialArray(a)) : msg );\r
-}\r
-\r
-/**\r
- * Asserts that two objects are equivalent\r
- */\r
-function isObj(a, b, msg) {\r
- var ret = true;\r
- \r
- if ( a && b ) {\r
- for ( var i in a )\r
- if ( a[i] != b[i] )\r
- ret = false;\r
-\r
- for ( i in b )\r
- if ( a[i] != b[i] )\r
- ret = false;\r
- } else\r
- ret = false;\r
-\r
- QUnit.ok( ret, msg );\r
-}\r
-\r
-/**\r
- * Returns an array of elements with the given IDs, eg.\r
- * @example q("main", "foo", "bar")\r
- * @result [<div id="main">, <span id="foo">, <input id="bar">]\r
- */\r
-function q() {\r
- var r = [];\r
- for ( var i = 0; i < arguments.length; i++ )\r
- r.push( document.getElementById( arguments[i] ) );\r
- return r;\r
-}\r
-\r
-/**\r
- * Asserts that a select matches the given IDs\r
- * @example t("Check for something", "//[a]", ["foo", "baar"]);\r
- * @result returns true if "//[a]" return two elements with the IDs 'foo' and 'baar'\r
- */\r
-function t(a,b,c) {\r
- var f = $(b);\r
- var s = "";\r
- for ( var i = 0; i < f.length; i++ )\r
- s += (s && ",") + '"' + f[i].id + '"';\r
- isSet(f, q.apply(q,c), a + " (" + b + ")");\r
-}\r
-\r
-/**\r
- * Add random number to url to stop IE from caching\r
- *\r
- * @example url("data/test.html")\r
- * @result "data/test.html?10538358428943"\r
- *\r
- * @example url("data/test.php?foo=bar")\r
- * @result "data/test.php?foo=bar&10538358345554"\r
- */\r
-function url(value) {\r
- return value + (/\?/.test(value) ? "&" : "?") + new Date().getTime() + "" + parseInt(Math.random()*100000);\r
-}\r
-\r
-/**\r
- * Checks that the first two arguments are equal, with an optional message.\r
- * Prints out both actual and expected values.\r
- *\r
- * Prefered to ok( actual == expected, message )\r
- *\r
- * @example equals( $.format("Received {0} bytes.", 2), "Received 2 bytes." );\r
- *\r
- * @param Object actual\r
- * @param Object expected\r
- * @param String message (optional)\r
- */\r
-function equals(actual, expected, message) {\r
- push(expected == actual, actual, expected, message);\r
-}\r
-\r
-function push(result, actual, expected, message) {\r
- message = message || (result ? "okay" : "failed");\r
- QUnit.ok( result, result ? message + ": " + expected : message + ", expected: " + jsDump.parse(expected) + " result: " + jsDump.parse(actual) );\r
-}\r
-\r
-/**\r
- * Trigger an event on an element.\r
- *\r
- * @example triggerEvent( document.body, "click" );\r
- *\r
- * @param DOMElement elem\r
- * @param String type\r
- */\r
-function triggerEvent( elem, type, event ) {\r
- if ( $.browser.mozilla || $.browser.opera ) {\r
- event = document.createEvent("MouseEvents");\r
- event.initMouseEvent(type, true, true, elem.ownerDocument.defaultView,\r
- 0, 0, 0, 0, 0, false, false, false, false, 0, null);\r
- elem.dispatchEvent( event );\r
- } else if ( $.browser.msie ) {\r
- elem.fireEvent("on"+type);\r
- }\r
-}\r
-\r
-})(jQuery);\r
-\r
-/**\r
- * jsDump\r
- * Copyright (c) 2008 Ariel Flesler - aflesler(at)gmail(dot)com | http://flesler.blogspot.com\r
- * Licensed under BSD (http://www.opensource.org/licenses/bsd-license.php)\r
- * Date: 5/15/2008\r
- * @projectDescription Advanced and extensible data dumping for Javascript.\r
- * @version 1.0.0\r
- * @author Ariel Flesler\r
- * @link {http://flesler.blogspot.com/2008/05/jsdump-pretty-dump-of-any-javascript.html}\r
- */\r
-(function(){\r
- function quote( str ){\r
- return '"' + str.toString().replace(/"/g, '\\"') + '"';\r
- };\r
- function literal( o ){\r
- return o + ''; \r
- };\r
- function join( pre, arr, post ){\r
- var s = jsDump.separator(),\r
- base = jsDump.indent();\r
- inner = jsDump.indent(1);\r
- if( arr.join )\r
- arr = arr.join( ',' + s + inner );\r
- if( !arr )\r
- return pre + post;\r
- return [ pre, inner + arr, base + post ].join(s);\r
- };\r
- function array( arr ){\r
- var i = arr.length, ret = Array(i); \r
- this.up();\r
- while( i-- )\r
- ret[i] = this.parse( arr[i] ); \r
- this.down();\r
- return join( '[', ret, ']' );\r
- };\r
- \r
- var reName = /^function (\w+)/;\r
- \r
- var jsDump = window.jsDump = {\r
- parse:function( obj, type ){//type is used mostly internally, you can fix a (custom)type in advance\r
- var parser = this.parsers[ type || this.typeOf(obj) ];\r
- type = typeof parser; \r
- \r
- return type == 'function' ? parser.call( this, obj ) :\r
- type == 'string' ? parser :\r
- this.parsers.error;\r
- },\r
- typeOf:function( obj ){\r
- var type = typeof obj,\r
- f = 'function';//we'll use it 3 times, save it\r
- return type != 'object' && type != f ? type :\r
- !obj ? 'null' :\r
- obj.exec ? 'regexp' :// some browsers (FF) consider regexps functions\r
- obj.getHours ? 'date' :\r
- obj.scrollBy ? 'window' :\r
- obj.nodeName == '#document' ? 'document' :\r
- obj.nodeName ? 'node' :\r
- obj.item ? 'nodelist' : // Safari reports nodelists as functions\r
- obj.callee ? 'arguments' :\r
- obj.call || obj.constructor != Array && //an array would also fall on this hack\r
- (obj+'').indexOf(f) != -1 ? f : //IE reports functions like alert, as objects\r
- 'length' in obj ? 'array' :\r
- type;\r
- },\r
- separator:function(){\r
- return this.multiline ? this.HTML ? '<br />' : '\n' : this.HTML ? ' ' : ' ';\r
- },\r
- indent:function( extra ){// extra can be a number, shortcut for increasing-calling-decreasing\r
- if( !this.multiline )\r
- return '';\r
- var chr = this.indentChar;\r
- if( this.HTML )\r
- chr = chr.replace(/\t/g,' ').replace(/ /g,' ');\r
- return Array( this._depth_ + (extra||0) ).join(chr);\r
- },\r
- up:function( a ){\r
- this._depth_ += a || 1;\r
- },\r
- down:function( a ){\r
- this._depth_ -= a || 1;\r
- },\r
- setParser:function( name, parser ){\r
- this.parsers[name] = parser;\r
- },\r
- // The next 3 are exposed so you can use them\r
- quote:quote, \r
- literal:literal,\r
- join:join,\r
- //\r
- _depth_: 1,\r
- // This is the list of parsers, to modify them, use jsDump.setParser\r
- parsers:{\r
- window: '[Window]',\r
- document: '[Document]',\r
- error:'[ERROR]', //when no parser is found, shouldn't happen\r
- unknown: '[Unknown]',\r
- 'null':'null',\r
- undefined:'undefined',\r
- 'function':function( fn ){\r
- var ret = 'function',\r
- name = 'name' in fn ? fn.name : (reName.exec(fn)||[])[1];//functions never have name in IE\r
- if( name )\r
- ret += ' ' + name;\r
- ret += '(';\r
- \r
- ret = [ ret, this.parse( fn, 'functionArgs' ), '){'].join('');\r
- return join( ret, this.parse(fn,'functionCode'), '}' );\r
- },\r
- array: array,\r
- nodelist: array,\r
- arguments: array,\r
- object:function( map ){\r
- var ret = [ ];\r
- this.up();\r
- for( var key in map )\r
- ret.push( this.parse(key,'key') + ': ' + this.parse(map[key]) );\r
- this.down();\r
- return join( '{', ret, '}' );\r
- },\r
- node:function( node ){\r
- var open = this.HTML ? '<' : '<',\r
- close = this.HTML ? '>' : '>';\r
- \r
- var tag = node.nodeName.toLowerCase(),\r
- ret = open + tag;\r
- \r
- for( var a in this.DOMAttrs ){\r
- var val = node[this.DOMAttrs[a]];\r
- if( val )\r
- ret += ' ' + a + '=' + this.parse( val, 'attribute' );\r
- }\r
- return ret + close + open + '/' + tag + close;\r
- },\r
- functionArgs:function( fn ){//function calls it internally, it's the arguments part of the function\r
- var l = fn.length;\r
- if( !l ) return ''; \r
- \r
- var args = Array(l);\r
- while( l-- )\r
- args[l] = String.fromCharCode(97+l);//97 is 'a'\r
- return ' ' + args.join(', ') + ' ';\r
- },\r
- key:quote, //object calls it internally, the key part of an item in a map\r
- functionCode:'[code]', //function calls it internally, it's the content of the function\r
- attribute:quote, //node calls it internally, it's an html attribute value\r
- string:quote,\r
- date:quote,\r
- regexp:literal, //regex\r
- number:literal,\r
- 'boolean':literal\r
- },\r
- DOMAttrs:{//attributes to dump from nodes, name=>realName\r
- id:'id',\r
- name:'name',\r
- 'class':'className'\r
- },\r
- HTML:false,//if true, entities are escaped ( <, >, \t, space and \n )\r
- indentChar:' ',//indentation unit\r
- multiline:true //if true, items in a collection, are separated by a \n, else just a space.\r
- };\r
-\r
-})();\r
--- /dev/null
+/*\r
+ * QUnit - jQuery unit testrunner\r
+ * \r
+ * http://docs.jquery.com/QUnit\r
+ *\r
+ * Copyright (c) 2008 John Resig, Jörn Zaefferer\r
+ * Dual licensed under the MIT (MIT-LICENSE.txt)\r
+ * and GPL (GPL-LICENSE.txt) licenses.\r
+ *\r
+ * $Id: testrunner.js 6416 2009-07-10 16:08:27Z joern.zaefferer $\r
+ */\r
+\r
+(function($) {\r
+\r
+// Test for equality any JavaScript type.\r
+// Discussions and reference: http://philrathe.com/articles/equiv\r
+// Test suites: http://philrathe.com/tests/equiv\r
+// Author: Philippe Rathé <prathe@gmail.com>\r
+var equiv = function () {\r
+\r
+ var innerEquiv; // the real equiv function\r
+ var callers = []; // stack to decide between skip/abort functions\r
+\r
+\r
+ // Determine what is o.\r
+ function hoozit(o) {\r
+ if (o.constructor === String) {\r
+ return "string";\r
+ \r
+ } else if (o.constructor === Boolean) {\r
+ return "boolean";\r
+\r
+ } else if (o.constructor === Number) {\r
+\r
+ if (isNaN(o)) {\r
+ return "nan";\r
+ } else {\r
+ return "number";\r
+ }\r
+\r
+ } else if (typeof o === "undefined") {\r
+ return "undefined";\r
+\r
+ // consider: typeof null === object\r
+ } else if (o === null) {\r
+ return "null";\r
+\r
+ // consider: typeof [] === object\r
+ } else if (o instanceof Array) {\r
+ return "array";\r
+ \r
+ // consider: typeof new Date() === object\r
+ } else if (o instanceof Date) {\r
+ return "date";\r
+\r
+ // consider: /./ instanceof Object;\r
+ // /./ instanceof RegExp;\r
+ // typeof /./ === "function"; // => false in IE and Opera,\r
+ // true in FF and Safari\r
+ } else if (o instanceof RegExp) {\r
+ return "regexp";\r
+\r
+ } else if (typeof o === "object") {\r
+ return "object";\r
+\r
+ } else if (o instanceof Function) {\r
+ return "function";\r
+ } else {\r
+ return undefined;\r
+ }\r
+ }\r
+\r
+ // Call the o related callback with the given arguments.\r
+ function bindCallbacks(o, callbacks, args) {\r
+ var prop = hoozit(o);\r
+ if (prop) {\r
+ if (hoozit(callbacks[prop]) === "function") {\r
+ return callbacks[prop].apply(callbacks, args);\r
+ } else {\r
+ return callbacks[prop]; // or undefined\r
+ }\r
+ }\r
+ }\r
+ \r
+ var callbacks = function () {\r
+\r
+ // for string, boolean, number and null\r
+ function useStrictEquality(b, a) {\r
+ if (b instanceof a.constructor || a instanceof b.constructor) {\r
+ // to catch short annotaion VS 'new' annotation of a declaration\r
+ // e.g. var i = 1;\r
+ // var j = new Number(1);\r
+ return a == b;\r
+ } else {\r
+ return a === b;\r
+ }\r
+ }\r
+\r
+ return {\r
+ "string": useStrictEquality,\r
+ "boolean": useStrictEquality,\r
+ "number": useStrictEquality,\r
+ "null": useStrictEquality,\r
+ "undefined": useStrictEquality,\r
+\r
+ "nan": function (b) {\r
+ return isNaN(b);\r
+ },\r
+\r
+ "date": function (b, a) {\r
+ return hoozit(b) === "date" && a.valueOf() === b.valueOf();\r
+ },\r
+\r
+ "regexp": function (b, a) {\r
+ return hoozit(b) === "regexp" &&\r
+ a.source === b.source && // the regex itself\r
+ a.global === b.global && // and its modifers (gmi) ...\r
+ a.ignoreCase === b.ignoreCase &&\r
+ a.multiline === b.multiline;\r
+ },\r
+\r
+ // - skip when the property is a method of an instance (OOP)\r
+ // - abort otherwise,\r
+ // initial === would have catch identical references anyway\r
+ "function": function () {\r
+ var caller = callers[callers.length - 1];\r
+ return caller !== Object &&\r
+ typeof caller !== "undefined";\r
+ },\r
+\r
+ "array": function (b, a) {\r
+ var i;\r
+ var len;\r
+\r
+ // b could be an object literal here\r
+ if ( ! (hoozit(b) === "array")) {\r
+ return false;\r
+ }\r
+\r
+ len = a.length;\r
+ if (len !== b.length) { // safe and faster\r
+ return false;\r
+ }\r
+ for (i = 0; i < len; i++) {\r
+ if( ! innerEquiv(a[i], b[i])) {\r
+ return false;\r
+ }\r
+ }\r
+ return true;\r
+ },\r
+\r
+ "object": function (b, a) {\r
+ var i;\r
+ var eq = true; // unless we can proove it\r
+ var aProperties = [], bProperties = []; // collection of strings\r
+\r
+ // comparing constructors is more strict than using instanceof\r
+ if ( a.constructor !== b.constructor) {\r
+ return false;\r
+ }\r
+\r
+ // stack constructor before traversing properties\r
+ callers.push(a.constructor);\r
+\r
+ for (i in a) { // be strict: don't ensures hasOwnProperty and go deep\r
+\r
+ aProperties.push(i); // collect a's properties\r
+\r
+ if ( ! innerEquiv(a[i], b[i])) {\r
+ eq = false;\r
+ }\r
+ }\r
+\r
+ callers.pop(); // unstack, we are done\r
+\r
+ for (i in b) {\r
+ bProperties.push(i); // collect b's properties\r
+ }\r
+\r
+ // Ensures identical properties name\r
+ return eq && innerEquiv(aProperties.sort(), bProperties.sort());\r
+ }\r
+ };\r
+ }();\r
+\r
+ innerEquiv = function () { // can take multiple arguments\r
+ var args = Array.prototype.slice.apply(arguments);\r
+ if (args.length < 2) {\r
+ return true; // end transition\r
+ }\r
+\r
+ return (function (a, b) {\r
+ if (a === b) {\r
+ return true; // catch the most you can\r
+ } else if (a === null || b === null || typeof a === "undefined" || typeof b === "undefined" || hoozit(a) !== hoozit(b)) {\r
+ return false; // don't lose time with error prone cases\r
+ } else {\r
+ return bindCallbacks(a, callbacks, [b, a]);\r
+ }\r
+\r
+ // apply transition with (1..n) arguments\r
+ })(args[0], args[1]) && arguments.callee.apply(this, args.splice(1, args.length -1));\r
+ };\r
+\r
+ return innerEquiv;\r
+\r
+}();\r
+\r
+var GETParams = $.map( location.search.slice(1).split('&'), decodeURIComponent ),\r
+ ngindex = $.inArray("noglobals", GETParams),\r
+ noglobals = ngindex !== -1;\r
+\r
+if( noglobals )\r
+ GETParams.splice( ngindex, 1 );\r
+ \r
+var config = {\r
+ stats: {\r
+ all: 0,\r
+ bad: 0\r
+ },\r
+ queue: [],\r
+ // block until document ready\r
+ blocking: true,\r
+ //restrict modules/tests by get parameters\r
+ filters: GETParams,\r
+ isLocal: !!(window.location.protocol == 'file:')\r
+};\r
+\r
+// public API as global methods\r
+$.extend(window, {\r
+ test: test,\r
+ module: module,\r
+ expect: expect,\r
+ ok: ok,\r
+ equals: equals,\r
+ start: start,\r
+ stop: stop,\r
+ reset: reset,\r
+ isLocal: config.isLocal,\r
+ same: function(a, b, message) {\r
+ push(equiv(a, b), a, b, message);\r
+ },\r
+ QUnit: {\r
+ equiv: equiv,\r
+ ok: ok,\r
+ done: function(failures, total){},\r
+ log: function(result, message){}\r
+ },\r
+ // legacy methods below\r
+ isSet: isSet,\r
+ isObj: isObj,\r
+ compare: function() {\r
+ throw "compare is deprecated - use same() instead";\r
+ },\r
+ compare2: function() {\r
+ throw "compare2 is deprecated - use same() instead";\r
+ },\r
+ serialArray: function() {\r
+ throw "serialArray is deprecated - use jsDump.parse() instead";\r
+ },\r
+ q: q,\r
+ t: t,\r
+ url: url,\r
+ triggerEvent: triggerEvent\r
+});\r
+\r
+$(window).load(function() {\r
+ \r
+ if (!$("#header, #banner, #userAgent, #tests").length) {\r
+ $('body').prepend(\r
+ '<h1 id="header">' + document.title + '</h1>' +\r
+ '<h2 id="banner"></h2>' +\r
+ '<h2 id="userAgent"></h2>' +\r
+ '<ol id="tests"></ol>'\r
+ );\r
+ }\r
+ \r
+ $('#userAgent').html(navigator.userAgent);\r
+ var head = $('<div class="testrunner-toolbar"><label for="filter-pass">Hide passed tests</label></div>').insertAfter("#userAgent");\r
+ $('<input type="checkbox" id="filter-pass" />').attr("disabled", true).prependTo(head).click(function() {\r
+ $('li.pass')[this.checked ? 'hide' : 'show']();\r
+ });\r
+ $('<input type="checkbox" id="filter-missing">').attr("disabled", true).appendTo(head).click(function() {\r
+ $("li.fail:contains('missing test - untested code is broken code')").parent('ol').parent('li.fail')[this.checked ? 'hide' : 'show']();\r
+ });\r
+ $("#filter-missing").after('<label for="filter-missing">Hide missing tests (untested code is broken code)</label>');\r
+ runTest(); \r
+});\r
+\r
+function synchronize(callback) {\r
+ config.queue.push(callback);\r
+ if(!config.blocking) {\r
+ process();\r
+ }\r
+}\r
+\r
+function process() {\r
+ while(config.queue.length && !config.blocking) {\r
+ config.queue.shift()();\r
+ }\r
+}\r
+\r
+function stop(timeout) {\r
+ config.blocking = true;\r
+ if (timeout)\r
+ config.timeout = setTimeout(function() {\r
+ QUnit.ok( false, "Test timed out" );\r
+ start();\r
+ }, timeout);\r
+}\r
+function start() {\r
+ // A slight delay, to avoid any current callbacks\r
+ setTimeout(function() {\r
+ if(config.timeout)\r
+ clearTimeout(config.timeout);\r
+ config.blocking = false;\r
+ process();\r
+ }, 13);\r
+}\r
+\r
+function validTest( name ) {\r
+ var i = config.filters.length,\r
+ run = false;\r
+\r
+ if( !i )\r
+ return true;\r
+ \r
+ while( i-- ){\r
+ var filter = config.filters[i],\r
+ not = filter.charAt(0) == '!';\r
+ if( not ) \r
+ filter = filter.slice(1);\r
+ if( name.indexOf(filter) != -1 )\r
+ return !not;\r
+ if( not )\r
+ run = true;\r
+ }\r
+ return run;\r
+}\r
+\r
+function runTest() {\r
+ config.blocking = false;\r
+ var started = +new Date;\r
+ config.fixture = document.getElementById('main').innerHTML;\r
+ config.ajaxSettings = $.ajaxSettings;\r
+ synchronize(function() {\r
+ $('<p id="testresult" class="result"/>').html(['Tests completed in ',\r
+ +new Date - started, ' milliseconds.<br/>',\r
+ '<span class="bad">', config.stats.all - config.stats.bad, '</span> tests of <span class="all">', config.stats.all, '</span> passed, ', config.stats.bad,' failed.']\r
+ .join(''))\r
+ .appendTo("body");\r
+ $("#banner").addClass(config.stats.bad ? "fail" : "pass");\r
+ QUnit.done( config.stats.bad, config.stats.all );\r
+ });\r
+}\r
+\r
+var pollution;\r
+\r
+function saveGlobal(){\r
+ pollution = [ ];\r
+ \r
+ if( noglobals )\r
+ for( var key in window )\r
+ pollution.push(key);\r
+}\r
+function checkPollution( name ){\r
+ var old = pollution;\r
+ saveGlobal();\r
+ \r
+ if( pollution.length > old.length ){\r
+ ok( false, "Introduced global variable(s): " + diff(old, pollution).join(", ") );\r
+ config.expected++;\r
+ }\r
+}\r
+\r
+function diff( clean, dirty ){\r
+ return $.grep( dirty, function(name){\r
+ return $.inArray( name, clean ) == -1;\r
+ });\r
+}\r
+\r
+function test(name, callback) {\r
+ if(config.currentModule)\r
+ name = config.currentModule + " module: <span>" + name + "</span>";\r
+ var lifecycle = $.extend({\r
+ setup: function() {},\r
+ teardown: function() {}\r
+ }, config.moduleLifecycle);\r
+ \r
+ if ( !validTest(name) )\r
+ return;\r
+ \r
+ var testEnvironment = {};\r
+ \r
+ synchronize(function() {\r
+ config.assertions = [];\r
+ config.expected = null;\r
+ try {\r
+ if( !pollution )\r
+ saveGlobal();\r
+ lifecycle.setup.call(testEnvironment);\r
+ } catch(e) {\r
+ QUnit.ok( false, "Setup failed on " + name + ": " + e.message );\r
+ }\r
+ });\r
+ synchronize(function() {\r
+ try {\r
+ callback.call(testEnvironment);\r
+ } catch(e) {\r
+ fail("Test " + name + " died, exception and test follows", e, callback);\r
+ QUnit.ok( false, "Died on test #" + (config.assertions.length + 1) + ": " + e.message );\r
+ // else next test will carry the responsibility\r
+ saveGlobal();\r
+ }\r
+ });\r
+ synchronize(function() {\r
+ try {\r
+ checkPollution();\r
+ lifecycle.teardown.call(testEnvironment);\r
+ } catch(e) {\r
+ QUnit.ok( false, "Teardown failed on " + name + ": " + e.message );\r
+ }\r
+ });\r
+ synchronize(function() {\r
+ try {\r
+ reset();\r
+ } catch(e) {\r
+ fail("reset() failed, following Test " + name + ", exception and reset fn follows", e, reset);\r
+ }\r
+ \r
+ if(config.expected && config.expected != config.assertions.length) {\r
+ QUnit.ok( false, "Expected " + config.expected + " assertions, but " + config.assertions.length + " were run" );\r
+ }\r
+ \r
+ var good = 0, bad = 0;\r
+ var ol = $("<ol/>").hide();\r
+ config.stats.all += config.assertions.length;\r
+ for ( var i = 0; i < config.assertions.length; i++ ) {\r
+ var assertion = config.assertions[i];\r
+ $("<li/>").addClass(assertion.result ? "pass" : "fail").text(assertion.message || "(no message)").appendTo(ol);\r
+ assertion.result ? good++ : bad++;\r
+ }\r
+ config.stats.bad += bad;\r
+ \r
+ var b = $("<strong/>").html(name + " <b style='color:black;'>(<b class='fail'>" + bad + "</b>, <b class='pass'>" + good + "</b>, " + config.assertions.length + ")</b>")\r
+ .click(function(){\r
+ $(this).next().toggle();\r
+ })\r
+ .dblclick(function(event) {\r
+ var target = $(event.target).filter("strong").clone();\r
+ if ( target.length ) {\r
+ target.children().remove();\r
+ location.href = location.href.match(/^(.+?)(\?.*)?$/)[1] + "?" + encodeURIComponent($.trim(target.text()));\r
+ }\r
+ });\r
+ \r
+ $("<li/>").addClass(bad ? "fail" : "pass").append(b).append(ol).appendTo("#tests");\r
+ \r
+ if(bad) {\r
+ $("#filter-pass").attr("disabled", null);\r
+ $("#filter-missing").attr("disabled", null);\r
+ }\r
+ });\r
+}\r
+\r
+function fail(message, exception, callback) {\r
+ if( typeof console != "undefined" && console.error && console.warn ) {\r
+ console.error(message);\r
+ console.error(exception);\r
+ console.warn(callback.toString());\r
+ } else if (window.opera && opera.postError) {\r
+ opera.postError(message, exception, callback.toString);\r
+ }\r
+}\r
+\r
+// call on start of module test to prepend name to all tests\r
+function module(name, lifecycle) {\r
+ config.currentModule = name;\r
+ config.moduleLifecycle = lifecycle;\r
+}\r
+\r
+/**\r
+ * Specify the number of expected assertions to gurantee that failed test (no assertions are run at all) don't slip through.\r
+ */\r
+function expect(asserts) {\r
+ config.expected = asserts;\r
+}\r
+\r
+/**\r
+ * Resets the test setup. Useful for tests that modify the DOM.\r
+ */\r
+function reset() {\r
+ $("#main").html( config.fixture );\r
+ $.event.global = {};\r
+ $.ajaxSettings = $.extend({}, config.ajaxSettings);\r
+}\r
+\r
+/**\r
+ * Asserts true.\r
+ * @example ok( $("a").size() > 5, "There must be at least 5 anchors" );\r
+ */\r
+function ok(a, msg) {\r
+ QUnit.log(a, msg);\r
+\r
+ config.assertions.push({\r
+ result: !!a,\r
+ message: msg\r
+ });\r
+}\r
+\r
+/**\r
+ * Asserts that two arrays are the same\r
+ */\r
+function isSet(a, b, msg) {\r
+ function serialArray( a ) {\r
+ var r = [];\r
+ \r
+ if ( a && a.length )\r
+ for ( var i = 0; i < a.length; i++ ) {\r
+ var str = a[i].nodeName;\r
+ if ( str ) {\r
+ str = str.toLowerCase();\r
+ if ( a[i].id )\r
+ str += "#" + a[i].id;\r
+ } else\r
+ str = a[i];\r
+ r.push( str );\r
+ }\r
+ \r
+ return "[ " + r.join(", ") + " ]";\r
+ }\r
+ var ret = true;\r
+ if ( a && b && a.length != undefined && a.length == b.length ) {\r
+ for ( var i = 0; i < a.length; i++ )\r
+ if ( a[i] != b[i] )\r
+ ret = false;\r
+ } else\r
+ ret = false;\r
+ QUnit.ok( ret, !ret ? (msg + " expected: " + serialArray(b) + " result: " + serialArray(a)) : msg );\r
+}\r
+\r
+/**\r
+ * Asserts that two objects are equivalent\r
+ */\r
+function isObj(a, b, msg) {\r
+ var ret = true;\r
+ \r
+ if ( a && b ) {\r
+ for ( var i in a )\r
+ if ( a[i] != b[i] )\r
+ ret = false;\r
+\r
+ for ( i in b )\r
+ if ( a[i] != b[i] )\r
+ ret = false;\r
+ } else\r
+ ret = false;\r
+\r
+ QUnit.ok( ret, msg );\r
+}\r
+\r
+/**\r
+ * Returns an array of elements with the given IDs, eg.\r
+ * @example q("main", "foo", "bar")\r
+ * @result [<div id="main">, <span id="foo">, <input id="bar">]\r
+ */\r
+function q() {\r
+ var r = [];\r
+ for ( var i = 0; i < arguments.length; i++ )\r
+ r.push( document.getElementById( arguments[i] ) );\r
+ return r;\r
+}\r
+\r
+/**\r
+ * Asserts that a select matches the given IDs\r
+ * @example t("Check for something", "//[a]", ["foo", "baar"]);\r
+ * @result returns true if "//[a]" return two elements with the IDs 'foo' and 'baar'\r
+ */\r
+function t(a,b,c) {\r
+ var f = $(b);\r
+ var s = "";\r
+ for ( var i = 0; i < f.length; i++ )\r
+ s += (s && ",") + '"' + f[i].id + '"';\r
+ isSet(f, q.apply(q,c), a + " (" + b + ")");\r
+}\r
+\r
+/**\r
+ * Add random number to url to stop IE from caching\r
+ *\r
+ * @example url("data/test.html")\r
+ * @result "data/test.html?10538358428943"\r
+ *\r
+ * @example url("data/test.php?foo=bar")\r
+ * @result "data/test.php?foo=bar&10538358345554"\r
+ */\r
+function url(value) {\r
+ return value + (/\?/.test(value) ? "&" : "?") + new Date().getTime() + "" + parseInt(Math.random()*100000);\r
+}\r
+\r
+/**\r
+ * Checks that the first two arguments are equal, with an optional message.\r
+ * Prints out both actual and expected values.\r
+ *\r
+ * Prefered to ok( actual == expected, message )\r
+ *\r
+ * @example equals( $.format("Received {0} bytes.", 2), "Received 2 bytes." );\r
+ *\r
+ * @param Object actual\r
+ * @param Object expected\r
+ * @param String message (optional)\r
+ */\r
+function equals(actual, expected, message) {\r
+ push(expected == actual, actual, expected, message);\r
+}\r
+\r
+function push(result, actual, expected, message) {\r
+ message = message || (result ? "okay" : "failed");\r
+ QUnit.ok( result, result ? message + ": " + expected : message + ", expected: " + jsDump.parse(expected) + " result: " + jsDump.parse(actual) );\r
+}\r
+\r
+/**\r
+ * Trigger an event on an element.\r
+ *\r
+ * @example triggerEvent( document.body, "click" );\r
+ *\r
+ * @param DOMElement elem\r
+ * @param String type\r
+ */\r
+function triggerEvent( elem, type, event ) {\r
+ if ( $.browser.mozilla || $.browser.opera ) {\r
+ event = document.createEvent("MouseEvents");\r
+ event.initMouseEvent(type, true, true, elem.ownerDocument.defaultView,\r
+ 0, 0, 0, 0, 0, false, false, false, false, 0, null);\r
+ elem.dispatchEvent( event );\r
+ } else if ( $.browser.msie ) {\r
+ elem.fireEvent("on"+type);\r
+ }\r
+}\r
+\r
+})(jQuery);\r
+\r
+/**\r
+ * jsDump\r
+ * Copyright (c) 2008 Ariel Flesler - aflesler(at)gmail(dot)com | http://flesler.blogspot.com\r
+ * Licensed under BSD (http://www.opensource.org/licenses/bsd-license.php)\r
+ * Date: 5/15/2008\r
+ * @projectDescription Advanced and extensible data dumping for Javascript.\r
+ * @version 1.0.0\r
+ * @author Ariel Flesler\r
+ * @link {http://flesler.blogspot.com/2008/05/jsdump-pretty-dump-of-any-javascript.html}\r
+ */\r
+(function(){\r
+ function quote( str ){\r
+ return '"' + str.toString().replace(/"/g, '\\"') + '"';\r
+ };\r
+ function literal( o ){\r
+ return o + ''; \r
+ };\r
+ function join( pre, arr, post ){\r
+ var s = jsDump.separator(),\r
+ base = jsDump.indent(),\r
+ inner = jsDump.indent(1);\r
+ if( arr.join )\r
+ arr = arr.join( ',' + s + inner );\r
+ if( !arr )\r
+ return pre + post;\r
+ return [ pre, inner + arr, base + post ].join(s);\r
+ };\r
+ function array( arr ){\r
+ var i = arr.length, ret = Array(i); \r
+ this.up();\r
+ while( i-- )\r
+ ret[i] = this.parse( arr[i] ); \r
+ this.down();\r
+ return join( '[', ret, ']' );\r
+ };\r
+ \r
+ var reName = /^function (\w+)/;\r
+ \r
+ var jsDump = window.jsDump = {\r
+ parse:function( obj, type ){//type is used mostly internally, you can fix a (custom)type in advance\r
+ var parser = this.parsers[ type || this.typeOf(obj) ];\r
+ type = typeof parser; \r
+ \r
+ return type == 'function' ? parser.call( this, obj ) :\r
+ type == 'string' ? parser :\r
+ this.parsers.error;\r
+ },\r
+ typeOf:function( obj ){\r
+ var type = typeof obj,\r
+ f = 'function';//we'll use it 3 times, save it\r
+ return type != 'object' && type != f ? type :\r
+ !obj ? 'null' :\r
+ obj.exec ? 'regexp' :// some browsers (FF) consider regexps functions\r
+ obj.getHours ? 'date' :\r
+ obj.scrollBy ? 'window' :\r
+ obj.nodeName == '#document' ? 'document' :\r
+ obj.nodeName ? 'node' :\r
+ obj.item ? 'nodelist' : // Safari reports nodelists as functions\r
+ obj.callee ? 'arguments' :\r
+ obj.call || obj.constructor != Array && //an array would also fall on this hack\r
+ (obj+'').indexOf(f) != -1 ? f : //IE reports functions like alert, as objects\r
+ 'length' in obj ? 'array' :\r
+ type;\r
+ },\r
+ separator:function(){\r
+ return this.multiline ? this.HTML ? '<br />' : '\n' : this.HTML ? ' ' : ' ';\r
+ },\r
+ indent:function( extra ){// extra can be a number, shortcut for increasing-calling-decreasing\r
+ if( !this.multiline )\r
+ return '';\r
+ var chr = this.indentChar;\r
+ if( this.HTML )\r
+ chr = chr.replace(/\t/g,' ').replace(/ /g,' ');\r
+ return Array( this._depth_ + (extra||0) ).join(chr);\r
+ },\r
+ up:function( a ){\r
+ this._depth_ += a || 1;\r
+ },\r
+ down:function( a ){\r
+ this._depth_ -= a || 1;\r
+ },\r
+ setParser:function( name, parser ){\r
+ this.parsers[name] = parser;\r
+ },\r
+ // The next 3 are exposed so you can use them\r
+ quote:quote, \r
+ literal:literal,\r
+ join:join,\r
+ //\r
+ _depth_: 1,\r
+ // This is the list of parsers, to modify them, use jsDump.setParser\r
+ parsers:{\r
+ window: '[Window]',\r
+ document: '[Document]',\r
+ error:'[ERROR]', //when no parser is found, shouldn't happen\r
+ unknown: '[Unknown]',\r
+ 'null':'null',\r
+ undefined:'undefined',\r
+ 'function':function( fn ){\r
+ var ret = 'function',\r
+ name = 'name' in fn ? fn.name : (reName.exec(fn)||[])[1];//functions never have name in IE\r
+ if( name )\r
+ ret += ' ' + name;\r
+ ret += '(';\r
+ \r
+ ret = [ ret, this.parse( fn, 'functionArgs' ), '){'].join('');\r
+ return join( ret, this.parse(fn,'functionCode'), '}' );\r
+ },\r
+ array: array,\r
+ nodelist: array,\r
+ arguments: array,\r
+ object:function( map ){\r
+ var ret = [ ];\r
+ this.up();\r
+ for( var key in map )\r
+ ret.push( this.parse(key,'key') + ': ' + this.parse(map[key]) );\r
+ this.down();\r
+ return join( '{', ret, '}' );\r
+ },\r
+ node:function( node ){\r
+ var open = this.HTML ? '<' : '<',\r
+ close = this.HTML ? '>' : '>';\r
+ \r
+ var tag = node.nodeName.toLowerCase(),\r
+ ret = open + tag;\r
+ \r
+ for( var a in this.DOMAttrs ){\r
+ var val = node[this.DOMAttrs[a]];\r
+ if( val )\r
+ ret += ' ' + a + '=' + this.parse( val, 'attribute' );\r
+ }\r
+ return ret + close + open + '/' + tag + close;\r
+ },\r
+ functionArgs:function( fn ){//function calls it internally, it's the arguments part of the function\r
+ var l = fn.length;\r
+ if( !l ) return ''; \r
+ \r
+ var args = Array(l);\r
+ while( l-- )\r
+ args[l] = String.fromCharCode(97+l);//97 is 'a'\r
+ return ' ' + args.join(', ') + ' ';\r
+ },\r
+ key:quote, //object calls it internally, the key part of an item in a map\r
+ functionCode:'[code]', //function calls it internally, it's the content of the function\r
+ attribute:quote, //node calls it internally, it's an html attribute value\r
+ string:quote,\r
+ date:quote,\r
+ regexp:literal, //regex\r
+ number:literal,\r
+ 'boolean':literal\r
+ },\r
+ DOMAttrs:{//attributes to dump from nodes, name=>realName\r
+ id:'id',\r
+ name:'name',\r
+ 'class':'className'\r
+ },\r
+ HTML:false,//if true, entities are escaped ( <, >, \t, space and \n )\r
+ indentChar:' ',//indentation unit\r
+ multiline:true //if true, items in a collection, are separated by a \n, else just a space.\r
+ };\r
+\r
+})();\r
<link type="text/css" href="../testsuite.css" rel="stylesheet" />
<script type="text/javascript" src="../testsuite.js"></script>
- <script type="text/javascript" src="../../../external/testrunner-r6343.js"></script>
+ <script type="text/javascript" src="../../../external/testrunner-r6416.js"></script>
<script type="text/javascript" src="../../jquery.simulate.js"></script>
<script type="text/javascript" src="accordion_core.js"></script>
<script type="text/javascript" src="../../../ui/ui.sortable.js"></script>
<script type="text/javascript" src="../../../ui/ui.tabs.js"></script>
- <script type="text/javascript" src="../../../external/testrunner-r6343.js"></script>
+ <script type="text/javascript" src="../../../external/testrunner-r6416.js"></script>
<script type="text/javascript" src="../../../external/jquery.cookie-r6165.js"></script>
<script type="text/javascript" src="../../jquery.simulate.js"></script>
<script type="text/javascript" src="../../../ui/ui.sortable.js"></script>
<script type="text/javascript" src="../../../ui/ui.tabs.js"></script>
- <script type="text/javascript" src="../../../external/testrunner-r6343.js"></script>
+ <script type="text/javascript" src="../../../external/testrunner-r6416.js"></script>
<script type="text/javascript" src="../../../external/jquery.cookie-r6165.js"></script>
<script type="text/javascript" src="../../jquery.simulate.js"></script>
<link type="text/css" href="../testsuite.css" rel="stylesheet" />
<script type="text/javascript" src="../testsuite.js"></script>
- <script type="text/javascript" src="../../../external/testrunner-r6343.js"></script>
+ <script type="text/javascript" src="../../../external/testrunner-r6416.js"></script>
<script type="text/javascript" src="../../jquery.simulate.js"></script>
<script type="text/javascript" src="core.js"></script>
<link type="text/css" href="../testsuite.css" rel="stylesheet" />
<script type="text/javascript" src="../testsuite.js"></script>
- <script type="text/javascript" src="../../../external/testrunner-r6343.js"></script>
+ <script type="text/javascript" src="../../../external/testrunner-r6416.js"></script>
<script type="text/javascript" src="../../jquery.simulate.js"></script>
<script type="text/javascript" src="datepicker_core.js"></script>
<link type="text/css" href="testsuite.css" rel="stylesheet" />
<script type="text/javascript" src="testsuite.js"></script>
- <script type="text/javascript" src="../../external/testrunner-r6343.js"></script>
+ <script type="text/javascript" src="../../external/testrunner-r6416.js"></script>
<script type="text/javascript" src="../../external/jquery.cookie-r6165.js"></script>
<script type="text/javascript" src="../jquery.simulate.js"></script>
<link type="text/css" href="../testsuite.css" rel="stylesheet" />
<script type="text/javascript" src="../testsuite.js"></script>
- <script type="text/javascript" src="../../../external/testrunner-r6343.js"></script>
+ <script type="text/javascript" src="../../../external/testrunner-r6416.js"></script>
<script type="text/javascript" src="../../jquery.simulate.js"></script>
<script type="text/javascript" src="dialog_core.js"></script>
<link type="text/css" href="../testsuite.css" rel="stylesheet" />
<script type="text/javascript" src="../testsuite.js"></script>
- <script type="text/javascript" src="../../../external/testrunner-r6343.js"></script>
+ <script type="text/javascript" src="../../../external/testrunner-r6416.js"></script>
<script type="text/javascript" src="../../jquery.simulate.js"></script>
<script type="text/javascript" src="draggable_core.js"></script>
<link type="text/css" href="../testsuite.css" rel="stylesheet" />
<script type="text/javascript" src="../testsuite.js"></script>
- <script type="text/javascript" src="../../../external/testrunner-r6343.js"></script>
+ <script type="text/javascript" src="../../../external/testrunner-r6416.js"></script>
<script type="text/javascript" src="../../jquery.simulate.js"></script>
<script type="text/javascript" src="droppable_core.js"></script>
\r
<link type="text/css" href="../testsuite.css" rel="stylesheet" />\r
<script type="text/javascript" src="../testsuite.js"></script>\r
- <script type="text/javascript" src="../../../external/testrunner-r6343.js"></script>\r
+ <script type="text/javascript" src="../../../external/testrunner-r6416.js"></script>\r
\r
<script type="text/javascript" src="position_core.js"></script>\r
</head>\r
<link type="text/css" href="../testsuite.css" rel="stylesheet" />
<script type="text/javascript" src="../testsuite.js"></script>
- <script type="text/javascript" src="../../../external/testrunner-r6343.js"></script>
+ <script type="text/javascript" src="../../../external/testrunner-r6416.js"></script>
<script type="text/javascript" src="../../jquery.simulate.js"></script>
<script type="text/javascript" src="progressbar_core.js"></script>
<link type="text/css" href="../testsuite.css" rel="stylesheet" />
<script type="text/javascript" src="../testsuite.js"></script>
- <script type="text/javascript" src="../../../external/testrunner-r6343.js"></script>
+ <script type="text/javascript" src="../../../external/testrunner-r6416.js"></script>
<script type="text/javascript" src="../../jquery.simulate.js"></script>
<script type="text/javascript" src="resizable_core.js"></script>
<link type="text/css" href="../testsuite.css" rel="stylesheet" />
<script type="text/javascript" src="../testsuite.js"></script>
- <script type="text/javascript" src="../../../external/testrunner-r6343.js"></script>
+ <script type="text/javascript" src="../../../external/testrunner-r6416.js"></script>
<script type="text/javascript" src="../../jquery.simulate.js"></script>
<script type="text/javascript" src="selectable_core.js"></script>
<link type="text/css" href="../testsuite.css" rel="stylesheet" />
<script type="text/javascript" src="../testsuite.js"></script>
- <script type="text/javascript" src="../../../external/testrunner-r6343.js"></script>
+ <script type="text/javascript" src="../../../external/testrunner-r6416.js"></script>
<script type="text/javascript" src="../../jquery.simulate.js"></script>
<script type="text/javascript" src="slider_core.js"></script>
<link type="text/css" href="../testsuite.css" rel="stylesheet" />
<script type="text/javascript" src="../testsuite.js"></script>
- <script type="text/javascript" src="../../../external/testrunner-r6343.js"></script>
+ <script type="text/javascript" src="../../../external/testrunner-r6416.js"></script>
<script type="text/javascript" src="../../jquery.simulate.js"></script>
<script type="text/javascript" src="sortable_core.js"></script>
<link type="text/css" href="../testsuite.css" rel="stylesheet" />
<script type="text/javascript" src="../testsuite.js"></script>
- <script type="text/javascript" src="../../../external/testrunner-r6343.js"></script>
+ <script type="text/javascript" src="../../../external/testrunner-r6416.js"></script>
<script type="text/javascript" src="../../../external/jquery.cookie-r6165.js"></script>
<script type="text/javascript" src="../../jquery.simulate.js"></script>