configApi.html
2.63 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
<html>
<head>
<script type="text/javascript" src="../../../dojo.js" data-dojo-config="isDebug:1, async:1"></script>
<script type="text/javascript">
require(["dojo", "doh"], function(dojo, doh) {
dojo.ready(function(){
doh.register("config-event", [
function expectDojoConfig(t) {
var
expectedConfig1, expectedConfig2,
called1, called2,
savedRawConfig,
configListener1= function(config, rawConfig){
called1= true;
savedRawConfig= rawConfig;
t.is(config, expectedConfig1);
},
configListener2= function(config, rawConfig){
called2= true;
savedRawConfig= rawConfig;
t.is(config, expectedConfig2);
};
var configListeners = require.listenerQueues.config || (require.listenerQueues.config = []);
listenerCount= configListeners.length,
h1= require.on("config", configListener1),
h2= require.on("config", configListener2);
t.is(configListeners.length, listenerCount+2);
t.is(configListeners[listenerCount], configListener1);
t.is(configListeners[listenerCount+1], configListener2);
expectedConfig1= expectedConfig2= {
someFeature:1
};
called1= called2= 0;
require(expectedConfig1);
t.t(called1);
t.t(called2);
h1.remove();
t.is(configListeners.length, listenerCount+1);
t.is(configListeners[listenerCount], configListener2);
expectedConfig1= expectedConfig2= {
someFeature:0,
someOtherFeature:1
};
called1= called2= 0;
require(expectedConfig1);
t.is(called1, 0);
t.t(called2);
t.is(savedRawConfig.someFeature, 0);
t.is(savedRawConfig.someOtherFeature, 1);
h2.remove();
require({async:1});
t.is(require.async, true);
t.is(require.legacyMode, false);
require({async:true});
t.is(require.async, true);
t.is(require.legacyMode, false);
require({async:2});
t.is(require.async, true);
t.is(require.legacyMode, false);
require({async:"nonsense"});
t.is(require.async, true);
t.is(require.legacyMode, false);
require({async:0});
t.is(require.async, false);
t.is(require.legacyMode, "sync");
require({async:false});
t.is(require.async, false);
t.is(require.legacyMode, "sync");
require({async:"sync"});
t.is(require.async, false);
t.is(require.legacyMode, "sync");
require({async:"legacyAsync"});
t.is(require.async, false);
t.is(require.legacyMode, "legacyAsync");
}
]);
doh.runOnLoad();
});
});
</script>
</head>
<body>
</body>
</html>