96 lines
2.2 KiB
HTML
96 lines
2.2 KiB
HTML
<!DOCTYPE html>
|
|
<html>
|
|
<head>
|
|
<title>require.js: Multiversion Test</title>
|
|
<script type="text/javascript" src="../require.js"></script>
|
|
<script type="text/javascript" src="doh/runner.js"></script>
|
|
<script type="text/javascript" src="doh/_browserRunner.js"></script>
|
|
<script type="text/javascript">
|
|
var doneCount = 0;
|
|
var master = new doh.Deferred();
|
|
function done() {
|
|
doneCount += 1;
|
|
//alert("done");
|
|
if (doneCount == 2) {
|
|
//alert("master callback");
|
|
master.callback(true);
|
|
}
|
|
}
|
|
doh.register(
|
|
"multiversion",
|
|
[
|
|
{
|
|
name: "multiversion",
|
|
timeout: 5000,
|
|
runTest: function() {
|
|
require(
|
|
{
|
|
context: "version1",
|
|
baseUrl: "version1/"
|
|
},
|
|
["require", "alpha", "beta", "version1/gamma.js"],
|
|
function(require, alpha, beta) {
|
|
//Notice no module arg name for gamma in the function call.
|
|
//gamma in the log call below will be a global created by gamma.js.
|
|
doh.is("green", gamma.color);
|
|
doh.is(1, alpha.version);
|
|
doh.is(1, beta.version);
|
|
|
|
setTimeout(function(){
|
|
require(
|
|
["omega"],
|
|
function(omega) {
|
|
doh.is(1, omega.version);
|
|
doh.is("1", alpha.version);
|
|
done();
|
|
}
|
|
);
|
|
}, 100);
|
|
}
|
|
);
|
|
|
|
require.config(
|
|
{
|
|
context: "version2",
|
|
baseUrl: "version2/"
|
|
})(
|
|
["require", "alpha", "beta", "version2/epsilon.js"],
|
|
function(require, alpha, beta) {
|
|
//Notice no module arg name for epsilon in the function call.
|
|
//epsilon in the log call below will be a global created by epsilon.js.
|
|
doh.is("red", epsilon.color);
|
|
doh.is(2, alpha.version);
|
|
doh.is(2, beta.version);
|
|
|
|
setTimeout(function(){
|
|
require(
|
|
["omega"],
|
|
function(omega) {
|
|
doh.is(2, omega.version);
|
|
doh.is("2", alpha.version);
|
|
done();
|
|
}
|
|
);
|
|
}, 100);
|
|
});
|
|
|
|
return master;
|
|
}
|
|
}
|
|
]
|
|
);
|
|
doh.run();
|
|
</script>
|
|
</head>
|
|
<body>
|
|
<h1>require.js: Multiversion Test</h1>
|
|
|
|
<p>Check console for messages.</p>
|
|
|
|
<p>This test loads two different versions of a module by using the
|
|
"context" settings for require.</p>
|
|
|
|
<p>It also tests loading a plain js file.</p>
|
|
</body>
|
|
</html>
|