From e44a7e37b6c7b5961adaffc62b9042b8d442938e Mon Sep 17 00:00:00 2001 From: mensonge Date: Thu, 13 Nov 2008 09:49:11 +0000 Subject: New feature: basic Ajax suggestion for tags and implementation of Dojo toolkit git-svn-id: https://semanticscuttle.svn.sourceforge.net/svnroot/semanticscuttle/trunk@151 b3834d28-1941-0410-a4f8-b48e95affb8f --- includes/js/dojo/tests/AdapterRegistry.js | 75 + includes/js/dojo/tests/DeferredList.js | 206 ++ includes/js/dojo/tests/NodeList-fx.html | 150 ++ includes/js/dojo/tests/TODO | 11 + includes/js/dojo/tests/_base.js | 136 ++ includes/js/dojo/tests/_base/Color.js | 32 + includes/js/dojo/tests/_base/Deferred.js | 76 + includes/js/dojo/tests/_base/NodeList.html | 370 ++++ .../js/dojo/tests/_base/_loader/addLoadEvents.html | 37 + .../js/dojo/tests/_base/_loader/afterOnLoad.html | 56 + includes/js/dojo/tests/_base/_loader/bootstrap.js | 86 + includes/js/dojo/tests/_base/_loader/getText.txt | 1 + .../js/dojo/tests/_base/_loader/hostenv_browser.js | 15 + .../js/dojo/tests/_base/_loader/hostenv_rhino.js | 17 + .../tests/_base/_loader/hostenv_spidermonkey.js | 15 + includes/js/dojo/tests/_base/_loader/loader.js | 52 + .../js/dojo/tests/_base/_loader/scope/scope04.html | 80 + .../tests/_base/_loader/scope/scopeContained.html | 71 + .../_base/_loader/scope/scopeContainedXd.html | 84 + .../tests/_base/_loader/scope/scopeDjConfig.html | 64 + .../tests/_base/_loader/scope/scopeSingle.html | 62 + .../tests/_base/_loader/scope/scopeSingleDaac.html | 63 + includes/js/dojo/tests/_base/array.js | 301 +++ includes/js/dojo/tests/_base/connect.js | 225 ++ includes/js/dojo/tests/_base/declare.js | 197 ++ includes/js/dojo/tests/_base/fx.html | 342 +++ includes/js/dojo/tests/_base/fx.js | 8 + includes/js/dojo/tests/_base/fx_delay.html | 22 + includes/js/dojo/tests/_base/html.html | 556 +++++ includes/js/dojo/tests/_base/html.js | 12 + includes/js/dojo/tests/_base/html_box.html | 207 ++ includes/js/dojo/tests/_base/html_box_quirks.html | 205 ++ includes/js/dojo/tests/_base/html_quirks.html | 322 +++ includes/js/dojo/tests/_base/html_rtl.html | 110 + includes/js/dojo/tests/_base/json.js | 37 + includes/js/dojo/tests/_base/lang.js | 180 ++ includes/js/dojo/tests/_base/query.html | 154 ++ includes/js/dojo/tests/_base/query.js | 9 + includes/js/dojo/tests/_base/timeout.php | 7 + includes/js/dojo/tests/_base/xhr.html | 404 ++++ includes/js/dojo/tests/_base/xhr.js | 8 + includes/js/dojo/tests/_base/xhrDummyMethod.php | 7 + includes/js/dojo/tests/back-hash.js | 33 + includes/js/dojo/tests/back.html | 107 + includes/js/dojo/tests/back.js | 8 + includes/js/dojo/tests/behavior.html | 106 + includes/js/dojo/tests/behavior.js | 8 + includes/js/dojo/tests/cldr.js | 19 + includes/js/dojo/tests/colors.js | 48 + includes/js/dojo/tests/cookie.html | 84 + includes/js/dojo/tests/cookie.js | 8 + includes/js/dojo/tests/currency.js | 48 + includes/js/dojo/tests/data.js | 12 + includes/js/dojo/tests/data/ItemFileReadStore.js | 10 + includes/js/dojo/tests/data/ItemFileWriteStore.js | 1402 ++++++++++++ includes/js/dojo/tests/data/countries.json | 11 + .../dojo/tests/data/countries_commentFiltered.json | 12 + .../js/dojo/tests/data/countries_idcollision.json | 10 + .../js/dojo/tests/data/countries_references.json | 44 + .../js/dojo/tests/data/countries_withBoolean.json | 11 + .../js/dojo/tests/data/countries_withDates.json | 21 + .../js/dojo/tests/data/countries_withNull.json | 10 + .../js/dojo/tests/data/countries_withoutid.json | 10 + includes/js/dojo/tests/data/data_multitype.json | 18 + .../dojo/tests/data/geography_hierarchy_large.json | 44 + .../dojo/tests/data/geography_hierarchy_small.json | 19 + .../tests/data/readOnlyItemFileTestTemplates.js | 2260 ++++++++++++++++++++ .../js/dojo/tests/data/reference_integrity.json | 27 + includes/js/dojo/tests/data/runTests.html | 9 + includes/js/dojo/tests/data/utils.js | 203 ++ includes/js/dojo/tests/date.js | 716 +++++++ includes/js/dojo/tests/date/locale.js | 398 ++++ includes/js/dojo/tests/date/stamp.js | 94 + includes/js/dojo/tests/dnd/dndDefault.css | 52 + .../js/dojo/tests/dnd/dndDefault.css.commented.css | 69 + includes/js/dojo/tests/dnd/flickr_viewer.html | 168 ++ .../js/dojo/tests/dnd/test_box_constraints.html | 61 + includes/js/dojo/tests/dnd/test_container.html | 74 + .../js/dojo/tests/dnd/test_container_markup.html | 67 + .../js/dojo/tests/dnd/test_custom_constraints.html | 51 + includes/js/dojo/tests/dnd/test_dnd.html | 130 ++ includes/js/dojo/tests/dnd/test_dnd_handles.html | 65 + includes/js/dojo/tests/dnd/test_form.html | 103 + includes/js/dojo/tests/dnd/test_moveable.html | 106 + .../js/dojo/tests/dnd/test_moveable_markup.html | 83 + includes/js/dojo/tests/dnd/test_params.html | 61 + .../js/dojo/tests/dnd/test_parent_constraints.html | 53 + .../tests/dnd/test_parent_constraints_margins.html | 51 + includes/js/dojo/tests/dnd/test_selector.html | 80 + .../js/dojo/tests/dnd/test_selector_markup.html | 71 + .../js/dojo/tests/dnd/test_timed_moveable.html | 112 + includes/js/dojo/tests/fx.html | 310 +++ includes/js/dojo/tests/fx.js | 9 + includes/js/dojo/tests/i18n.js | 88 + includes/js/dojo/tests/io/iframe.html | 124 ++ includes/js/dojo/tests/io/iframe.js | 8 + includes/js/dojo/tests/io/iframeResponse.html | 8 + includes/js/dojo/tests/io/iframeResponse.js.html | 7 + includes/js/dojo/tests/io/iframeResponse.json.html | 7 + includes/js/dojo/tests/io/iframeResponse.text.html | 7 + includes/js/dojo/tests/io/iframeUploadTest.html | 50 + includes/js/dojo/tests/io/script.html | 101 + includes/js/dojo/tests/io/script.js | 8 + includes/js/dojo/tests/io/scriptJsonp.js | 57 + includes/js/dojo/tests/io/scriptSimple.js | 5 + includes/js/dojo/tests/io/scriptTimeout.html | 67 + includes/js/dojo/tests/io/upload.cgi | 60 + includes/js/dojo/tests/manualTests.html | 12 + includes/js/dojo/tests/manualTests.js | 45 + includes/js/dojo/tests/module.js | 29 + includes/js/dojo/tests/nls/ar/salutations.js | 1 + includes/js/dojo/tests/nls/cs/salutations.js | 1 + includes/js/dojo/tests/nls/de/salutations.js | 1 + includes/js/dojo/tests/nls/el/salutations.js | 1 + includes/js/dojo/tests/nls/en-au/salutations.js | 1 + .../js/dojo/tests/nls/en-us-hawaii/salutations.js | 1 + .../nls/en-us-new_york-brooklyn/salutations.js | 1 + .../js/dojo/tests/nls/en-us-texas/salutations.js | 1 + includes/js/dojo/tests/nls/es/salutations.js | 1 + includes/js/dojo/tests/nls/fa/salutations.js | 1 + includes/js/dojo/tests/nls/fr/salutations.js | 1 + includes/js/dojo/tests/nls/he/salutations.js | 1 + includes/js/dojo/tests/nls/hi/salutations.js | 1 + includes/js/dojo/tests/nls/it/salutations.js | 1 + includes/js/dojo/tests/nls/ja/salutations.js | 1 + includes/js/dojo/tests/nls/ko/salutations.js | 1 + includes/js/dojo/tests/nls/pl/salutations.js | 1 + includes/js/dojo/tests/nls/pt/salutations.js | 1 + includes/js/dojo/tests/nls/ru/salutations.js | 1 + includes/js/dojo/tests/nls/salutations.js | 1 + includes/js/dojo/tests/nls/sw/salutations.js | 1 + includes/js/dojo/tests/nls/th/salutations.js | 1 + includes/js/dojo/tests/nls/tr/salutations.js | 1 + includes/js/dojo/tests/nls/yi/salutations.js | 1 + includes/js/dojo/tests/nls/zh-cn/salutations.js | 1 + includes/js/dojo/tests/nls/zh-tw/salutations.js | 1 + includes/js/dojo/tests/number.js | 966 +++++++++ includes/js/dojo/tests/parser.html | 241 +++ includes/js/dojo/tests/parser.js | 8 + .../js/dojo/tests/resources/ApplicationState.js | 28 + includes/js/dojo/tests/resources/JSON.php | 724 +++++++ includes/js/dojo/tests/resources/testClass.php | 20 + includes/js/dojo/tests/resources/testClass.smd | 40 + .../dojo/tests/resources/test_JsonRPCMediator.php | 43 + includes/js/dojo/tests/resources/test_css.html | 100 + includes/js/dojo/tests/resources/yahoo_smd_v1.smd | 268 +++ includes/js/dojo/tests/rpc.js | 151 ++ includes/js/dojo/tests/runTests.html | 9 + includes/js/dojo/tests/string.js | 31 + includes/js/dojo/tests/test_FirebugLite.html | 100 + includes/js/dojo/tests/test_FirebugLitePopup.html | 101 + includes/js/dojo/tests/test_fx.html | 107 + 152 files changed, 16304 insertions(+) create mode 100644 includes/js/dojo/tests/AdapterRegistry.js create mode 100644 includes/js/dojo/tests/DeferredList.js create mode 100644 includes/js/dojo/tests/NodeList-fx.html create mode 100644 includes/js/dojo/tests/TODO create mode 100644 includes/js/dojo/tests/_base.js create mode 100644 includes/js/dojo/tests/_base/Color.js create mode 100644 includes/js/dojo/tests/_base/Deferred.js create mode 100644 includes/js/dojo/tests/_base/NodeList.html create mode 100644 includes/js/dojo/tests/_base/_loader/addLoadEvents.html create mode 100644 includes/js/dojo/tests/_base/_loader/afterOnLoad.html create mode 100644 includes/js/dojo/tests/_base/_loader/bootstrap.js create mode 100644 includes/js/dojo/tests/_base/_loader/getText.txt create mode 100644 includes/js/dojo/tests/_base/_loader/hostenv_browser.js create mode 100644 includes/js/dojo/tests/_base/_loader/hostenv_rhino.js create mode 100644 includes/js/dojo/tests/_base/_loader/hostenv_spidermonkey.js create mode 100644 includes/js/dojo/tests/_base/_loader/loader.js create mode 100644 includes/js/dojo/tests/_base/_loader/scope/scope04.html create mode 100644 includes/js/dojo/tests/_base/_loader/scope/scopeContained.html create mode 100644 includes/js/dojo/tests/_base/_loader/scope/scopeContainedXd.html create mode 100644 includes/js/dojo/tests/_base/_loader/scope/scopeDjConfig.html create mode 100644 includes/js/dojo/tests/_base/_loader/scope/scopeSingle.html create mode 100644 includes/js/dojo/tests/_base/_loader/scope/scopeSingleDaac.html create mode 100644 includes/js/dojo/tests/_base/array.js create mode 100644 includes/js/dojo/tests/_base/connect.js create mode 100644 includes/js/dojo/tests/_base/declare.js create mode 100644 includes/js/dojo/tests/_base/fx.html create mode 100644 includes/js/dojo/tests/_base/fx.js create mode 100644 includes/js/dojo/tests/_base/fx_delay.html create mode 100644 includes/js/dojo/tests/_base/html.html create mode 100644 includes/js/dojo/tests/_base/html.js create mode 100644 includes/js/dojo/tests/_base/html_box.html create mode 100644 includes/js/dojo/tests/_base/html_box_quirks.html create mode 100644 includes/js/dojo/tests/_base/html_quirks.html create mode 100644 includes/js/dojo/tests/_base/html_rtl.html create mode 100644 includes/js/dojo/tests/_base/json.js create mode 100644 includes/js/dojo/tests/_base/lang.js create mode 100644 includes/js/dojo/tests/_base/query.html create mode 100644 includes/js/dojo/tests/_base/query.js create mode 100644 includes/js/dojo/tests/_base/timeout.php create mode 100644 includes/js/dojo/tests/_base/xhr.html create mode 100644 includes/js/dojo/tests/_base/xhr.js create mode 100644 includes/js/dojo/tests/_base/xhrDummyMethod.php create mode 100644 includes/js/dojo/tests/back-hash.js create mode 100644 includes/js/dojo/tests/back.html create mode 100644 includes/js/dojo/tests/back.js create mode 100644 includes/js/dojo/tests/behavior.html create mode 100644 includes/js/dojo/tests/behavior.js create mode 100644 includes/js/dojo/tests/cldr.js create mode 100644 includes/js/dojo/tests/colors.js create mode 100644 includes/js/dojo/tests/cookie.html create mode 100644 includes/js/dojo/tests/cookie.js create mode 100644 includes/js/dojo/tests/currency.js create mode 100644 includes/js/dojo/tests/data.js create mode 100644 includes/js/dojo/tests/data/ItemFileReadStore.js create mode 100644 includes/js/dojo/tests/data/ItemFileWriteStore.js create mode 100644 includes/js/dojo/tests/data/countries.json create mode 100644 includes/js/dojo/tests/data/countries_commentFiltered.json create mode 100644 includes/js/dojo/tests/data/countries_idcollision.json create mode 100644 includes/js/dojo/tests/data/countries_references.json create mode 100644 includes/js/dojo/tests/data/countries_withBoolean.json create mode 100644 includes/js/dojo/tests/data/countries_withDates.json create mode 100644 includes/js/dojo/tests/data/countries_withNull.json create mode 100644 includes/js/dojo/tests/data/countries_withoutid.json create mode 100644 includes/js/dojo/tests/data/data_multitype.json create mode 100644 includes/js/dojo/tests/data/geography_hierarchy_large.json create mode 100644 includes/js/dojo/tests/data/geography_hierarchy_small.json create mode 100644 includes/js/dojo/tests/data/readOnlyItemFileTestTemplates.js create mode 100644 includes/js/dojo/tests/data/reference_integrity.json create mode 100644 includes/js/dojo/tests/data/runTests.html create mode 100644 includes/js/dojo/tests/data/utils.js create mode 100644 includes/js/dojo/tests/date.js create mode 100644 includes/js/dojo/tests/date/locale.js create mode 100644 includes/js/dojo/tests/date/stamp.js create mode 100644 includes/js/dojo/tests/dnd/dndDefault.css create mode 100644 includes/js/dojo/tests/dnd/dndDefault.css.commented.css create mode 100644 includes/js/dojo/tests/dnd/flickr_viewer.html create mode 100644 includes/js/dojo/tests/dnd/test_box_constraints.html create mode 100644 includes/js/dojo/tests/dnd/test_container.html create mode 100644 includes/js/dojo/tests/dnd/test_container_markup.html create mode 100644 includes/js/dojo/tests/dnd/test_custom_constraints.html create mode 100644 includes/js/dojo/tests/dnd/test_dnd.html create mode 100644 includes/js/dojo/tests/dnd/test_dnd_handles.html create mode 100644 includes/js/dojo/tests/dnd/test_form.html create mode 100644 includes/js/dojo/tests/dnd/test_moveable.html create mode 100644 includes/js/dojo/tests/dnd/test_moveable_markup.html create mode 100644 includes/js/dojo/tests/dnd/test_params.html create mode 100644 includes/js/dojo/tests/dnd/test_parent_constraints.html create mode 100644 includes/js/dojo/tests/dnd/test_parent_constraints_margins.html create mode 100644 includes/js/dojo/tests/dnd/test_selector.html create mode 100644 includes/js/dojo/tests/dnd/test_selector_markup.html create mode 100644 includes/js/dojo/tests/dnd/test_timed_moveable.html create mode 100644 includes/js/dojo/tests/fx.html create mode 100644 includes/js/dojo/tests/fx.js create mode 100644 includes/js/dojo/tests/i18n.js create mode 100644 includes/js/dojo/tests/io/iframe.html create mode 100644 includes/js/dojo/tests/io/iframe.js create mode 100644 includes/js/dojo/tests/io/iframeResponse.html create mode 100644 includes/js/dojo/tests/io/iframeResponse.js.html create mode 100644 includes/js/dojo/tests/io/iframeResponse.json.html create mode 100644 includes/js/dojo/tests/io/iframeResponse.text.html create mode 100644 includes/js/dojo/tests/io/iframeUploadTest.html create mode 100644 includes/js/dojo/tests/io/script.html create mode 100644 includes/js/dojo/tests/io/script.js create mode 100644 includes/js/dojo/tests/io/scriptJsonp.js create mode 100644 includes/js/dojo/tests/io/scriptSimple.js create mode 100644 includes/js/dojo/tests/io/scriptTimeout.html create mode 100644 includes/js/dojo/tests/io/upload.cgi create mode 100644 includes/js/dojo/tests/manualTests.html create mode 100644 includes/js/dojo/tests/manualTests.js create mode 100644 includes/js/dojo/tests/module.js create mode 100644 includes/js/dojo/tests/nls/ar/salutations.js create mode 100644 includes/js/dojo/tests/nls/cs/salutations.js create mode 100644 includes/js/dojo/tests/nls/de/salutations.js create mode 100644 includes/js/dojo/tests/nls/el/salutations.js create mode 100644 includes/js/dojo/tests/nls/en-au/salutations.js create mode 100644 includes/js/dojo/tests/nls/en-us-hawaii/salutations.js create mode 100644 includes/js/dojo/tests/nls/en-us-new_york-brooklyn/salutations.js create mode 100644 includes/js/dojo/tests/nls/en-us-texas/salutations.js create mode 100644 includes/js/dojo/tests/nls/es/salutations.js create mode 100644 includes/js/dojo/tests/nls/fa/salutations.js create mode 100644 includes/js/dojo/tests/nls/fr/salutations.js create mode 100644 includes/js/dojo/tests/nls/he/salutations.js create mode 100644 includes/js/dojo/tests/nls/hi/salutations.js create mode 100644 includes/js/dojo/tests/nls/it/salutations.js create mode 100644 includes/js/dojo/tests/nls/ja/salutations.js create mode 100644 includes/js/dojo/tests/nls/ko/salutations.js create mode 100644 includes/js/dojo/tests/nls/pl/salutations.js create mode 100644 includes/js/dojo/tests/nls/pt/salutations.js create mode 100644 includes/js/dojo/tests/nls/ru/salutations.js create mode 100644 includes/js/dojo/tests/nls/salutations.js create mode 100644 includes/js/dojo/tests/nls/sw/salutations.js create mode 100644 includes/js/dojo/tests/nls/th/salutations.js create mode 100644 includes/js/dojo/tests/nls/tr/salutations.js create mode 100644 includes/js/dojo/tests/nls/yi/salutations.js create mode 100644 includes/js/dojo/tests/nls/zh-cn/salutations.js create mode 100644 includes/js/dojo/tests/nls/zh-tw/salutations.js create mode 100644 includes/js/dojo/tests/number.js create mode 100644 includes/js/dojo/tests/parser.html create mode 100644 includes/js/dojo/tests/parser.js create mode 100644 includes/js/dojo/tests/resources/ApplicationState.js create mode 100644 includes/js/dojo/tests/resources/JSON.php create mode 100644 includes/js/dojo/tests/resources/testClass.php create mode 100644 includes/js/dojo/tests/resources/testClass.smd create mode 100644 includes/js/dojo/tests/resources/test_JsonRPCMediator.php create mode 100644 includes/js/dojo/tests/resources/test_css.html create mode 100644 includes/js/dojo/tests/resources/yahoo_smd_v1.smd create mode 100644 includes/js/dojo/tests/rpc.js create mode 100644 includes/js/dojo/tests/runTests.html create mode 100644 includes/js/dojo/tests/string.js create mode 100644 includes/js/dojo/tests/test_FirebugLite.html create mode 100644 includes/js/dojo/tests/test_FirebugLitePopup.html create mode 100644 includes/js/dojo/tests/test_fx.html (limited to 'includes/js/dojo/tests') diff --git a/includes/js/dojo/tests/AdapterRegistry.js b/includes/js/dojo/tests/AdapterRegistry.js new file mode 100644 index 0000000..4565e27 --- /dev/null +++ b/includes/js/dojo/tests/AdapterRegistry.js @@ -0,0 +1,75 @@ +if(!dojo._hasResource["tests.AdapterRegistry"]){ //_hasResource checks added by build. Do not use _hasResource directly in your code. +dojo._hasResource["tests.AdapterRegistry"] = true; +dojo.provide("tests.AdapterRegistry"); +dojo.require("dojo.AdapterRegistry"); + +doh.register("tests.AdapterRegistry", + [ + function ctor(t){ + var taa = new dojo.AdapterRegistry(); + t.is(0, taa.pairs.length); + t.f(taa.returnWrappers); + + var taa = new dojo.AdapterRegistry(true); + t.t(taa.returnWrappers); + }, + + function register(t){ + var taa = new dojo.AdapterRegistry(); + taa.register("blah", + function(str){ return str == "blah"; }, + function(){ return "blah"; } + ); + t.is(1, taa.pairs.length); + t.is("blah", taa.pairs[0][0]); + + taa.register("thinger"); + taa.register("prepend", null, null, true, true); + t.is("prepend", taa.pairs[0][0]); + t.t(taa.pairs[0][3]); + }, + + /* + function match(t){ + }, + */ + + function noMatch(t){ + var taa = new dojo.AdapterRegistry(); + var threw = false; + try{ + taa.match("blah"); + }catch(e){ + threw = true; + } + t.t(threw); + }, + + function returnWrappers(t){ + var taa = new dojo.AdapterRegistry(); + taa.register("blah", + function(str){ return str == "blah"; }, + function(){ return "blah"; } + ); + t.is("blah", taa.match("blah")); + + taa.returnWrappers = true; + t.is("blah", taa.match("blah")()); + }, + + function unregister(t){ + var taa = new dojo.AdapterRegistry(); + taa.register("blah", + function(str){ return str == "blah"; }, + function(){ return "blah"; } + ); + taa.register("thinger"); + taa.register("prepend", null, null, true, true); + taa.unregister("prepend"); + t.is(2, taa.pairs.length); + t.is("blah", taa.pairs[0][0]); + } + ] +); + +} diff --git a/includes/js/dojo/tests/DeferredList.js b/includes/js/dojo/tests/DeferredList.js new file mode 100644 index 0000000..9353bfa --- /dev/null +++ b/includes/js/dojo/tests/DeferredList.js @@ -0,0 +1,206 @@ +if(!dojo._hasResource["tests.DeferredList"]){ //_hasResource checks added by build. Do not use _hasResource directly in your code. +dojo._hasResource["tests.DeferredList"] = true; +dojo.provide("tests.DeferredList"); + +dojo.require("dojo.DeferredList"); + +doh.register("tests.DeferredList", + [ + function callback(t){ + var d1 = new dojo.Deferred(); + var d2 = new dojo.Deferred(); + var dl = new dojo.DeferredList([d1, d2]); + var fired = false; + + dl.addCallback(function(res){ + doh.debug("debug from dojo.DeferredList callback"); + return res; + }); + dl.addCallback(function(res){ + console.log("res: ", res, res.length); + t.assertTrue(res.length == 2); + t.assertTrue(res[0][0]); + t.assertEqual(res[0][1], "foo"); + t.assertTrue(res[1][0]); + t.assertEqual(res[1][1], "bar"); + fired = true; + return res; + }); + d1.callback("foo"); + d2.callback("bar"); + t.assertTrue(fired); + }, + + function errback(t){ + var d1 = new dojo.Deferred(); + var d2 = new dojo.Deferred(); + var dl = new dojo.DeferredList([d1, d2]); + var fired = false; + var e1 = new Error("foo"); + var e2 = new Error("bar"); + + dl.addCallback(function(res){ + doh.debug("debug from dojo.DeferredList callback"); + return res; + }); + dl.addCallback(function(res){ + t.assertTrue(res.length == 2); + t.assertTrue(!res[0][0]); + + t.assertEqual(res[0][1], e1); + t.assertTrue(!res[1][0]); + t.assertEqual(res[1][1], e2); + fired = true; + return res; + }); + d1.errback(e1); + d2.errback(e2); + t.assertTrue(fired); + }, + + + function mixed(t){ + var d1 = new dojo.Deferred(); + var d2 = new dojo.Deferred(); + var dl = new dojo.DeferredList([d1, d2]); + var fired = false; + var e = new Error("foo"); + + dl.addCallback(function(res){ + doh.debug("debug from dojo.DeferredList callback"); + return res; + }); + dl.addCallback(function(res){ + t.assertTrue(res.length == 2); + t.assertTrue(!res[0][0]); + + t.assertEqual(res[0][1], e); + t.assertTrue(res[1][0]); + t.assertEqual(res[1][1], "bar"); + fired = true; + return res; + }); + d1.errback(e); + d2.callback("bar"); + t.assertTrue(fired); + }, + + function gather(t){ + var d1 = new dojo.Deferred(); + var d2 = new dojo.Deferred(); + var dl = dojo.DeferredList.prototype.gatherResults([d1, d2]); + var fired = false; + dl.addCallback(function(res){ + t.assertEqual(res[0], "foo"); + t.assertEqual(res[1], "bar"); + fired = true; + return res; + }); + d1.callback("foo"); + d2.callback("bar"); + t.assertTrue(fired); + } + ] +); +dojo.provide("tests.DeferredList"); + +dojo.require("dojo.DeferredList"); + +doh.register("tests.DeferredList", + [ + function callback(t){ + var d1 = new dojo.Deferred(); + var d2 = new dojo.Deferred(); + var dl = new dojo.DeferredList([d1, d2]); + var fired = false; + dl.addCallback(function(res){ + doh.debug("debug from dojo.DeferredList callback"); + return res; + }); + dl.addCallback(function(res){ + t.assertTrue(res.length == 2); + t.assertTrue(res[0][0]); + t.assertEqual(res[0][1], "foo"); + t.assertTrue(res[1][0]); + t.assertEqual(res[1][1], "bar"); + fired = true; + return res; + }); + d1.callback("foo"); + d2.callback("bar"); + t.assertTrue(fired); + }, + + function errback(t){ + var d1 = new dojo.Deferred(); + var d2 = new dojo.Deferred(); + var dl = new dojo.DeferredList([d1, d2]); + var fired = false; + var e1 = new Error("foo"); + var e2 = new Error("bar"); + + dl.addCallback(function(res){ + doh.debug("debug from dojo.DeferredList callback"); + return res; + }); + dl.addCallback(function(res){ + t.assertTrue(res.length == 2); + t.assertTrue(!res[0][0]); + + t.assertEqual(res[0][1], e1); + t.assertTrue(!res[1][0]); + t.assertEqual(res[1][1], e2); + fired = true; + return res; + }); + d1.errback(e1); + d2.errback(e2); + t.assertTrue(fired); + }, + + + function mixed(t){ + var d1 = new dojo.Deferred(); + var d2 = new dojo.Deferred(); + var dl = new dojo.DeferredList([d1, d2]); + var fired = false; + var e = new Error("foo"); + + dl.addCallback(function(res){ + doh.debug("debug from dojo.DeferredList callback"); + return res; + }); + dl.addCallback(function(res){ + t.assertTrue(res.length == 2); + t.assertTrue(!res[0][0]); + + t.assertEqual(res[0][1], e); + t.assertTrue(res[1][0]); + t.assertEqual(res[1][1], "bar"); + fired = true; + return res; + }); + d1.errback(e); + d2.callback("bar"); + t.assertTrue(fired); + }, + + function gather(t){ + var d1 = new dojo.Deferred(); + var d2 = new dojo.Deferred(); + var dl = dojo.DeferredList.prototype.gatherResults([d1, d2]); + var fired = false; + dl.addCallback(function(res){ + t.assertEqual(res[0], "foo"); + t.assertEqual(res[1], "bar"); + fired = true; + return res; + }); + d1.callback("foo"); + d2.callback("bar"); + t.assertTrue(fired); + } + ] +); + +} diff --git a/includes/js/dojo/tests/NodeList-fx.html b/includes/js/dojo/tests/NodeList-fx.html new file mode 100644 index 0000000..07fdbe0 --- /dev/null +++ b/includes/js/dojo/tests/NodeList-fx.html @@ -0,0 +1,150 @@ + + +
++ Lorem ipsum dolor sit amet, consectetuer adipiscing elit. Aenean semper + sagittis velit. Cras in mi. Duis porta mauris ut ligula. Proin porta + rutrum lacus. Etiam consequat scelerisque quam. Nulla facilisi. + Maecenas luctus venenatis nulla. In sit amet dui non mi semper iaculis. + Sed molestie tortor at ipsum. Morbi dictum rutrum magna. Sed vitae + risus. +
++ Aliquam vitae enim. Duis scelerisque metus auctor est venenatis + imperdiet. Fusce dignissim porta augue. Nulla vestibulum. Integer lorem + nunc, ullamcorper a, commodo ac, malesuada sed, dolor. Aenean id mi in + massa bibendum suscipit. Integer eros. Nullam suscipit mauris. In + pellentesque. Mauris ipsum est, pharetra semper, pharetra in, viverra + quis, tellus. Etiam purus. Quisque egestas, tortor ac cursus lacinia, + felis leo adipiscing nisi, et rhoncus elit dolor eget eros. Fusce ut + quam. Suspendisse eleifend leo vitae ligula. Nulla facilisi. Nulla + rutrum, erat vitae lacinia dictum, pede purus imperdiet lacus, ut + semper velit ante id metus. Praesent massa dolor, porttitor sed, + pulvinar in, consequat ut, leo. Nullam nec est. Aenean id risus blandit + tortor pharetra congue. Suspendisse pulvinar. +
++ Aliquam vitae enim. Duis scelerisque metus auctor est venenatis + imperdiet. Fusce dignissim porta augue. Nulla vestibulum. Integer lorem + nunc, ullamcorper a, commodo ac, malesuada sed, dolor. Aenean id mi in + massa bibendum suscipit. Integer eros. Nullam suscipit mauris. In + pellentesque. Mauris ipsum est, pharetra semper, pharetra in, viverra + quis, tellus. Etiam purus. Quisque egestas, tortor ac cursus lacinia, + felis leo adipiscing nisi, et rhoncus elit dolor eget eros. Fusce ut + quam. Suspendisse eleifend leo vitae ligula. Nulla facilisi. Nulla + rutrum, erat vitae lacinia dictum, pede purus imperdiet lacus, ut + semper velit ante id metus. Praesent massa dolor, porttitor sed, + pulvinar in, consequat ut, leo. Nullam nec est. Aenean id risus blandit + tortor pharetra congue. Suspendisse pulvinar. +
+ + + diff --git a/includes/js/dojo/tests/TODO b/includes/js/dojo/tests/TODO new file mode 100644 index 0000000..c18bc3a --- /dev/null +++ b/includes/js/dojo/tests/TODO @@ -0,0 +1,11 @@ +This file lists tests that need to be implemented or expanded. See ticket #3121 +for changes related to things listed here. + +Tests to add: +------------- + * add tests for dojo.place() + +Tests to improve: +----------------- + * cookie tests don't seem to test expiry or date functions + * NodeList isn't testing several of its public methods (place, orphan, adopt, etc.) diff --git a/includes/js/dojo/tests/_base.js b/includes/js/dojo/tests/_base.js new file mode 100644 index 0000000..7bc5301 --- /dev/null +++ b/includes/js/dojo/tests/_base.js @@ -0,0 +1,136 @@ +if(!dojo._hasResource["tests._base"]){ //_hasResource checks added by build. Do not use _hasResource directly in your code. +dojo._hasResource["tests._base"] = true; +var testGlobal = this; +try{ + dojo.provide("tests._base"); + testGlobal = dojo.global; +}catch(e){ } + +// the test suite for the bootstrap. Requires hostenv and other base tests at +// the end + +if(doh.selfTest){ + + doh.register("doh.smokeTest", + [ + function sanityCheckHarness(t){ + // sanity checks + t.assertTrue(true); + t.assertFalse(false); + t.assertFalse(0); + t.assertFalse(null); + var tObj = { w00t: false, blarg: true }; + t.assertEqual( + ["thinger", "blah", tObj], + ["thinger", "blah", tObj] + ); + t.assertEqual(tObj, tObj); + }, + /* + // uncomment to tests exception handling + function sanityCheckassertTrue(t){ + // should throw an error + t.assertTrue(false); + }, + function sanityCheckassertFalse(t){ + // should throw an error + t.assertFalse(true); + }, + function sanityCheckassertEqual(t){ + // should throw an error + t.assertEqual("foo", "bar"); + }, + */ + { + name: "eqTest", + // smoke test the fixture system + setUp: function(t){ + this.foo = "blah"; + }, + runTest: function(t){ + t.assertEqual("blah", this.foo); + }, + tearDown: function(t){ + } + } + ] + ); + + if(testGlobal["dojo"]){ + doh.register("tests._base", + [ + function dojoIsAvailable(t){ + t.assertTrue(testGlobal["dojo"]); + } + ] + ); + } + + if(testGlobal["setTimeout"]){ + // a stone-stupid async test + doh.register("tests.async", + [ + { + name: "deferredSuccess", + runTest: function(t){ + var d = new doh.Deferred(); + setTimeout(d.getTestCallback(function(){ + t.assertTrue(true); + t.assertFalse(false); + }), 50); + return d; + } + }, + { + name: "deferredFailure", + runTest: function(t){ + var d = new doh.Deferred(); + setTimeout(function(){ + d.errback(new Error("hrm...")); + }, 50); + return d; + } + }, + { + name: "timeoutFailure", + timeout: 50, + runTest: function(t){ + // timeout of 50 + var d = new doh.Deferred(); + setTimeout(function(){ + d.callback(true); + }, 100); + return d; + } + } + ] + ); + } +} + +try{ + // go grab the others + dojo.require("tests._base._loader.bootstrap"); + dojo.require("tests._base._loader.loader"); + dojo.platformRequire({ + browser: ["tests._base._loader.hostenv_browser"], + rhino: ["tests._base._loader.hostenv_rhino"], + spidermonkey: ["tests._base._loader.hostenv_spidermonkey"] + }); + dojo.require("tests._base.array"); + dojo.require("tests._base.Color"); + dojo.require("tests._base.lang"); + dojo.require("tests._base.declare"); + dojo.require("tests._base.connect"); + dojo.require("tests._base.Deferred"); + dojo.require("tests._base.json"); + // FIXME: add test includes for the rest of the Dojo Base groups here + dojo.requireIf(dojo.isBrowser, "tests._base.html"); + dojo.requireIf(dojo.isBrowser, "tests._base.fx"); + dojo.requireIf(dojo.isBrowser, "tests._base.query"); + dojo.requireIf(dojo.isBrowser, "tests._base.xhr"); +}catch(e){ + doh.debug(e); +} + +} diff --git a/includes/js/dojo/tests/_base/Color.js b/includes/js/dojo/tests/_base/Color.js new file mode 100644 index 0000000..fa09842 --- /dev/null +++ b/includes/js/dojo/tests/_base/Color.js @@ -0,0 +1,32 @@ +if(!dojo._hasResource["tests._base.Color"]){ //_hasResource checks added by build. Do not use _hasResource directly in your code. +dojo._hasResource["tests._base.Color"] = true; +dojo.provide("tests._base.Color"); + +(function(){ + var white = dojo.colorFromString("white").toRgba(); + var maroon = dojo.colorFromString("maroon").toRgba(); + var verifyColor = function(t, source, expected){ + var color = new dojo.Color(source); + t.is(expected, color.toRgba()); + dojo.forEach(color.toRgba(), function(n){ t.is("number", typeof(n)); }); + } + + doh.register("tests._base.Color", + [ + function testColor1(t){ verifyColor(t, "maroon", maroon); }, + function testColor2(t){ verifyColor(t, "white", white); }, + function testColor3(t){ verifyColor(t, "#fff", white); }, + function testColor4(t){ verifyColor(t, "#ffffff", white); }, + function testColor5(t){ verifyColor(t, "rgb(255,255,255)", white); }, + function testColor6(t){ verifyColor(t, "#800000", maroon); }, + function testColor7(t){ verifyColor(t, "rgb(128, 0, 0)", maroon); }, + function testColor8(t){ verifyColor(t, "rgba(128, 0, 0, 0.5)", [128, 0, 0, 0.5]); }, + function testColor9(t){ verifyColor(t, maroon, maroon); }, + function testColor10(t){ verifyColor(t, [1, 2, 3], [1, 2, 3, 1]); }, + function testColor11(t){ verifyColor(t, [1, 2, 3, 0.5], [1, 2, 3, 0.5]); }, + function testColor12(t){ verifyColor(t, dojo.blendColors(new dojo.Color("black"), new dojo.Color("white"), 0.5), [128, 128, 128, 1]); } + ] + ); +})(); + +} diff --git a/includes/js/dojo/tests/_base/Deferred.js b/includes/js/dojo/tests/_base/Deferred.js new file mode 100644 index 0000000..5dcf003 --- /dev/null +++ b/includes/js/dojo/tests/_base/Deferred.js @@ -0,0 +1,76 @@ +if(!dojo._hasResource["tests._base.Deferred"]){ //_hasResource checks added by build. Do not use _hasResource directly in your code. +dojo._hasResource["tests._base.Deferred"] = true; +dojo.provide("tests._base.Deferred"); + +doh.register("tests._base.Deferred", + [ + + function callback(t){ + var nd = new dojo.Deferred(); + var cnt = 0; + nd.addCallback(function(res){ + doh.debug("debug from dojo.Deferred callback"); + return res; + }); + nd.addCallback(function(res){ + // t.debug("val:", res); + cnt+=res; + return cnt; + }); + nd.callback(5); + // t.debug("cnt:", cnt); + t.assertEqual(cnt, 5); + }, + + function callback_extra_args(t){ + var nd = new dojo.Deferred(); + var cnt = 0; + nd.addCallback(dojo.global, function(base, res){ cnt+=base; cnt+=res; return cnt; }, 30); + nd.callback(5); + t.assertEqual(cnt, 35); + }, + + function errback(t){ + var nd = new dojo.Deferred(); + var cnt = 0; + nd.addErrback(function(val){ + return ++cnt; + }); + nd.errback(); + t.assertEqual(cnt, 1); + }, + + function callbackTwice(t){ + var nd = new dojo.Deferred(); + var cnt = 0; + nd.addCallback(function(res){ + return ++cnt; + }); + nd.callback(); + t.assertEqual(cnt, 1); + var thrown = false; + try{ + nd.callback(); + }catch(e){ + thrown = true; + } + t.assertTrue(thrown); + }, + + function addBoth(t){ + var nd = new dojo.Deferred(); + var cnt = 0; + nd.addBoth(function(res){ + return ++cnt; + }); + nd.callback(); + t.assertEqual(cnt, 1); + + // nd.callback(); + // t.debug(cnt); + // t.assertEqual(cnt, 1); + } + ] +); + +} diff --git a/includes/js/dojo/tests/_base/NodeList.html b/includes/js/dojo/tests/_base/NodeList.html new file mode 100644 index 0000000..e3f08c5 --- /dev/null +++ b/includes/js/dojo/tests/_base/NodeList.html @@ -0,0 +1,370 @@ + + + + + +This page has registers a function with dojo.addOnLoad() and dojo.addOnUnload.
+ +dojo.addOnLoad(): You should see an alert with the page first loads ("addOnLoad works").
+ +dojo.addOnUnload(): You should see an alert if the page is reloaded, or if you navigate to a + different web page ("addOnUnload works"). + + + diff --git a/includes/js/dojo/tests/_base/_loader/afterOnLoad.html b/includes/js/dojo/tests/_base/_loader/afterOnLoad.html new file mode 100644 index 0000000..48ebd60 --- /dev/null +++ b/includes/js/dojo/tests/_base/_loader/afterOnLoad.html @@ -0,0 +1,56 @@ + + +
+This page only works with a dojo build. It will not work properly if you run it directly from the subversion source.
+ +This page tests loading dojo after the page is loaded.
+ +When the window.onload fires, the dojo script tag will be added to the DOM + and configured to fire the onload callbacks. If everything works, you should + see a Calendar below.
+ ++ +
+ + diff --git a/includes/js/dojo/tests/_base/_loader/bootstrap.js b/includes/js/dojo/tests/_base/_loader/bootstrap.js new file mode 100644 index 0000000..c2605cb --- /dev/null +++ b/includes/js/dojo/tests/_base/_loader/bootstrap.js @@ -0,0 +1,86 @@ +if(!dojo._hasResource["tests._base._loader.bootstrap"]){ //_hasResource checks added by build. Do not use _hasResource directly in your code. +dojo._hasResource["tests._base._loader.bootstrap"] = true; +dojo.provide("tests._base._loader.bootstrap"); + +tests.register("tests._base._loader.bootstrap", + [ + + function hasConsole(t){ + t.assertTrue("console" in dojo.global); + t.assertTrue("assert" in console); + t.assertEqual("function", typeof console.assert); + }, + + { + name: "getObject", + setUp: function(){ + //Set an object in global scope. + dojo.global.globalValue = { + color: "blue", + size: 20 + }; + + //Set up an object in a specific scope. + this.foo = { + bar: { + color: "red", + size: 100 + } + }; + }, + runTest: function(t){ + //Test for existing object using global as root path. + var globalVar = dojo.getObject("globalValue"); + t.is("object", (typeof globalVar)); + t.assertEqual("blue", globalVar.color); + t.assertEqual(20, globalVar.size); + t.assertEqual("blue", dojo.getObject("globalValue.color")); + + //Test for non-existent object using global as root path. + //Then create it. + t.assertFalse(dojo.getObject("something.thatisNew")); + t.assertTrue(typeof(dojo.getObject("something.thatisNew", true)) == "object"); + + //Test for existing object using another object as root path. + var scopedVar = dojo.getObject("foo.bar", false, this); + t.assertTrue(typeof(scopedVar) == "object"); + t.assertEqual("red", scopedVar.color); + t.assertEqual(100, scopedVar.size); + t.assertEqual("red", dojo.getObject("foo.bar.color", true, this)); + + //Test for existing object using another object as root path. + //Then create it. + t.assertFalse(dojo.getObject("something.thatisNew", false, this)); + t.assertTrue(typeof(dojo.getObject("something.thatisNew", true, this)) == "object"); + }, + tearDown: function(){ + //Clean up global object that should not exist if + //the test is re-run. + try{ + delete dojo.global.something; + delete this.something; + }catch(e){} + } + }, + + { + name: "exists", + setUp: function(){ + this.foo = { + bar: {} + }; + }, + runTest: function(t){ + t.assertTrue(dojo.exists("foo.bar", this)); + t.assertFalse(dojo.exists("foo.bar")); + } + }, + + function evalWorks(t){ + t.assertTrue(dojo.eval("(true)")); + t.assertFalse(dojo.eval("(false)")); + } + ] +); + +} diff --git a/includes/js/dojo/tests/_base/_loader/getText.txt b/includes/js/dojo/tests/_base/_loader/getText.txt new file mode 100644 index 0000000..054e8e8 --- /dev/null +++ b/includes/js/dojo/tests/_base/_loader/getText.txt @@ -0,0 +1 @@ +dojo._getText() test data \ No newline at end of file diff --git a/includes/js/dojo/tests/_base/_loader/hostenv_browser.js b/includes/js/dojo/tests/_base/_loader/hostenv_browser.js new file mode 100644 index 0000000..255fca5 --- /dev/null +++ b/includes/js/dojo/tests/_base/_loader/hostenv_browser.js @@ -0,0 +1,15 @@ +if(!dojo._hasResource["tests._base._loader.hostenv_browser"]){ //_hasResource checks added by build. Do not use _hasResource directly in your code. +dojo._hasResource["tests._base._loader.hostenv_browser"] = true; +dojo.provide("tests._base._loader.hostenv_browser"); + +tests.register("tests._base._loader.hostenv_browser", + [ + function getText(t){ + var filePath = dojo.moduleUrl("tests._base._loader", "getText.txt"); + var text = dojo._getText(filePath); + t.assertEqual("dojo._getText() test data", text); + } + ] +); + +} diff --git a/includes/js/dojo/tests/_base/_loader/hostenv_rhino.js b/includes/js/dojo/tests/_base/_loader/hostenv_rhino.js new file mode 100644 index 0000000..c121576 --- /dev/null +++ b/includes/js/dojo/tests/_base/_loader/hostenv_rhino.js @@ -0,0 +1,17 @@ +if(!dojo._hasResource["tests._base._loader.hostenv_rhino"]){ //_hasResource checks added by build. Do not use _hasResource directly in your code. +dojo._hasResource["tests._base._loader.hostenv_rhino"] = true; +dojo.provide("tests._base._loader.hostenv_rhino"); + +tests.register("tests._base._loader.hostenv_rhino", + [ + function getText(t){ + var filePath = dojo.moduleUrl("tests._base._loader", "getText.txt"); + var text = (new String(readText(filePath))); + //The Java file read seems to add a line return. + text = text.replace(/[\r\n]+$/, ""); + t.assertEqual("dojo._getText() test data", text); + } + ] +); + +} diff --git a/includes/js/dojo/tests/_base/_loader/hostenv_spidermonkey.js b/includes/js/dojo/tests/_base/_loader/hostenv_spidermonkey.js new file mode 100644 index 0000000..980d624 --- /dev/null +++ b/includes/js/dojo/tests/_base/_loader/hostenv_spidermonkey.js @@ -0,0 +1,15 @@ +if(!dojo._hasResource["tests._base._loader.hostenv_spidermonkey"]){ //_hasResource checks added by build. Do not use _hasResource directly in your code. +dojo._hasResource["tests._base._loader.hostenv_spidermonkey"] = true; +dojo.provide("tests._base._loader.hostenv_spidermonkey"); + +tests.register("tests._base._loader.hostenv_spidermonkey", + [ + function getText(t){ + var filePath = dojo.moduleUrl("tests._base._loader", "getText.txt"); + var text = readText(filePath); + t.assertEqual("dojo._getText() test data", text); + } + ] +); + +} diff --git a/includes/js/dojo/tests/_base/_loader/loader.js b/includes/js/dojo/tests/_base/_loader/loader.js new file mode 100644 index 0000000..af1a338 --- /dev/null +++ b/includes/js/dojo/tests/_base/_loader/loader.js @@ -0,0 +1,52 @@ +if(!dojo._hasResource["tests._base._loader.loader"]){ //_hasResource checks added by build. Do not use _hasResource directly in your code. +dojo._hasResource["tests._base._loader.loader"] = true; +dojo.provide("tests._base._loader.loader"); + +tests.register("tests._base._loader.loader", + [ + function baseUrl(t){ + var originalBaseUrl = dojo.config["baseUrl"] || "./"; + + t.assertEqual(originalBaseUrl, dojo.baseUrl); + }, + + function modulePaths(t){ + dojo.registerModulePath("mycoolmod", "../some/path/mycoolpath"); + dojo.registerModulePath("mycoolmod.widget", "http://some.domain.com/another/path/mycoolpath/widget"); + + t.assertEqual("../some/path/mycoolpath/util", dojo._getModuleSymbols("mycoolmod.util").join("/")); + t.assertEqual("http://some.domain.com/another/path/mycoolpath/widget", dojo._getModuleSymbols("mycoolmod.widget").join("/")); + t.assertEqual("http://some.domain.com/another/path/mycoolpath/widget/thingy", dojo._getModuleSymbols("mycoolmod.widget.thingy").join("/")); + }, + + function moduleUrls(t){ + dojo.registerModulePath("mycoolmod", "some/path/mycoolpath"); + dojo.registerModulePath("mycoolmod2", "/some/path/mycoolpath2"); + dojo.registerModulePath("mycoolmod.widget", "http://some.domain.com/another/path/mycoolpath/widget"); + + + var basePrefix = dojo.baseUrl; + //dojo._Uri will strip off "./" characters, so do the same here + if(basePrefix == "./"){ + basePrefix = ""; + } + + t.assertEqual(basePrefix + "some/path/mycoolpath/my/favorite.html", + dojo.moduleUrl("mycoolmod", "my/favorite.html").toString()); + t.assertEqual(basePrefix + "some/path/mycoolpath/my/favorite.html", + dojo.moduleUrl("mycoolmod.my", "favorite.html").toString()); + + t.assertEqual("/some/path/mycoolpath2/my/favorite.html", + dojo.moduleUrl("mycoolmod2", "my/favorite.html").toString()); + t.assertEqual("/some/path/mycoolpath2/my/favorite.html", + dojo.moduleUrl("mycoolmod2.my", "favorite.html").toString()); + + t.assertEqual("http://some.domain.com/another/path/mycoolpath/widget/my/favorite.html", + dojo.moduleUrl("mycoolmod.widget", "my/favorite.html").toString()); + t.assertEqual("http://some.domain.com/another/path/mycoolpath/widget/my/favorite.html", + dojo.moduleUrl("mycoolmod.widget.my", "favorite.html").toString()); + } + ] +); + +} diff --git a/includes/js/dojo/tests/_base/_loader/scope/scope04.html b/includes/js/dojo/tests/_base/_loader/scope/scope04.html new file mode 100644 index 0000000..1866e4a --- /dev/null +++ b/includes/js/dojo/tests/_base/_loader/scope/scope04.html @@ -0,0 +1,80 @@ + + + +NOTE: This test only works with a built version of Dojo
+ +This page loads Dojo 0.4.3 and Dojo 1.0.
+ +Dojo 0.4.3 version:
+ +Dojo 1.0 version:
+ +dojo.addClass should be undefined:
+ ++ +
+ ++ +
+ + + + diff --git a/includes/js/dojo/tests/_base/_loader/scope/scopeContained.html b/includes/js/dojo/tests/_base/_loader/scope/scopeContained.html new file mode 100644 index 0000000..0acea5b --- /dev/null +++ b/includes/js/dojo/tests/_base/_loader/scope/scopeContained.html @@ -0,0 +1,71 @@ + + + +NOTE: This test only works with a built version of Dojo, and it must be built with the scopeMap parameter (the backslashes below are required):
+ +build.sh profile=standard action=release scopeMap=[[\"dojo\",\"jodo\"],[\"dijit\",\"jidit\"],[\"dojox\",\"jodox\"]]
+ +This page loads Dojo 0.4.3 and Dojo 1.0 (under the jodo scope)
+ +Dojo 0.4.3 version:
+ +Jodo version:
+ ++ +
+ ++ +
+ + + + diff --git a/includes/js/dojo/tests/_base/_loader/scope/scopeContainedXd.html b/includes/js/dojo/tests/_base/_loader/scope/scopeContainedXd.html new file mode 100644 index 0000000..c4c2eda --- /dev/null +++ b/includes/js/dojo/tests/_base/_loader/scope/scopeContainedXd.html @@ -0,0 +1,84 @@ + + + +NOTE: This test only works with a built, xdomain version of Dojo, and it must be built with the scopeMap parameter (the backslashes below are required):
+ +build.sh profile=standard action=release scopeMap=[[\"dojo\",\"jodo\"],[\"dijit\",\"jidit\"],[\"dojox\",\"jodox\"]] xdDojoScopeName=jodo loader=xdomain
+ +Only load this page from an http:// URL. Otherwise, the xd loading will not happen.
+ +This page xdomain loads Dojo 0.4.3 and Dojo 1.0 (under the jodo scope)
+ +Dojo 0.4.3 version:
+ +Jodo version:
+ ++ +
+ ++ +
+ + + + diff --git a/includes/js/dojo/tests/_base/_loader/scope/scopeDjConfig.html b/includes/js/dojo/tests/_base/_loader/scope/scopeDjConfig.html new file mode 100644 index 0000000..0ef5daa --- /dev/null +++ b/includes/js/dojo/tests/_base/_loader/scope/scopeDjConfig.html @@ -0,0 +1,64 @@ + + + +NOTE: This test only works with a built version of Dojo, and it must be built with the scopeDjConfig parameter (the backslashes below are required):
+ +build.sh profile=standard action=release scopeDjConfig=\{parseOnLoad:true,baseUrl:\"../../../../\",foo:\"bar\",scopeMap:[[\"dojo\",\"jodo\"],[\"dijit\",\"jidit\"],[\"dojox\",\"jodox\"]]\}
+ +This page loads Dojo 0.4.3 and Dojo 1.0 (under the jodo scope)
+ +djConfig.baseUrl should not exist:
+ +jodo.baseUrl should be "../../../../":
+ ++ +
+ ++ +
+ + + + diff --git a/includes/js/dojo/tests/_base/_loader/scope/scopeSingle.html b/includes/js/dojo/tests/_base/_loader/scope/scopeSingle.html new file mode 100644 index 0000000..759fcbe --- /dev/null +++ b/includes/js/dojo/tests/_base/_loader/scope/scopeSingle.html @@ -0,0 +1,62 @@ + + + +NOTE: This test only works with a built version of Dojo.
+ +Jodo version:
+ +typeof dojo, dijit and dojox should be undefined:
+ +
+ + + + diff --git a/includes/js/dojo/tests/_base/_loader/scope/scopeSingleDaac.html b/includes/js/dojo/tests/_base/_loader/scope/scopeSingleDaac.html new file mode 100644 index 0000000..8f9d7d8 --- /dev/null +++ b/includes/js/dojo/tests/_base/_loader/scope/scopeSingleDaac.html @@ -0,0 +1,63 @@ + + + +NOTE: This test only works with a built version of Dojo.
+ +Jodo version:
+ +typeof dojo, dijit and dojox should be object, since debugAtAllCosts is ON:
+ +
+ + + + diff --git a/includes/js/dojo/tests/_base/array.js b/includes/js/dojo/tests/_base/array.js new file mode 100644 index 0000000..6611257 --- /dev/null +++ b/includes/js/dojo/tests/_base/array.js @@ -0,0 +1,301 @@ +if(!dojo._hasResource["tests._base.array"]){ //_hasResource checks added by build. Do not use _hasResource directly in your code. +dojo._hasResource["tests._base.array"] = true; +dojo.provide("tests._base.array"); + +tests.register("tests._base.array", + [ + function testIndexOf(t){ + var foo = [128, 256, 512]; + var bar = ["aaa", "bbb", "ccc"]; + + t.assertEqual(1, dojo.indexOf([45, 56, 85], 56)); + t.assertEqual(1, dojo.indexOf([Number, String, Date], String)); + t.assertEqual(1, dojo.indexOf(foo, foo[1])); + t.assertEqual(2, dojo.indexOf(foo, foo[2])); + t.assertEqual(1, dojo.indexOf(bar, bar[1])); + t.assertEqual(2, dojo.indexOf(bar, bar[2])); + t.assertEqual(-1, dojo.indexOf({a:1}, "a")); + + foo.push(bar); + t.assertEqual(3, dojo.indexOf(foo, bar)); + }, + + function testIndexOfFromIndex(t){ + var foo = [128, 256, 512]; + var bar = ["aaa", "bbb", "ccc"]; + + t.assertEqual(-1, dojo.indexOf([45, 56, 85], 56, 2)); + t.assertEqual(1, dojo.indexOf([45, 56, 85], 56, 1)); + t.assertEqual(1, dojo.indexOf([45, 56, 85], 56, -1)); + // Make sure going out of bounds doesn't throw us in an infinite loop + t.assertEqual(-1, dojo.indexOf([45, 56, 85], 56, 3)); + }, + + function testLastIndexOf(t){ + var foo = [128, 256, 512]; + var bar = ["aaa", "bbb", "aaa", "ccc"]; + + t.assertEqual(1, dojo.indexOf([45, 56, 85], 56)); + t.assertEqual(1, dojo.indexOf([Number, String, Date], String)); + t.assertEqual(1, dojo.lastIndexOf(foo, foo[1])); + t.assertEqual(2, dojo.lastIndexOf(foo, foo[2])); + t.assertEqual(1, dojo.lastIndexOf(bar, bar[1])); + t.assertEqual(2, dojo.lastIndexOf(bar, bar[2])); + t.assertEqual(2, dojo.lastIndexOf(bar, bar[0])); + }, + + function testLastIndexOfFromIndex(t){ + t.assertEqual(1, dojo.lastIndexOf([45, 56, 85], 56, 1)); + t.assertEqual(-1, dojo.lastIndexOf([45, 56, 85], 85, 1)); + t.assertEqual(-1, dojo.lastIndexOf([45, 56, 85], 85, -1)); + t.assertEqual(0, dojo.lastIndexOf([45, 56, 45], 45, 0)); + }, + + function testForEach(t){ + var foo = [128, "bbb", 512]; + dojo.forEach(foo, function(elt, idx, array){ + switch(idx){ + case 0: t.assertEqual(128, elt); break; + case 1: t.assertEqual("bbb", elt); break; + case 2: t.assertEqual(512, elt); break; + default: t.assertTrue(false); + } + }); + + var noException = true; + try{ + dojo.forEach(undefined, function(){}); + }catch(e){ + noException = false; + } + t.assertTrue(noException); + }, + + function testForEach_str(t){ + var bar = 'abc'; + dojo.forEach(bar, function(elt, idx, array){ + switch(idx){ + case 0: t.assertEqual("a", elt); break; + case 1: t.assertEqual("b", elt); break; + case 2: t.assertEqual("c", elt); break; + default: t.assertTrue(false); + } + }); + }, + // FIXME: test forEach w/ a NodeList()? + + function testForEach_string_callback(t){ + // Test using strings as callback", which accept the parameters with + // the names "item", "index" and "array"! + var foo = [128, "bbb", 512]; + // Test that the variable "item" contains the value of each item. + this._res = ""; + dojo.forEach(foo, 'this._res+=item', this); + t.assertEqual(this._res, "128bbb512"); + // Test that the variable "index" contains each index. + this._res = []; + dojo.forEach(foo, 'this._res.push(index)', this); + t.assertEqual(this._res, [0,1,2]); + // Test that the variable "array" always contains the entire array. + this._res = []; + dojo.forEach(foo, 'this._res.push(array)', this); + t.assertEqual(this._res, [[128, "bbb", 512],[128, "bbb", 512],[128, "bbb", 512]]); + // Catch undefined variable usage (I used to use "i" :-)). + var caughtException = false; + try{ + dojo.forEach(foo, 'this._res+=i', this); + }catch(e){ + caughtException = true; + } + t.assertTrue(caughtException); + }, + + // FIXME: test forEach w/ a NodeList()? + function testEvery(t){ + var foo = [128, "bbb", 512]; + + t.assertTrue( + dojo.every(foo, function(elt, idx, array){ + t.assertEqual(Array, array.constructor); + t.assertTrue(dojo.isArray(array)); + t.assertTrue(typeof idx == "number"); + if(idx == 1){ t.assertEqual("bbb" , elt); } + return true; + }) + ); + + t.assertTrue( + dojo.every(foo, function(elt, idx, array){ + switch(idx){ + case 0: t.assertEqual(128, elt); return true; + case 1: t.assertEqual("bbb", elt); return true; + case 2: t.assertEqual(512, elt); return true; + default: return false; + } + }) + ); + + t.assertFalse( + dojo.every(foo, function(elt, idx, array){ + switch(idx){ + case 0: t.assertEqual(128, elt); return true; + case 1: t.assertEqual("bbb", elt); return true; + case 2: t.assertEqual(512, elt); return false; + default: return true; + } + }) + ); + + }, + + function testEvery_str(t){ + var bar = 'abc'; + t.assertTrue( + dojo.every(bar, function(elt, idx, array){ + switch(idx){ + case 0: t.assertEqual("a", elt); return true; + case 1: t.assertEqual("b", elt); return true; + case 2: t.assertEqual("c", elt); return true; + default: return false; + } + }) + ); + + t.assertFalse( + dojo.every(bar, function(elt, idx, array){ + switch(idx){ + case 0: t.assertEqual("a", elt); return true; + case 1: t.assertEqual("b", elt); return true; + case 2: t.assertEqual("c", elt); return false; + default: return true; + } + }) + ); + }, + // FIXME: test NodeList for every()? + + function testSome(t){ + var foo = [128, "bbb", 512]; + t.assertTrue( + dojo.some(foo, function(elt, idx, array){ + t.assertEqual(3, array.length); + return true; + }) + ); + + t.assertTrue( + dojo.some(foo, function(elt, idx, array){ + if(idx < 1){ return true; } + return false; + }) + ); + + t.assertFalse( + dojo.some(foo, function(elt, idx, array){ + return false; + }) + ); + + t.assertTrue( + dojo.some(foo, function(elt, idx, array){ + t.assertEqual(Array, array.constructor); + t.assertTrue(dojo.isArray(array)); + t.assertTrue(typeof idx == "number"); + if(idx == 1){ t.assertEqual("bbb" , elt); } + return true; + }) + ); + }, + + function testSome_str(t){ + var bar = 'abc'; + t.assertTrue( + dojo.some(bar, function(elt, idx, array){ + t.assertEqual(3, array.length); + switch(idx){ + case 0: t.assertEqual("a", elt); return true; + case 1: t.assertEqual("b", elt); return true; + case 2: t.assertEqual("c", elt); return true; + default: return false; + } + }) + ); + + t.assertTrue( + dojo.some(bar, function(elt, idx, array){ + switch(idx){ + case 0: t.assertEqual("a", elt); return true; + case 1: t.assertEqual("b", elt); return true; + case 2: t.assertEqual("c", elt); return false; + default: return true; + } + }) + ); + + t.assertFalse( + dojo.some(bar, function(elt, idx, array){ + return false; + }) + ); + }, + // FIXME: need to add scoping tests for all of these!!! + + function testFilter(t){ + var foo = ["foo", "bar", 10]; + + t.assertEqual(["foo"], + dojo.filter(foo, function(elt, idx, array){ + return idx < 1; + }) + ); + + t.assertEqual(["foo"], + dojo.filter(foo, function(elt, idx, array){ + return elt == "foo"; + }) + ); + + t.assertEqual([], + dojo.filter(foo, function(elt, idx, array){ + return false; + }) + ); + + t.assertEqual([10], + dojo.filter(foo, function(elt, idx, array){ + return typeof elt == "number"; + }) + ); + }, + + function testFilter_str(t){ + var foo = "thinger blah blah blah"; + t.assertEqual(["t", "h", "i"], + dojo.filter(foo, function(elt, idx, array){ + return idx < 3; + }) + ); + + t.assertEqual([], + dojo.filter(foo, function(elt, idx, array){ + return false; + }) + ); + }, + + function testMap(t){ + t.assertEqual([], + dojo.map([], function(){ return true; }) + ); + + t.assertEqual([1, 2, 3], + dojo.map(["cat", "dog", "mouse"], function(elt, idx, array){ + return idx+1; + }) + ); + } + ] +); + + +} diff --git a/includes/js/dojo/tests/_base/connect.js b/includes/js/dojo/tests/_base/connect.js new file mode 100644 index 0000000..3761861 --- /dev/null +++ b/includes/js/dojo/tests/_base/connect.js @@ -0,0 +1,225 @@ +if(!dojo._hasResource["tests._base.connect"]){ //_hasResource checks added by build. Do not use _hasResource directly in your code. +dojo._hasResource["tests._base.connect"] = true; +dojo.provide("tests._base.connect"); + +hub = function(){ +} + +failures = 0; +bad = function(){ + failures++; +} + +good = function(){ +} + +// make 'iterations' connections to hub +// roughly half of which will be to 'good' and +// half to 'bad' +// all connections to 'bad' are disconnected +// test can then be performed on the values +// 'failures' and 'successes' +markAndSweepTest = function(iterations){ + var marked = []; + // connections + for(var i=0; i+ Lorem ipsum dolor sit amet, consectetuer adipiscing elit. Aenean + semper sagittis velit. Cras in mi. Duis porta mauris ut ligula. + Proin porta rutrum lacus. Etiam consequat scelerisque quam. Nulla + facilisi. Maecenas luctus venenatis nulla. In sit amet dui non mi + semper iaculis. Sed molestie tortor at ipsum. Morbi dictum rutrum + magna. Sed vitae risus. +
++ Aliquam vitae enim. Duis scelerisque metus auctor est venenatis + imperdiet. Fusce dignissim porta augue. Nulla vestibulum. Integer + lorem nunc, ullamcorper a, commodo ac, malesuada sed, dolor. Aenean + id mi in massa bibendum suscipit. Integer eros. Nullam suscipit + mauris. In pellentesque. Mauris ipsum est, pharetra semper, + pharetra in, viverra quis, tellus. Etiam purus. Quisque egestas, + tortor ac cursus lacinia, felis leo adipiscing nisi, et rhoncus + elit dolor eget eros. Fusce ut quam. Suspendisse eleifend leo vitae + ligula. Nulla facilisi. Nulla rutrum, erat vitae lacinia dictum, + pede purus imperdiet lacus, ut semper velit ante id metus. Praesent + massa dolor, porttitor sed, pulvinar in, consequat ut, leo. Nullam + nec est. Aenean id risus blandit tortor pharetra congue. + Suspendisse pulvinar. +
+