70 lines
2.3 KiB
HTML
70 lines
2.3 KiB
HTML
<!DOCTYPE html>
|
|
<html>
|
|
<head>
|
|
<title>require.js: urlFetch Mapping Test</title>
|
|
<script type="text/javascript">
|
|
var dohArgs = {async:0};
|
|
requirejsArgs= {
|
|
dojoLocation:"../../../../.."
|
|
};
|
|
</script>
|
|
<script type="text/javascript" src="../requirejs-setup.js"></script>
|
|
<script type="text/javascript" src="../../../../../dojo.js"></script>
|
|
<script type="text/javascript">
|
|
require({
|
|
baseUrl: "./",
|
|
paths: {
|
|
'one' : 'two',
|
|
'two' : 'two',
|
|
'three': 'three',
|
|
'four': 'three'
|
|
}
|
|
},
|
|
["require", "one", "two", "three", "four", "doh"],
|
|
function(require, one, two, three, four, doh) {
|
|
doh.register(
|
|
"urlfetch",
|
|
[
|
|
function urlfetch(t){
|
|
//First confirm there is only one script tag for each
|
|
//module:
|
|
var scripts = document.getElementsByTagName("script"),
|
|
i, counts = {}, url, props, something;
|
|
for (var i = scripts.length - 1; i > -1; i--) {
|
|
url = scripts[i].src;
|
|
if (url) {
|
|
if (!(url in counts)) {
|
|
counts[url] = 0;
|
|
}
|
|
counts[url] += 1;
|
|
}
|
|
}
|
|
|
|
if(require.async){
|
|
for (prop in counts) {
|
|
t.is(1, counts[prop]);
|
|
}
|
|
}
|
|
|
|
t.is("one", one.name);
|
|
t.is("one", two.oneName);
|
|
t.is("two", two.name);
|
|
t.is("three", three.name);
|
|
t.is("three", four.threeName);
|
|
t.is("four", four.name);
|
|
}
|
|
]
|
|
);
|
|
doh.run();
|
|
}
|
|
);
|
|
</script>
|
|
</head>
|
|
<body>
|
|
<h1>require.js: urlFetch Mapping Test</h1>
|
|
<p>Make sure that multiple modules mapped to the same URL only get
|
|
the URL fetched once.</p>
|
|
<p>Check console for messages</p>
|
|
</body>
|
|
</html>
|