Subversion Repositories Applications.papyrus

Compare Revisions

Ignore whitespace Rev 2149 → Rev 2150

/trunk/api/js/dojo1.0/dojo/tests/_base/_loader/bootstrap.js
New file
0,0 → 1,90
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);
},
 
function hasDjConfig(t){
t.assertTrue("djConfig" in dojo.global);
},
 
{
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)"));
}
]
);
 
}
/trunk/api/js/dojo1.0/dojo/tests/_base/_loader/hostenv_spidermonkey.js
New file
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);
}
]
);
 
}
/trunk/api/js/dojo1.0/dojo/tests/_base/_loader/744/foo/bar.js
New file
0,0 → 1,20
if(!dojo._hasResource["foo.bar"]){ //_hasResource checks added by build. Do not use _hasResource directly in your code.
dojo._hasResource["foo.bar"] = true;
dojo.provide("foo.bar");
 
//Define some globals and see if we can read them.
 
//This is OK
barMessage = "It Worked";
 
//This one FAILS in IE/Safari 2 with regular eval.
function getBarMessage(){
return barMessage;
}
 
//This is OK
getBar2Message = function(){
return getBarMessage();
}
 
}
/trunk/api/js/dojo1.0/dojo/tests/_base/_loader/744/testEval.html
New file
0,0 → 1,37
<html>
<head>
<script djConfig="isDebug: true" src="../../../../dojo.js"></script>
<script>
dojo.registerModulePath("foo", "tests/_base/_loader/744/foo");
dojo.require("foo.bar");
 
dojo.addOnLoad(function(){
console.debug(barMessage);
console.debug(getBar2Message());
console.debug(getBarMessage());
});
 
 
dojo.addOnLoad(function(){
//This fails if window.execScripts is used for MSIE, since that function
//does not return a value.
var temp = "({name: 'light'})";
var evalTemp = dojo.eval(temp);
console.debug("Object's name is: ", evalTemp.name);
});
 
</script>
</head>
<body>
<p>
Defining global variables/functions in a module that is loaded via dojo.require()
(meaning that XHR is used to load the text of the file and then eval the text) does
not seem to define the global variables/functions on window.
</p>
 
<p>
The test succeeds if you see "It Worked" 3 times in the debug console, then a "Object's name is: light" message.
</p>
 
</body>
</html>
/trunk/api/js/dojo1.0/dojo/tests/_base/_loader/addLoadEvents.html
New file
0,0 → 1,28
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN"
"http://www.w3.org/TR/html4/strict.dtd">
<html>
<head>
<title>Testing dojo.addOnLoad() and dojo.addOnUnload()</title>
<script type="text/javascript"
src="../../../dojo.js" djConfig="isDebug: true"></script>
<script type="text/javascript">
dojo.addOnLoad(function(){
alert("addOnLoad works");
});
dojo.addOnUnload(function(){
alert("addOnUnload works");
});
</script>
</head>
<body>
<h1>Testing dojo.addOnLoad() and dojo.addOnUnload()</h1>
 
<p>This page has registers a function with dojo.addOnLoad() and dojo.addOnUnload.</p>
<p><b>dojo.addOnLoad()</b>: You should see an alert with the page first loads ("addOnLoad works").</p>
<p><b>dojo.addOnUnload()</b>: You should see an alert if the page is reloaded, or if you navigate to a
different web page ("addOnUnload works").
</body>
</html>
 
/trunk/api/js/dojo1.0/dojo/tests/_base/_loader/hostenv_rhino.js
New file
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);
}
]
);
 
}
/trunk/api/js/dojo1.0/dojo/tests/_base/_loader/loader.js
New file
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 = djConfig["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());
}
]
);
 
}
/trunk/api/js/dojo1.0/dojo/tests/_base/_loader/getText.txt
New file
0,0 → 1,0
dojo._getText() test data
/trunk/api/js/dojo1.0/dojo/tests/_base/_loader/hostenv_browser.js
New file
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);
}
]
);
 
}