217 |
218 |
219 |
--------------------------------------------------------------------------------
/lib/jsunit/licenses/JDOM_license.txt:
--------------------------------------------------------------------------------
1 | /*--
2 |
3 | $Id: JDOM_license.txt 81 2003-07-24 04:44:54Z edwardhieatt $
4 |
5 | Copyright (C) 2000-2003 Jason Hunter & Brett McLaughlin.
6 | All rights reserved.
7 |
8 | Redistribution and use in source and binary forms, with or without
9 | modification, are permitted provided that the following conditions
10 | are met:
11 |
12 | 1. Redistributions of source code must retain the above copyright
13 | notice, this list of conditions, and the following disclaimer.
14 |
15 | 2. Redistributions in binary form must reproduce the above copyright
16 | notice, this list of conditions, and the disclaimer that follows
17 | these conditions in the documentation and/or other materials
18 | provided with the distribution.
19 |
20 | 3. The name "JDOM" must not be used to endorse or promote products
21 | derived from this software without prior written permission. For
22 | written permission, please contact .
23 |
24 | 4. Products derived from this software may not be called "JDOM", nor
25 | may "JDOM" appear in their name, without prior written permission
26 | from the JDOM Project Management .
27 |
28 | In addition, we request (but do not require) that you include in the
29 | end-user documentation provided with the redistribution and/or in the
30 | software itself an acknowledgement equivalent to the following:
31 | "This product includes software developed by the
32 | JDOM Project (http://www.jdom.org/)."
33 | Alternatively, the acknowledgment may be graphical using the logos
34 | available at http://www.jdom.org/images/logos.
35 |
36 | THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED
37 | WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
38 | OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
39 | DISCLAIMED. IN NO EVENT SHALL THE JDOM AUTHORS OR THE PROJECT
40 | CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
41 | SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
42 | LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
43 | USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
44 | ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
45 | OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
46 | OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
47 | SUCH DAMAGE.
48 |
49 | This software consists of voluntary contributions made by many
50 | individuals on behalf of the JDOM Project and was originally
51 | created by Jason Hunter and
52 | Brett McLaughlin . For more information on
53 | the JDOM Project, please see .
54 |
55 | */
56 |
57 |
--------------------------------------------------------------------------------
/lib/jsunit/app/testContainerController.html:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 | JsUnit Test Container Controller
6 |
72 |
73 |
74 |
75 | Test Container Controller
76 |
77 |
--------------------------------------------------------------------------------
/lib/jsunit/app/jsUnitMockTimeout.js:
--------------------------------------------------------------------------------
1 | // Mock setTimeout, clearTimeout
2 | // Contributed by Pivotal Computer Systems, www.pivotalsf.com
3 |
4 | var Clock = {
5 | timeoutsMade: 0,
6 | scheduledFunctions: {},
7 | nowMillis: 0,
8 | reset: function() {
9 | this.scheduledFunctions = {};
10 | this.nowMillis = 0;
11 | this.timeoutsMade = 0;
12 | },
13 | tick: function(millis) {
14 | var oldMillis = this.nowMillis;
15 | var newMillis = oldMillis + millis;
16 | this.runFunctionsWithinRange(oldMillis, newMillis);
17 | this.nowMillis = newMillis;
18 | },
19 | runFunctionsWithinRange: function(oldMillis, nowMillis) {
20 | var scheduledFunc;
21 | var funcsToRun = [];
22 | for (var timeoutKey in this.scheduledFunctions) {
23 | scheduledFunc = this.scheduledFunctions[timeoutKey];
24 | if (scheduledFunc != undefined &&
25 | scheduledFunc.runAtMillis >= oldMillis &&
26 | scheduledFunc.runAtMillis <= nowMillis) {
27 | funcsToRun.push(scheduledFunc);
28 | this.scheduledFunctions[timeoutKey] = undefined;
29 | }
30 | }
31 |
32 | if (funcsToRun.length > 0) {
33 | funcsToRun.sort(function(a, b) {
34 | return a.runAtMillis - b.runAtMillis;
35 | });
36 | for (var i = 0; i < funcsToRun.length; ++i) {
37 | try {
38 | this.nowMillis = funcsToRun[i].runAtMillis;
39 | funcsToRun[i].funcToCall();
40 | if (funcsToRun[i].recurring) {
41 | Clock.scheduleFunction(funcsToRun[i].timeoutKey,
42 | funcsToRun[i].funcToCall,
43 | funcsToRun[i].millis,
44 | true);
45 | }
46 | } catch(e) {
47 | }
48 | }
49 | this.runFunctionsWithinRange(oldMillis, nowMillis);
50 | }
51 | },
52 | scheduleFunction: function(timeoutKey, funcToCall, millis, recurring) {
53 | Clock.scheduledFunctions[timeoutKey] = {
54 | runAtMillis: Clock.nowMillis + millis,
55 | funcToCall: funcToCall,
56 | recurring: recurring,
57 | timeoutKey: timeoutKey,
58 | millis: millis
59 | };
60 | }
61 | };
62 |
63 | function setTimeout(funcToCall, millis) {
64 | Clock.timeoutsMade = Clock.timeoutsMade + 1;
65 | Clock.scheduleFunction(Clock.timeoutsMade, funcToCall, millis, false);
66 | return Clock.timeoutsMade;
67 | }
68 |
69 | function setInterval(funcToCall, millis) {
70 | Clock.timeoutsMade = Clock.timeoutsMade + 1;
71 | Clock.scheduleFunction(Clock.timeoutsMade, funcToCall, millis, true);
72 | return Clock.timeoutsMade;
73 | }
74 |
75 | function clearTimeout(timeoutKey) {
76 | Clock.scheduledFunctions[timeoutKey] = undefined;
77 | }
78 |
79 | function clearInterval(timeoutKey) {
80 | Clock.scheduledFunctions[timeoutKey] = undefined;
81 | }
82 |
--------------------------------------------------------------------------------
/lib/jsunit/jsunit.properties.sample:
--------------------------------------------------------------------------------
1 |
2 |
3 | #Using jsunit.properties is one way to specify the various properties used by the JsUnitServer.
4 | #It is deprecated in favor of using ant build files. See build.xml.
5 | #To use this file, rename it to "jsunit.properties". You need to provide values for the mandatory properties.
6 | #See the documentation at http://www.jsunit.net for more information.
7 |
8 |
9 | #closeBrowsersAfterTestRuns determines whether to attempt to close browsers after test runs. This is not a mandatory property. The default is true. For example: 'true'
10 | closeBrowsersAfterTestRuns=
11 |
12 | #description is a human-readable description of a standard or farm server. This is not a mandatory property. The default is blank. For example: 'This is our Mac - it's only running Safari right now'
13 | description=
14 |
15 | #ignoreUnresponsiveRemoteMachines is a property used only by the JsUnit Farm Server and the distributed_test target. Its value is whether to ignore a remove machine that does not respond. If true, test runs will be green even if one or more remove machines fail to respond; if false, an unresponsive remove machine results in a failure. This is not a mandatory property. Its default is false. For example: 'true'
16 | ignoreUnresponsiveRemoteMachines=
17 |
18 | #logsDirectory is the directory in which the JsUnitStandardServer stores the XML logs produced from tests run. It can be specified relative to the working directory. This is not a mandatory property. If not specified, the directory called 'logs' inside resourceBase is assumed. For example: 'c:\jsunit\java\logs'
19 | logsDirectory=
20 |
21 | #port is the port on which the JsUnitStandardServer runs. This is not a mandatory property. If not specified, 8080 is assumed. For exapmle: '8080'
22 | port=
23 |
24 | #remoteMachineURLs is a property used only by the JsUnit Farm Server and the distributed_test target. Its value is the list of URLs of remove machines to which a request to run tests will be sent. For example: 'http://machine1.company.com:8080,http://localhost:8080,http://192.168.1.200:9090'
25 | remoteMachineURLs=
26 |
27 | #resourceBase is the directory that the JsUnitStandardServer considers to be its document root. It can be specified relative to the working directory. This is not a mandatory property. If not specified, the working directory is assumed. For example: 'c:\jsunit'
28 | resourceBase=
29 |
30 | #timeoutSeconds is the number of seconds to wait before timing out a browser during a test run. This is not a mandatory property. If not specified, 60 is assumed. For example: '60'
31 | timeoutSeconds=
32 |
33 | #url is the URL (HTTP or file protocol) to open in the browser. For a JsUnit Server, this is a mandatory property for a test run if the server is not passed the 'url' parameter. For example: 'file:///c:/jsunit/testRunner.html?testPage=c:/jsunit/tests/jsUnitTestSuite.html'
34 | url=
35 |
--------------------------------------------------------------------------------
/lib/dom.js:
--------------------------------------------------------------------------------
1 | function DIV(attrs){
2 | return dom('div', attrs, arguments);
3 | }
4 |
5 | function BLOCKQUOTE(attrs, children){
6 | return dom('blockquote', attrs, arguments);
7 | }
8 |
9 | function H2(attrs){
10 | return dom('h2', attrs, arguments);
11 | }
12 |
13 | function ABBR(attrs){
14 | return dom('abbr', attrs, arguments);
15 | }
16 |
17 | function TIME(attrs){
18 | return dom('time', attrs, arguments);
19 | }
20 |
21 | function SPAN(attrs){
22 | return dom('span', attrs, arguments);
23 | }
24 |
25 | function P(attrs){
26 | return dom('p', attrs, arguments);
27 | }
28 |
29 | function A(attrs){
30 | return dom('a', attrs, arguments);
31 | }
32 |
33 | function IMG(attrs){
34 | return dom('img', attrs, arguments);
35 | }
36 |
37 | function isArray(obj) {
38 | if (obj.constructor.toString().indexOf("Array") == -1)
39 | return false;
40 | else
41 | return true;
42 | }
43 |
44 | function dom(name, attrs, args){
45 | if (typeof(attrs) == 'undefined'){
46 | attrs = {};
47 | }
48 | if (args.length > 1){
49 | attrs.childNodes = []
50 | for(i = 1; i < args.length; i++) {
51 | if(isArray(args[i])){ // flatten arrays
52 | attrs.childNodes = $.merge(attrs.childNodes, args[i])
53 | } else {
54 | attrs.childNodes.push(args[i]);
55 | }
56 | }
57 | }
58 | return DOM.Element.Create.createElement(name, attrs);
59 | }
60 |
61 | function appendChildNodes(){
62 | nodes = [];
63 | for (i = 1; i < arguments.length; i++){
64 | nodes.push(arguments[i]);
65 | }
66 | return DOM.Element.Create.updateElement(arguments[0], {childNodes: nodes});
67 | }
68 |
69 |
70 | function prettyHTML(dom, indent_string, indent_step) {
71 | if (typeof(indent_step) == 'undefined' || indent_step === null) {
72 | indent_step = 2;
73 | }
74 |
75 | // if we're just starting out, no indent
76 | if (typeof(indent_string) == 'undefined' || indent_string === null){
77 | indent_string = "\n";
78 | } else {
79 | for(var i = 0; i < indent_step; i++) {indent_string += ' ';}
80 | }
81 |
82 | var output = '';
83 |
84 | if (typeof(dom) == 'string') {
85 | output += indent_string + dom;
86 | } else if (dom.nodeType == 1) {
87 | //type 1 = element
88 | output += indent_string + '<' + dom.nodeName.toLowerCase();
89 | var attributes = [];
90 | var domAttr = attributeArray(dom);
91 | for (var i = 0; i < domAttr.length; i++) {
92 | var a = domAttr[i];
93 | output += " " + a.name + '="' + a.value + '"';
94 | }
95 | if (dom.hasChildNodes()){
96 | output += '>';
97 | if(dom.childNodes.length == 1 && dom.childNodes[0].nodeType == 3) {
98 | output += dom.childNodes[0].nodeValue;
99 | output += '' + dom.nodeName.toLowerCase() + '>';
100 | } else {
101 | var children = dom.childNodes;
102 | for (i = 0; i < children.length; i++) {
103 | output += prettyHTML(children[i], indent_string);
104 | }
105 | output += indent_string + '' + dom.nodeName.toLowerCase() + '>';
106 | }
107 |
108 | } else {
109 | output += ' />';
110 | }
111 | } else if (dom.nodeType == 3) {
112 | output += dom.nodeValue;
113 | }
114 | if(indent_string == "\n" && output[0] == "\n"){
115 | output = output.substring(1, output.length);
116 | }
117 |
118 | return output;
119 | }
--------------------------------------------------------------------------------
/lib/jsunit/changelog.txt:
--------------------------------------------------------------------------------
1 | TRACING
2 | - Tracing is now color coded by trace level
3 | - Traces are now prefixed with the Test Page and Test Function from which the trace is made
4 |
5 | ASSERTION FUNCTIONS
6 | - assertArrayEquals(array1, array2) introduced
7 | - assertObjectEquals(object1, object2) introduced
8 | - assertHTMLEquals function introduced
9 | - assertEvaluatesToTrue and assertEvaluatesToFalse introduced
10 | - assertHashEquals }
11 | - assertRoughlyEquals } Pivotal functions
12 | - assertContains }
13 |
14 | - changed expected/actual values display strings to use angle brackets, rather than square brackets
15 |
16 | - CLIENT-SIDE
17 | - HTML in result output is now correctly escaped
18 | - page load timeout changed to 120 seconds by default
19 | - setup page timeout change to 120 seconds by default
20 | - cache-buster for testpage retrieval & results submission
21 | - jsUnitRestoredHTMLDiv
22 | - turn off tracing, alerts, confirms when submitting
23 | - testPage parameter should be URL-encoded (only opera cares though)
24 | - Speed-up of Firefox/Mozilla (thanks to Chris Wesseling)
25 | - jsUnitMockTimeout.js (thanks to Pivotal, especially Nathan Wilmes)
26 |
27 | SERVER
28 | - start-browser scripts in bin
29 | - Migration of Java code to require Java 5.0
30 | - JSPs require a JDK
31 | - StandaloneTest and DistributedTest continue on after a failure in a particular browser or remote server respectively
32 | - StandaloneTest has a suite() method that makes the test run have multiple JUnit tests, one per browser
33 | - DistribuedTest has a suite() method that makes the test run have multiple JUnit tests, one per remote machine URL
34 | - Change to XML output format of test runs to include more information and be more hierarchical (machine->browser->test page->test case)
35 | - Logs are now prefixed with "JSTEST-" in order to match JUnit's "TEST-"
36 | - Logs now contain the browser ID (e.g. JSTEST-12345.5.xml means browser with ID 5); displayer servlet now takes an id and a browserId parameter
37 | - added support for launching the default system browser on Windows and UNIX (see the constant on net.jsunit.StandaloneTest)
38 | - StandaloneTest now runs tests in all specified browsers, even after an earlier browser failed
39 | - New "config" servlet that shows the configuration as XML of the server
40 | - Distributed Tests now send back an XML document that includes the XML for browser results as opposed to just a "success"/"failure" node
41 | - runner servlet takes a "url" querystring parameter that overrides the server's url property
42 | - test run requests to the JsUnitServer and the FarmServer are queued up and in serial so that different clients don't step on eachother
43 | - addition of new configuration parameter, "closeBrowsersAfterTestRuns", for whether to attempt to close browsers after test runs
44 | - addition of new configuration property, "timeoutSeconds", for how long to time browsers out
45 | - addition of new configuration property, "ignoreUnresponsiveRemoteMachines", for whether to care that remote machines don't uccessfully run the tests
46 | - addition of new configuration property, "description", which contains a human-readable description of the server
47 | - new index.jsp ("/") page
48 | - jsunit.org registered; redirects to edwardh.com/jsunit
49 |
50 | BUGS
51 | - fix for "retry test run" bug
52 | - bug 1070436 fixed
53 | - bug with multiple browsers and resultId specified fixed
54 | - Bug 1281427 fixed (test submission for Opera)
55 | - Safari fix
56 | - Bug 1431040 fixed
57 |
58 | ECLIPSE PLUGIN
59 | - Eclipse plugin version 1.0
60 |
61 |
--------------------------------------------------------------------------------
/lib/jsunit/tests/jsUnitFrameworkUtilityTests.html:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 | JsUnit StackTrace Tests
7 |
8 |
9 |
10 |
92 |
93 |
94 |
95 |
JsUnit Utility Tests
96 |
97 |
This page contains tests for the JsUnit framework uses. To see them, take a look at the source.
This page contains tests for the version checking code in JsUnit that looks to see whether a newer version of JsUnit
129 | is available. To see them, take a look at the source.
130 |
131 |
132 |
--------------------------------------------------------------------------------
/lib/jsunit/tests/jsUnitMockTimeoutTest.html:
--------------------------------------------------------------------------------
1 |
2 |
3 | Tests for jsUnitMockTimeout.js
4 |
5 |
6 |
175 |
176 |
177 |
178 |
179 |
180 |
--------------------------------------------------------------------------------
/lib/jsunit/testRunner.html:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 | JsUnit Test Runner
7 |
8 |
9 |
75 |
76 |
77 |
78 |
79 |
152 |
153 |
154 |
166 |
167 |
--------------------------------------------------------------------------------
/lib/DomCreate.js:
--------------------------------------------------------------------------------
1 | /*
2 |
3 | =head1 NAME
4 |
5 | DOM.Element.Create - Create new DOM elments in a more declarative manner
6 |
7 | =head1 SYNOPSIS
8 |
9 | // BEFORE
10 | var link = document.createElement('a');
11 | link.href= "http://www.google.com";
12 | link.title= "Search the Web";
13 | link.target= "_blank"
14 | link.onclick= function() { alert('here we go'); return true; };
15 | link.appendChild( document.createTextNode('link to Google') );
16 | var para = document.createElement('p');
17 | para.id = 'foo';
18 | para.style.fontWeight = 'bold';
19 | para.style.border = '1px solid black';
20 | para.className = 'body-text';
21 | para.onmouseover = function(){ this.style.backgroundColor="red"; };
22 | para.onmouseout = function(){ this.style.backgroundColor="white"; };
23 | para.appendChild( document.createTextNode('here is a ') );
24 | para.appendChild( link );
25 |
26 | // AFTER
27 | var para = createElement( 'p', {
28 | id: 'foo',
29 | className: 'body-text',
30 | style: {
31 | fontWeight: 'bold',
32 | border: '1px solid black'
33 | },
34 | events: {
35 | mouseover: function(){ this.style.backgroundColor="red"; },
36 | mouseout: function(){ this.style.backgroundColor="white"; }
37 | },
38 | childNodes: [ 'here is a ',
39 |
40 | createElement( 'a', {
41 | href: 'http://www.google.com',
42 | className: 'offsite',
43 | title: 'Search the Web',
44 | target: '_blank',
45 | events: {
46 | click: function() { alert('here we go'); return true; }
47 | },
48 | childNodes: [ 'link to Google' ]
49 | })
50 | ]
51 | });
52 |
53 | =head1 DESCRIPTION
54 |
55 | It has been fairly common in code I've had to write to create one or more html elements
56 | and subsequently set many of their attributes, append children and register event listeners.
57 | Rather than write line after line of C and
58 | C, C allows a more declarative approach to
59 | defining new elements.
60 |
61 | C does not export any methods by default, but allows you to export either of the
62 | methods described below.
63 |
64 | =head2 Package Methods
65 |
66 | =cut
67 |
68 | */
69 |
70 | if ( typeof DOM == "undefined") DOM = {};
71 | if ( typeof DOM.Element == "undefined") DOM.Element = {};
72 |
73 | DOM.Element.Create = {
74 |
75 | VERSION: 0.01,
76 |
77 | EXPORT_OK: [ 'createElement','updateElement' ],
78 |
79 | /*
80 |
81 | =head3 C
82 |
83 | Pass a tagName and an associative array of attributes to this method and get back the
84 | correpsonding element. attribute names are not checked for validity, allowing the possibility
85 | of adding custom attributes to an element. There are, however, 3 reserved keys:
86 |
87 | =over
88 |
89 | =item C
33 |
91 |
92 |
93 |
94 |
Создатель XFN 1.1
95 |
176 |
177 |
178 | <a href="" rel=""></a>
179 |
180 |
181 |
Этот пользовательский интерфейс и его код предоставлен как подспорье XFN разработчикам и как демонстрация красоты соответствия XFN значений и кода для их отображения.
182 | Создатель XFN 1.0, автор Мэт Малэнвег (Matt Mullenweg).
183 | Создатель XFN 1.1 (обновление), автор Тантек Челик (Tantek Çelik).
184 |
234 |
235 | The manual Test Runner is at testRunner.html.
236 |
237 |
238 |
239 |
240 |
241 |
242 | You can see the configuration of this server as XML by going to config.
244 | The config service is usually only used programmatically.
245 |
246 |
Warning - publishing your email address, phone number or instant messenger screenname on the web can open it up to abuse.
296 |
297 |
298 |
code
299 |
300 |
preview
301 |
302 |
303 |
304 |
305 |
306 |
307 |
This user interface, and the code behind it, is provided as an example for the benefit of microformat open standards developers, and to demonstrate the clear
308 | one to one correspondence between microformat fields and microformat code. The code generated by this interface may be used for semantic web pages, structured blogging, or any other application that requires markup that is simultaneously human presentable and machine readable. Based on the
309 | hCard creator
310 | by Tantek Çelik (later updated by Ryan King), which is based on the
311 | XFN Creator (v1.0 by Matt Mullenweg, v1.1 update by Tantek Çelik).
312 |
319 |
320 |
322 |
323 |
324 |
325 |
--------------------------------------------------------------------------------
/lib/jsunit/licenses/gpl-2.txt:
--------------------------------------------------------------------------------
1 | GNU GENERAL PUBLIC LICENSE
2 | Version 2, June 1991
3 |
4 | Copyright (C) 1989, 1991 Free Software Foundation, Inc.
5 | 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
6 | Everyone is permitted to copy and distribute verbatim copies
7 | of this license document, but changing it is not allowed.
8 |
9 | Preamble
10 |
11 | The licenses for most software are designed to take away your
12 | freedom to share and change it. By contrast, the GNU General Public
13 | License is intended to guarantee your freedom to share and change free
14 | software--to make sure the software is free for all its users. This
15 | General Public License applies to most of the Free Software
16 | Foundation's software and to any other program whose authors commit to
17 | using it. (Some other Free Software Foundation software is covered by
18 | the GNU Library General Public License instead.) You can apply it to
19 | your programs, too.
20 |
21 | When we speak of free software, we are referring to freedom, not
22 | price. Our General Public Licenses are designed to make sure that you
23 | have the freedom to distribute copies of free software (and charge for
24 | this service if you wish), that you receive source code or can get it
25 | if you want it, that you can change the software or use pieces of it
26 | in new free programs; and that you know you can do these things.
27 |
28 | To protect your rights, we need to make restrictions that forbid
29 | anyone to deny you these rights or to ask you to surrender the rights.
30 | These restrictions translate to certain responsibilities for you if you
31 | distribute copies of the software, or if you modify it.
32 |
33 | For example, if you distribute copies of such a program, whether
34 | gratis or for a fee, you must give the recipients all the rights that
35 | you have. You must make sure that they, too, receive or can get the
36 | source code. And you must show them these terms so they know their
37 | rights.
38 |
39 | We protect your rights with two steps: (1) copyright the software, and
40 | (2) offer you this license which gives you legal permission to copy,
41 | distribute and/or modify the software.
42 |
43 | Also, for each author's protection and ours, we want to make certain
44 | that everyone understands that there is no warranty for this free
45 | software. If the software is modified by someone else and passed on, we
46 | want its recipients to know that what they have is not the original, so
47 | that any problems introduced by others will not reflect on the original
48 | authors' reputations.
49 |
50 | Finally, any free program is threatened constantly by software
51 | patents. We wish to avoid the danger that redistributors of a free
52 | program will individually obtain patent licenses, in effect making the
53 | program proprietary. To prevent this, we have made it clear that any
54 | patent must be licensed for everyone's free use or not licensed at all.
55 |
56 | The precise terms and conditions for copying, distribution and
57 | modification follow.
58 |
59 | GNU GENERAL PUBLIC LICENSE
60 | TERMS AND CONDITIONS FOR COPYING, DISTRIBUTION AND MODIFICATION
61 |
62 | 0. This License applies to any program or other work which contains
63 | a notice placed by the copyright holder saying it may be distributed
64 | under the terms of this General Public License. The "Program", below,
65 | refers to any such program or work, and a "work based on the Program"
66 | means either the Program or any derivative work under copyright law:
67 | that is to say, a work containing the Program or a portion of it,
68 | either verbatim or with modifications and/or translated into another
69 | language. (Hereinafter, translation is included without limitation in
70 | the term "modification".) Each licensee is addressed as "you".
71 |
72 | Activities other than copying, distribution and modification are not
73 | covered by this License; they are outside its scope. The act of
74 | running the Program is not restricted, and the output from the Program
75 | is covered only if its contents constitute a work based on the
76 | Program (independent of having been made by running the Program).
77 | Whether that is true depends on what the Program does.
78 |
79 | 1. You may copy and distribute verbatim copies of the Program's
80 | source code as you receive it, in any medium, provided that you
81 | conspicuously and appropriately publish on each copy an appropriate
82 | copyright notice and disclaimer of warranty; keep intact all the
83 | notices that refer to this License and to the absence of any warranty;
84 | and give any other recipients of the Program a copy of this License
85 | along with the Program.
86 |
87 | You may charge a fee for the physical act of transferring a copy, and
88 | you may at your option offer warranty protection in exchange for a fee.
89 |
90 | 2. You may modify your copy or copies of the Program or any portion
91 | of it, thus forming a work based on the Program, and copy and
92 | distribute such modifications or work under the terms of Section 1
93 | above, provided that you also meet all of these conditions:
94 |
95 | a) You must cause the modified files to carry prominent notices
96 | stating that you changed the files and the date of any change.
97 |
98 | b) You must cause any work that you distribute or publish, that in
99 | whole or in part contains or is derived from the Program or any
100 | part thereof, to be licensed as a whole at no charge to all third
101 | parties under the terms of this License.
102 |
103 | c) If the modified program normally reads commands interactively
104 | when run, you must cause it, when started running for such
105 | interactive use in the most ordinary way, to print or display an
106 | announcement including an appropriate copyright notice and a
107 | notice that there is no warranty (or else, saying that you provide
108 | a warranty) and that users may redistribute the program under
109 | these conditions, and telling the user how to view a copy of this
110 | License. (Exception: if the Program itself is interactive but
111 | does not normally print such an announcement, your work based on
112 | the Program is not required to print an announcement.)
113 |
114 | These requirements apply to the modified work as a whole. If
115 | identifiable sections of that work are not derived from the Program,
116 | and can be reasonably considered independent and separate works in
117 | themselves, then this License, and its terms, do not apply to those
118 | sections when you distribute them as separate works. But when you
119 | distribute the same sections as part of a whole which is a work based
120 | on the Program, the distribution of the whole must be on the terms of
121 | this License, whose permissions for other licensees extend to the
122 | entire whole, and thus to each and every part regardless of who wrote it.
123 |
124 | Thus, it is not the intent of this section to claim rights or contest
125 | your rights to work written entirely by you; rather, the intent is to
126 | exercise the right to control the distribution of derivative or
127 | collective works based on the Program.
128 |
129 | In addition, mere aggregation of another work not based on the Program
130 | with the Program (or with a work based on the Program) on a volume of
131 | a storage or distribution medium does not bring the other work under
132 | the scope of this License.
133 |
134 | 3. You may copy and distribute the Program (or a work based on it,
135 | under Section 2) in object code or executable form under the terms of
136 | Sections 1 and 2 above provided that you also do one of the following:
137 |
138 | a) Accompany it with the complete corresponding machine-readable
139 | source code, which must be distributed under the terms of Sections
140 | 1 and 2 above on a medium customarily used for software interchange; or,
141 |
142 | b) Accompany it with a written offer, valid for at least three
143 | years, to give any third party, for a charge no more than your
144 | cost of physically performing source distribution, a complete
145 | machine-readable copy of the corresponding source code, to be
146 | distributed under the terms of Sections 1 and 2 above on a medium
147 | customarily used for software interchange; or,
148 |
149 | c) Accompany it with the information you received as to the offer
150 | to distribute corresponding source code. (This alternative is
151 | allowed only for noncommercial distribution and only if you
152 | received the program in object code or executable form with such
153 | an offer, in accord with Subsection b above.)
154 |
155 | The source code for a work means the preferred form of the work for
156 | making modifications to it. For an executable work, complete source
157 | code means all the source code for all modules it contains, plus any
158 | associated interface definition files, plus the scripts used to
159 | control compilation and installation of the executable. However, as a
160 | special exception, the source code distributed need not include
161 | anything that is normally distributed (in either source or binary
162 | form) with the major components (compiler, kernel, and so on) of the
163 | operating system on which the executable runs, unless that component
164 | itself accompanies the executable.
165 |
166 | If distribution of executable or object code is made by offering
167 | access to copy from a designated place, then offering equivalent
168 | access to copy the source code from the same place counts as
169 | distribution of the source code, even though third parties are not
170 | compelled to copy the source along with the object code.
171 |
172 | 4. You may not copy, modify, sublicense, or distribute the Program
173 | except as expressly provided under this License. Any attempt
174 | otherwise to copy, modify, sublicense or distribute the Program is
175 | void, and will automatically terminate your rights under this License.
176 | However, parties who have received copies, or rights, from you under
177 | this License will not have their licenses terminated so long as such
178 | parties remain in full compliance.
179 |
180 | 5. You are not required to accept this License, since you have not
181 | signed it. However, nothing else grants you permission to modify or
182 | distribute the Program or its derivative works. These actions are
183 | prohibited by law if you do not accept this License. Therefore, by
184 | modifying or distributing the Program (or any work based on the
185 | Program), you indicate your acceptance of this License to do so, and
186 | all its terms and conditions for copying, distributing or modifying
187 | the Program or works based on it.
188 |
189 | 6. Each time you redistribute the Program (or any work based on the
190 | Program), the recipient automatically receives a license from the
191 | original licensor to copy, distribute or modify the Program subject to
192 | these terms and conditions. You may not impose any further
193 | restrictions on the recipients' exercise of the rights granted herein.
194 | You are not responsible for enforcing compliance by third parties to
195 | this License.
196 |
197 | 7. If, as a consequence of a court judgment or allegation of patent
198 | infringement or for any other reason (not limited to patent issues),
199 | conditions are imposed on you (whether by court order, agreement or
200 | otherwise) that contradict the conditions of this License, they do not
201 | excuse you from the conditions of this License. If you cannot
202 | distribute so as to satisfy simultaneously your obligations under this
203 | License and any other pertinent obligations, then as a consequence you
204 | may not distribute the Program at all. For example, if a patent
205 | license would not permit royalty-free redistribution of the Program by
206 | all those who receive copies directly or indirectly through you, then
207 | the only way you could satisfy both it and this License would be to
208 | refrain entirely from distribution of the Program.
209 |
210 | If any portion of this section is held invalid or unenforceable under
211 | any particular circumstance, the balance of the section is intended to
212 | apply and the section as a whole is intended to apply in other
213 | circumstances.
214 |
215 | It is not the purpose of this section to induce you to infringe any
216 | patents or other property right claims or to contest validity of any
217 | such claims; this section has the sole purpose of protecting the
218 | integrity of the free software distribution system, which is
219 | implemented by public license practices. Many people have made
220 | generous contributions to the wide range of software distributed
221 | through that system in reliance on consistent application of that
222 | system; it is up to the author/donor to decide if he or she is willing
223 | to distribute software through any other system and a licensee cannot
224 | impose that choice.
225 |
226 | This section is intended to make thoroughly clear what is believed to
227 | be a consequence of the rest of this License.
228 |
229 | 8. If the distribution and/or use of the Program is restricted in
230 | certain countries either by patents or by copyrighted interfaces, the
231 | original copyright holder who places the Program under this License
232 | may add an explicit geographical distribution limitation excluding
233 | those countries, so that distribution is permitted only in or among
234 | countries not thus excluded. In such case, this License incorporates
235 | the limitation as if written in the body of this License.
236 |
237 | 9. The Free Software Foundation may publish revised and/or new versions
238 | of the General Public License from time to time. Such new versions will
239 | be similar in spirit to the present version, but may differ in detail to
240 | address new problems or concerns.
241 |
242 | Each version is given a distinguishing version number. If the Program
243 | specifies a version number of this License which applies to it and "any
244 | later version", you have the option of following the terms and conditions
245 | either of that version or of any later version published by the Free
246 | Software Foundation. If the Program does not specify a version number of
247 | this License, you may choose any version ever published by the Free Software
248 | Foundation.
249 |
250 | 10. If you wish to incorporate parts of the Program into other free
251 | programs whose distribution conditions are different, write to the author
252 | to ask for permission. For software which is copyrighted by the Free
253 | Software Foundation, write to the Free Software Foundation; we sometimes
254 | make exceptions for this. Our decision will be guided by the two goals
255 | of preserving the free status of all derivatives of our free software and
256 | of promoting the sharing and reuse of software generally.
257 |
258 | NO WARRANTY
259 |
260 | 11. BECAUSE THE PROGRAM IS LICENSED FREE OF CHARGE, THERE IS NO WARRANTY
261 | FOR THE PROGRAM, TO THE EXTENT PERMITTED BY APPLICABLE LAW. EXCEPT WHEN
262 | OTHERWISE STATED IN WRITING THE COPYRIGHT HOLDERS AND/OR OTHER PARTIES
263 | PROVIDE THE PROGRAM "AS IS" WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED
264 | OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
265 | MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. THE ENTIRE RISK AS
266 | TO THE QUALITY AND PERFORMANCE OF THE PROGRAM IS WITH YOU. SHOULD THE
267 | PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF ALL NECESSARY SERVICING,
268 | REPAIR OR CORRECTION.
269 |
270 | 12. IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING
271 | WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MAY MODIFY AND/OR
272 | REDISTRIBUTE THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES,
273 | INCLUDING ANY GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING
274 | OUT OF THE USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED
275 | TO LOSS OF DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY
276 | YOU OR THIRD PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER
277 | PROGRAMS), EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE
278 | POSSIBILITY OF SUCH DAMAGES.
279 |
280 | END OF TERMS AND CONDITIONS
281 |
282 | How to Apply These Terms to Your New Programs
283 |
284 | If you develop a new program, and you want it to be of the greatest
285 | possible use to the public, the best way to achieve this is to make it
286 | free software which everyone can redistribute and change under these terms.
287 |
288 | To do so, attach the following notices to the program. It is safest
289 | to attach them to the start of each source file to most effectively
290 | convey the exclusion of warranty; and each file should have at least
291 | the "copyright" line and a pointer to where the full notice is found.
292 |
293 |
294 | Copyright (C)
295 |
296 | This program is free software; you can redistribute it and/or modify
297 | it under the terms of the GNU General Public License as published by
298 | the Free Software Foundation; either version 2 of the License, or
299 | (at your option) any later version.
300 |
301 | This program is distributed in the hope that it will be useful,
302 | but WITHOUT ANY WARRANTY; without even the implied warranty of
303 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
304 | GNU General Public License for more details.
305 |
306 | You should have received a copy of the GNU General Public License
307 | along with this program; if not, write to the Free Software
308 | Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
309 |
310 |
311 | Also add information on how to contact you by electronic and paper mail.
312 |
313 | If the program is interactive, make it output a short notice like this
314 | when it starts in an interactive mode:
315 |
316 | Gnomovision version 69, Copyright (C) year name of author
317 | Gnomovision comes with ABSOLUTELY NO WARRANTY; for details type `show w'.
318 | This is free software, and you are welcome to redistribute it
319 | under certain conditions; type `show c' for details.
320 |
321 | The hypothetical commands `show w' and `show c' should show the appropriate
322 | parts of the General Public License. Of course, the commands you use may
323 | be called something other than `show w' and `show c'; they could even be
324 | mouse-clicks or menu items--whatever suits your program.
325 |
326 | You should also get your employer (if you work as a programmer) or your
327 | school, if any, to sign a "copyright disclaimer" for the program, if
328 | necessary. Here is a sample; alter the names:
329 |
330 | Yoyodyne, Inc., hereby disclaims all copyright interest in the program
331 | `Gnomovision' (which makes passes at compilers) written by James Hacker.
332 |
333 | , 1 April 1989
334 | Ty Coon, President of Vice
335 |
336 | This General Public License does not permit incorporating your program into
337 | proprietary programs. If your program is a subroutine library, you may
338 | consider it more useful to permit linking proprietary applications with the
339 | library. If this is what you want to do, use the GNU Library General
340 | Public License instead of this License.
341 |
--------------------------------------------------------------------------------
/lib/jsunit/app/jsUnitCore.js:
--------------------------------------------------------------------------------
1 | var JSUNIT_UNDEFINED_VALUE;
2 | var JSUNIT_VERSION = 2.2;
3 | var isTestPageLoaded = false;
4 |
5 | //hack for NS62 bug
6 | function jsUnitFixTop() {
7 | var tempTop = top;
8 | if (!tempTop) {
9 | tempTop = window;
10 | while (tempTop.parent) {
11 | tempTop = tempTop.parent;
12 | if (tempTop.top && tempTop.top.jsUnitTestSuite) {
13 | tempTop = tempTop.top;
14 | break;
15 | }
16 | }
17 | }
18 | try {
19 | window.top = tempTop;
20 | } catch (e) {
21 | }
22 | }
23 |
24 | jsUnitFixTop();
25 |
26 | /**
27 | + * A more functional typeof
28 | + * @param Object o
29 | + * @return String
30 | + */
31 | function _trueTypeOf(something) {
32 | var result = typeof something;
33 | try {
34 | switch (result) {
35 | case 'string':
36 | case 'boolean':
37 | case 'number':
38 | break;
39 | case 'object':
40 | case 'function':
41 | switch (something.constructor)
42 | {
43 | case String:
44 | result = 'String';
45 | break;
46 | case Boolean:
47 | result = 'Boolean';
48 | break;
49 | case Number:
50 | result = 'Number';
51 | break;
52 | case Array:
53 | result = 'Array';
54 | break;
55 | case RegExp:
56 | result = 'RegExp';
57 | break;
58 | case Function:
59 | result = 'Function';
60 | break;
61 | default:
62 | var m = something.constructor.toString().match(/function\s*([^( ]+)\(/);
63 | if (m)
64 | result = m[1];
65 | else
66 | break;
67 | }
68 | break;
69 | }
70 | }
71 | finally {
72 | result = result.substr(0, 1).toUpperCase() + result.substr(1);
73 | return result;
74 | }
75 | }
76 |
77 | function _displayStringForValue(aVar) {
78 | var result = '<' + aVar + '>';
79 | if (!(aVar === null || aVar === top.JSUNIT_UNDEFINED_VALUE)) {
80 | result += ' (' + _trueTypeOf(aVar) + ')';
81 | }
82 | return result;
83 | }
84 |
85 | function fail(failureMessage) {
86 | throw new JsUnitException("Call to fail()", failureMessage);
87 | }
88 |
89 | function error(errorMessage) {
90 | var errorObject = new Object();
91 | errorObject.description = errorMessage;
92 | errorObject.stackTrace = getStackTrace();
93 | throw errorObject;
94 | }
95 |
96 | function argumentsIncludeComments(expectedNumberOfNonCommentArgs, args) {
97 | return args.length == expectedNumberOfNonCommentArgs + 1;
98 | }
99 |
100 | function commentArg(expectedNumberOfNonCommentArgs, args) {
101 | if (argumentsIncludeComments(expectedNumberOfNonCommentArgs, args))
102 | return args[0];
103 |
104 | return null;
105 | }
106 |
107 | function nonCommentArg(desiredNonCommentArgIndex, expectedNumberOfNonCommentArgs, args) {
108 | return argumentsIncludeComments(expectedNumberOfNonCommentArgs, args) ?
109 | args[desiredNonCommentArgIndex] :
110 | args[desiredNonCommentArgIndex - 1];
111 | }
112 |
113 | function _validateArguments(expectedNumberOfNonCommentArgs, args) {
114 | if (!( args.length == expectedNumberOfNonCommentArgs ||
115 | (args.length == expectedNumberOfNonCommentArgs + 1 && typeof(args[0]) == 'string') ))
116 | error('Incorrect arguments passed to assert function');
117 | }
118 |
119 | function _assert(comment, booleanValue, failureMessage) {
120 | if (!booleanValue)
121 | throw new JsUnitException(comment, failureMessage);
122 | }
123 |
124 | function assert() {
125 | _validateArguments(1, arguments);
126 | var booleanValue = nonCommentArg(1, 1, arguments);
127 |
128 | if (typeof(booleanValue) != 'boolean')
129 | error('Bad argument to assert(boolean)');
130 |
131 | _assert(commentArg(1, arguments), booleanValue === true, 'Call to assert(boolean) with false');
132 | }
133 |
134 | function assertTrue() {
135 | _validateArguments(1, arguments);
136 | var booleanValue = nonCommentArg(1, 1, arguments);
137 |
138 | if (typeof(booleanValue) != 'boolean')
139 | error('Bad argument to assertTrue(boolean)');
140 |
141 | _assert(commentArg(1, arguments), booleanValue === true, 'Call to assertTrue(boolean) with false');
142 | }
143 |
144 | function assertFalse() {
145 | _validateArguments(1, arguments);
146 | var booleanValue = nonCommentArg(1, 1, arguments);
147 |
148 | if (typeof(booleanValue) != 'boolean')
149 | error('Bad argument to assertFalse(boolean)');
150 |
151 | _assert(commentArg(1, arguments), booleanValue === false, 'Call to assertFalse(boolean) with true');
152 | }
153 |
154 | function assertEquals() {
155 | _validateArguments(2, arguments);
156 | var var1 = nonCommentArg(1, 2, arguments);
157 | var var2 = nonCommentArg(2, 2, arguments);
158 | _assert(commentArg(2, arguments), var1 === var2, 'Expected ' + _displayStringForValue(var1) + ' but was ' + _displayStringForValue(var2));
159 | }
160 |
161 | function assertNotEquals() {
162 | _validateArguments(2, arguments);
163 | var var1 = nonCommentArg(1, 2, arguments);
164 | var var2 = nonCommentArg(2, 2, arguments);
165 | _assert(commentArg(2, arguments), var1 !== var2, 'Expected not to be ' + _displayStringForValue(var2));
166 | }
167 |
168 | function assertNull() {
169 | _validateArguments(1, arguments);
170 | var aVar = nonCommentArg(1, 1, arguments);
171 | _assert(commentArg(1, arguments), aVar === null, 'Expected ' + _displayStringForValue(null) + ' but was ' + _displayStringForValue(aVar));
172 | }
173 |
174 | function assertNotNull() {
175 | _validateArguments(1, arguments);
176 | var aVar = nonCommentArg(1, 1, arguments);
177 | _assert(commentArg(1, arguments), aVar !== null, 'Expected not to be ' + _displayStringForValue(null));
178 | }
179 |
180 | function assertUndefined() {
181 | _validateArguments(1, arguments);
182 | var aVar = nonCommentArg(1, 1, arguments);
183 | _assert(commentArg(1, arguments), aVar === top.JSUNIT_UNDEFINED_VALUE, 'Expected ' + _displayStringForValue(top.JSUNIT_UNDEFINED_VALUE) + ' but was ' + _displayStringForValue(aVar));
184 | }
185 |
186 | function assertNotUndefined() {
187 | _validateArguments(1, arguments);
188 | var aVar = nonCommentArg(1, 1, arguments);
189 | _assert(commentArg(1, arguments), aVar !== top.JSUNIT_UNDEFINED_VALUE, 'Expected not to be ' + _displayStringForValue(top.JSUNIT_UNDEFINED_VALUE));
190 | }
191 |
192 | function assertNaN() {
193 | _validateArguments(1, arguments);
194 | var aVar = nonCommentArg(1, 1, arguments);
195 | _assert(commentArg(1, arguments), isNaN(aVar), 'Expected NaN');
196 | }
197 |
198 | function assertNotNaN() {
199 | _validateArguments(1, arguments);
200 | var aVar = nonCommentArg(1, 1, arguments);
201 | _assert(commentArg(1, arguments), !isNaN(aVar), 'Expected not NaN');
202 | }
203 |
204 | function assertObjectEquals() {
205 | _validateArguments(2, arguments);
206 | var var1 = nonCommentArg(1, 2, arguments);
207 | var var2 = nonCommentArg(2, 2, arguments);
208 | var type;
209 | var msg = commentArg(2, arguments)?commentArg(2, arguments):'';
210 | var isSame = (var1 === var2);
211 | //shortpath for references to same object
212 | var isEqual = ( (type = _trueTypeOf(var1)) == _trueTypeOf(var2) );
213 | if (isEqual && !isSame) {
214 | switch (type) {
215 | case 'String':
216 | case 'Number':
217 | isEqual = (var1 == var2);
218 | break;
219 | case 'Boolean':
220 | case 'Date':
221 | isEqual = (var1 === var2);
222 | break;
223 | case 'RegExp':
224 | case 'Function':
225 | isEqual = (var1.toString() === var2.toString());
226 | break;
227 | default: //Object | Array
228 | var i;
229 | if (isEqual = (var1.length === var2.length))
230 | for (i in var1)
231 | assertObjectEquals(msg + ' found nested ' + type + '@' + i + '\n', var1[i], var2[i]);
232 | }
233 | _assert(msg, isEqual, 'Expected ' + _displayStringForValue(var1) + ' but was ' + _displayStringForValue(var2));
234 | }
235 | }
236 |
237 | assertArrayEquals = assertObjectEquals;
238 |
239 | function assertEvaluatesToTrue() {
240 | _validateArguments(1, arguments);
241 | var value = nonCommentArg(1, 1, arguments);
242 | if (!value)
243 | fail(commentArg(1, arguments));
244 | }
245 |
246 | function assertEvaluatesToFalse() {
247 | _validateArguments(1, arguments);
248 | var value = nonCommentArg(1, 1, arguments);
249 | if (value)
250 | fail(commentArg(1, arguments));
251 | }
252 |
253 | function assertHTMLEquals() {
254 | _validateArguments(2, arguments);
255 | var var1 = nonCommentArg(1, 2, arguments);
256 | var var2 = nonCommentArg(2, 2, arguments);
257 | var var1Standardized = standardizeHTML(var1);
258 | var var2Standardized = standardizeHTML(var2);
259 |
260 | _assert(commentArg(2, arguments), var1Standardized === var2Standardized, 'Expected ' + _displayStringForValue(var1Standardized) + ' but was ' + _displayStringForValue(var2Standardized));
261 | }
262 |
263 | function assertHashEquals() {
264 | _validateArguments(2, arguments);
265 | var var1 = nonCommentArg(1, 2, arguments);
266 | var var2 = nonCommentArg(2, 2, arguments);
267 | for (var key in var1) {
268 | assertNotUndefined("Expected hash had key " + key + " that was not found", var2[key]);
269 | assertEquals(
270 | "Value for key " + key + " mismatch - expected = " + var1[key] + ", actual = " + var2[key],
271 | var1[key], var2[key]
272 | );
273 | }
274 | for (var key in var2) {
275 | assertNotUndefined("Actual hash had key " + key + " that was not expected", var1[key]);
276 | }
277 | }
278 |
279 | function assertRoughlyEquals() {
280 | _validateArguments(3, arguments);
281 | var expected = nonCommentArg(1, 3, arguments);
282 | var actual = nonCommentArg(2, 3, arguments);
283 | var tolerance = nonCommentArg(3, 3, arguments);
284 | assertTrue(
285 | "Expected " + expected + ", but got " + actual + " which was more than " + tolerance + " away",
286 | Math.abs(expected - actual) < tolerance
287 | );
288 | }
289 |
290 | function assertContains() {
291 | _validateArguments(2, arguments);
292 | var contained = nonCommentArg(1, 2, arguments);
293 | var container = nonCommentArg(2, 2, arguments);
294 | assertTrue(
295 | "Expected '" + container + "' to contain '" + contained + "'",
296 | container.indexOf(contained) != -1
297 | );
298 | }
299 |
300 | function standardizeHTML(html) {
301 | var translator = document.createElement("DIV");
302 | translator.innerHTML = html;
303 | return translator.innerHTML;
304 | }
305 |
306 | function isLoaded() {
307 | return isTestPageLoaded;
308 | }
309 |
310 | function setUp() {
311 | }
312 |
313 | function tearDown() {
314 | }
315 |
316 | function getFunctionName(aFunction) {
317 | var regexpResult = aFunction.toString().match(/function(\s*)(\w*)/);
318 | if (regexpResult && regexpResult.length >= 2 && regexpResult[2]) {
319 | return regexpResult[2];
320 | }
321 | return 'anonymous';
322 | }
323 |
324 | function getStackTrace() {
325 | var result = '';
326 |
327 | if (typeof(arguments.caller) != 'undefined') { // IE, not ECMA
328 | for (var a = arguments.caller; a != null; a = a.caller) {
329 | result += '> ' + getFunctionName(a.callee) + '\n';
330 | if (a.caller == a) {
331 | result += '*';
332 | break;
333 | }
334 | }
335 | }
336 | else { // Mozilla, not ECMA
337 | // fake an exception so we can get Mozilla's error stack
338 | var testExcp;
339 | try
340 | {
341 | foo.bar;
342 | }
343 | catch(testExcp)
344 | {
345 | var stack = parseErrorStack(testExcp);
346 | for (var i = 1; i < stack.length; i++)
347 | {
348 | result += '> ' + stack[i] + '\n';
349 | }
350 | }
351 | }
352 |
353 | return result;
354 | }
355 |
356 | function parseErrorStack(excp)
357 | {
358 | var stack = [];
359 | var name;
360 |
361 | if (!excp || !excp.stack)
362 | {
363 | return stack;
364 | }
365 |
366 | var stacklist = excp.stack.split('\n');
367 |
368 | for (var i = 0; i < stacklist.length - 1; i++)
369 | {
370 | var framedata = stacklist[i];
371 |
372 | name = framedata.match(/^(\w*)/)[1];
373 | if (!name) {
374 | name = 'anonymous';
375 | }
376 |
377 | stack[stack.length] = name;
378 | }
379 | // remove top level anonymous functions to match IE
380 |
381 | while (stack.length && stack[stack.length - 1] == 'anonymous')
382 | {
383 | stack.length = stack.length - 1;
384 | }
385 | return stack;
386 | }
387 |
388 | function JsUnitException(comment, message) {
389 | this.isJsUnitException = true;
390 | this.comment = comment;
391 | this.jsUnitMessage = message;
392 | this.stackTrace = getStackTrace();
393 | }
394 |
395 | function warn() {
396 | if (top.tracer != null)
397 | top.tracer.warn(arguments[0], arguments[1]);
398 | }
399 |
400 | function inform() {
401 | if (top.tracer != null)
402 | top.tracer.inform(arguments[0], arguments[1]);
403 | }
404 |
405 | function info() {
406 | inform(arguments[0], arguments[1]);
407 | }
408 |
409 | function debug() {
410 | if (top.tracer != null)
411 | top.tracer.debug(arguments[0], arguments[1]);
412 | }
413 |
414 | function setJsUnitTracer(aJsUnitTracer) {
415 | top.tracer = aJsUnitTracer;
416 | }
417 |
418 | function trim(str) {
419 | if (str == null)
420 | return null;
421 |
422 | var startingIndex = 0;
423 | var endingIndex = str.length - 1;
424 |
425 | while (str.substring(startingIndex, startingIndex + 1) == ' ')
426 | startingIndex++;
427 |
428 | while (str.substring(endingIndex, endingIndex + 1) == ' ')
429 | endingIndex--;
430 |
431 | if (endingIndex < startingIndex)
432 | return '';
433 |
434 | return str.substring(startingIndex, endingIndex + 1);
435 | }
436 |
437 | function isBlank(str) {
438 | return trim(str) == '';
439 | }
440 |
441 | // the functions push(anArray, anObject) and pop(anArray)
442 | // exist because the JavaScript Array.push(anObject) and Array.pop()
443 | // functions are not available in IE 5.0
444 |
445 | function push(anArray, anObject) {
446 | anArray[anArray.length] = anObject;
447 | }
448 | function pop(anArray) {
449 | if (anArray.length >= 1) {
450 | delete anArray[anArray.length - 1];
451 | anArray.length--;
452 | }
453 | }
454 |
455 | function jsUnitGetParm(name)
456 | {
457 | if (typeof(top.jsUnitParmHash[name]) != 'undefined')
458 | {
459 | return top.jsUnitParmHash[name];
460 | }
461 | return null;
462 | }
463 |
464 | if (top && typeof(top.xbDEBUG) != 'undefined' && top.xbDEBUG.on && top.testManager)
465 | {
466 | top.xbDebugTraceObject('top.testManager.containerTestFrame', 'JSUnitException');
467 | // asserts
468 | top.xbDebugTraceFunction('top.testManager.containerTestFrame', '_displayStringForValue');
469 | top.xbDebugTraceFunction('top.testManager.containerTestFrame', 'error');
470 | top.xbDebugTraceFunction('top.testManager.containerTestFrame', 'argumentsIncludeComments');
471 | top.xbDebugTraceFunction('top.testManager.containerTestFrame', 'commentArg');
472 | top.xbDebugTraceFunction('top.testManager.containerTestFrame', 'nonCommentArg');
473 | top.xbDebugTraceFunction('top.testManager.containerTestFrame', '_validateArguments');
474 | top.xbDebugTraceFunction('top.testManager.containerTestFrame', '_assert');
475 | top.xbDebugTraceFunction('top.testManager.containerTestFrame', 'assert');
476 | top.xbDebugTraceFunction('top.testManager.containerTestFrame', 'assertTrue');
477 | top.xbDebugTraceFunction('top.testManager.containerTestFrame', 'assertEquals');
478 | top.xbDebugTraceFunction('top.testManager.containerTestFrame', 'assertNotEquals');
479 | top.xbDebugTraceFunction('top.testManager.containerTestFrame', 'assertNull');
480 | top.xbDebugTraceFunction('top.testManager.containerTestFrame', 'assertNotNull');
481 | top.xbDebugTraceFunction('top.testManager.containerTestFrame', 'assertUndefined');
482 | top.xbDebugTraceFunction('top.testManager.containerTestFrame', 'assertNotUndefined');
483 | top.xbDebugTraceFunction('top.testManager.containerTestFrame', 'assertNaN');
484 | top.xbDebugTraceFunction('top.testManager.containerTestFrame', 'assertNotNaN');
485 | top.xbDebugTraceFunction('top.testManager.containerTestFrame', 'isLoaded');
486 | top.xbDebugTraceFunction('top.testManager.containerTestFrame', 'setUp');
487 | top.xbDebugTraceFunction('top.testManager.containerTestFrame', 'tearDown');
488 | top.xbDebugTraceFunction('top.testManager.containerTestFrame', 'getFunctionName');
489 | top.xbDebugTraceFunction('top.testManager.containerTestFrame', 'getStackTrace');
490 | top.xbDebugTraceFunction('top.testManager.containerTestFrame', 'warn');
491 | top.xbDebugTraceFunction('top.testManager.containerTestFrame', 'inform');
492 | top.xbDebugTraceFunction('top.testManager.containerTestFrame', 'debug');
493 | top.xbDebugTraceFunction('top.testManager.containerTestFrame', 'setJsUnitTracer');
494 | top.xbDebugTraceFunction('top.testManager.containerTestFrame', 'trim');
495 | top.xbDebugTraceFunction('top.testManager.containerTestFrame', 'isBlank');
496 | top.xbDebugTraceFunction('top.testManager.containerTestFrame', 'newOnLoadEvent');
497 | top.xbDebugTraceFunction('top.testManager.containerTestFrame', 'push');
498 | top.xbDebugTraceFunction('top.testManager.containerTestFrame', 'pop');
499 | }
500 |
501 | function newOnLoadEvent() {
502 | isTestPageLoaded = true;
503 | }
504 |
505 | function jsUnitSetOnLoad(windowRef, onloadHandler)
506 | {
507 | var isKonqueror = navigator.userAgent.indexOf('Konqueror/') != -1 ||
508 | navigator.userAgent.indexOf('Safari/') != -1;
509 |
510 | if (typeof(windowRef.attachEvent) != 'undefined') {
511 | // Internet Explorer, Opera
512 | windowRef.attachEvent("onload", onloadHandler);
513 | } else if (typeof(windowRef.addEventListener) != 'undefined' && !isKonqueror) {
514 | // Mozilla, Konqueror
515 | // exclude Konqueror due to load issues
516 | windowRef.addEventListener("load", onloadHandler, false);
517 | } else if (typeof(windowRef.document.addEventListener) != 'undefined' && !isKonqueror) {
518 | // DOM 2 Events
519 | // exclude Mozilla, Konqueror due to load issues
520 | windowRef.document.addEventListener("load", onloadHandler, false);
521 | } else if (typeof(windowRef.onload) != 'undefined' && windowRef.onload) {
522 | windowRef.jsunit_original_onload = windowRef.onload;
523 | windowRef.onload = function() {
524 | windowRef.jsunit_original_onload();
525 | onloadHandler();
526 | };
527 | } else {
528 | // browsers that do not support windowRef.attachEvent or
529 | // windowRef.addEventListener will override a page's own onload event
530 | windowRef.onload = onloadHandler;
531 | }
532 | }
533 |
534 | jsUnitSetOnLoad(window, newOnLoadEvent);
--------------------------------------------------------------------------------