test.html
3.7 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
<html>
<head>
<script>
// The "loader" package depends on the package "pkg"; the application also
// depends on the package "pkg", but configured in a different way. Therefore, solve
// the problem by mapping "pkg" as seen by "loader" to "pkgMapped". Then configure
// the packages "pkg" and "pkgMapped" differently.
//
// At the app (global) level, config can be accomplished via the names "pkg" and "pkgMapped".
// Notice also that "pkg" does some of it's own configuration based on user configuration.
// This tests the ability to configure a mapped package.
var dojoConfig = {
async:1,
baseUrl:"../../../../..",
packages:[{
name:"loader",
location:"dojo/tests/_base/loader/config",
packageMap:{
"pkg":"pkgMapped"
}
},{
name:"pkg",
location:"dojo/tests/_base/loader/config/pkg"
},{
name:"pkgMapped",
location:"dojo/tests/_base/loader/config/pkg",
packageMap:{
"pkg":"pkgMapped"
}
},{
name:"dojo",
location:"dojo"
},{
name:"doh",
location:"util/doh"
}],
config:{
"loader/someModuleConfiggedPriorToBoot":{someConfig:"this is the config for someModuleConfiggedPriorToBoot"}
},
deps:["doh"],
callback:function(doh){
var master = new doh.Deferred(), waiting = 2;
doh.register(
"require.config",
[
{
name: "require.config",
timeout: 5000,
runTest: function() {
return master;
}
}
]
);
doh.run();
require({config:{
"loader/someModule":{someConfig:"this is the config for someModule-someConfig"},
"pkgMapped/m1":{globalConfig:"globalConfigForpkgMapped/m1", isMapped:true},
"pkgMapped/m2":{globalConfig:"globalConfigForpkgMapped/m2"}
}});
require(["loader/someModuleConfiggedPriorToBoot", "loader/someModule"], function(someModuleConfiggedPriorToBoot, someModule){
doh.is(someModuleConfiggedPriorToBoot.getConfig(), {
someConfig:"this is the config for someModuleConfiggedPriorToBoot"});
doh.is(someModule.getConfig(), {
someConfig:"this is the config for someModule-someConfig"});
doh.is(someModule.m1.getConfig(), {
globalConfig:"globalConfigForpkgMapped/m1",
isMapped:true,
configThroughMappedRefForM1:"configThroughMappedRefForM1"});
doh.is(someModule.m2.getConfig(), {
globalConfig:"globalConfigForpkgMapped/m2",
configThroughMappedRefForM1:"configThroughMappedRefForM1",
config1:"mapped-config1",
config2:"mapped-config2",
config3:"mapped-config3"
});
setTimeout(function(){
require({
config:{
"loader/someModule":{
someMoreConfig:"this is the config for someModule-someMoreConfig"
}
}
});
require(["loader/someModule"], function(someModule){
doh.is(someModule.getConfig(), {
someConfig:"this is the config for someModule-someConfig",
someMoreConfig:"this is the config for someModule-someMoreConfig"
});
if(!(--waiting)){
master.callback(true);
}
});
}, 10);
});
require({config:{
"pkg/m1":{globalConfig:"globalConfigForM1"},
"pkg/m2":{globalConfig:"globalConfigForM2"}
}},["pkg/m1", "pkg/m2"], function(m1, m2){
doh.is(m1.getConfig(), {
globalConfig:"globalConfigForM1"});
doh.is(m2.getConfig(), {
globalConfig:"globalConfigForM2",
config1:"config1",
config2:"config2",
config3:"config3"
});
if(!(--waiting)){
master.callback(true);
}
});
doh.run();
}
};
</script>
<script src="../../../../dojo.js"></script>
</head>
</html>