config.html 4.06 KB
<html>
<head>
	<script type="text/javascript">
		var hasAlias, dojoAlias;
		var _dojoConfig= {
			baseUrl:"../../../../dojo",
			waitSeconds:5,
			locale:"us-en1",
			has:{
				configTestHas1:1
			},
			cats:'dojo-config-dogs',
			a:2, 
			b:[3,4,5]
		};
		function expectDojoConfig(t) {
			t.is(require.rawConfig.baseUrl, "../../../../dojo");
			t.is(require.rawConfig.waitSeconds, 5);
			t.is(require.rawConfig.locale,"us-en1");
			t.is(require.rawConfig.has, _dojoConfig.has);
			t.is(require.rawConfig.cats, 'dojo-config-dogs');
			t.is(require.rawConfig.a, 2);
			t.is(require.rawConfig.b, [3,4,5]);

			t.is(require.baseUrl, "../../../../dojo/");
			t.t(hasAlias("configTestHas1"));
			t.is(require.cats, undefined);
			t.is(require.a, undefined);
			t.is(require.b, undefined);

			t.is(dojo.config.baseUrl, "../../../../dojo/");
			t.is(dojo.config.waitSeconds, 5);
			t.is(dojo.config.locale,"us-en1");
			t.is(dojo.config.cats, 'dojo-config-dogs');
			t.is(dojo.config.a, 2);
			t.is(dojo.config.b, [3,4,5]);			
		}

		var _djConfig= {
			baseUrl:"../../../../dojo",
			waitSeconds:6,
			locale:"us-en2",
			has:{
				configTestHas2:1
			},
			cats:'dj-config-dogs',
			a:6, 
			b:[7,8,9]
		};
		function expectDjConfig(t) {
			t.is(require.rawConfig.baseUrl, "../../../../dojo");
			t.is(require.rawConfig.waitSeconds, 6);
			t.is(require.rawConfig.locale,"us-en2");
			t.is(require.rawConfig.has, _djConfig.has);
			t.is(require.rawConfig.cats, 'dj-config-dogs');
			t.is(require.rawConfig.a, 6);
			t.is(require.rawConfig.b, [7,8,9]);

			t.is(require.baseUrl, "../../../../dojo/");
			t.t(hasAlias("configTestHas2"));
			t.is(require.cats, undefined);
			t.is(require.a, undefined);
			t.is(require.b, undefined);

			t.is(dojo.config.baseUrl, "../../../../dojo/");
			t.is(dojo.config.waitSeconds, 6);
			t.is(dojo.config.locale,"us-en2");
			t.is(dojo.config.cats, 'dj-config-dogs');
			t.is(dojo.config.a, 6);
			t.is(dojo.config.b, [7,8,9]);			
		}

		var _require= {
			baseUrl:"../../../../dojo",
			waitSeconds:7,
			locale:"us-en3",
			has:{
				configTestHas3:1
			},
			cats:'require-config-dogs',
			a:10, 
			b:[11,12,13]
		};
		function expectRequireConfig(t) {
			t.is(require.rawConfig.baseUrl, "../../../../dojo");
			t.is(require.rawConfig.waitSeconds, 7);
			t.is(require.rawConfig.locale,"us-en3");
			t.is(require.rawConfig.has, _require.has);
			t.is(require.rawConfig.cats, 'require-config-dogs');
			t.is(require.rawConfig.a, 10);
			t.is(require.rawConfig.b, [11,12,13]);

			t.is(require.baseUrl, "../../../../dojo/");
			t.t(hasAlias("configTestHas3"));
			t.is(require.cats, undefined);
			t.is(require.a, undefined);
			t.is(require.b, undefined);

			t.is(dojo.config.baseUrl, "../../../../dojo/");
			t.is(dojo.config.waitSeconds, 7);
			t.is(dojo.config.locale,"us-en3");
			t.is(dojo.config.cats, 'require-config-dogs');
			t.is(dojo.config.a, 10);
			t.is(dojo.config.b, [11,12,13]);			
		}
		switch(location.search){
			case "?dojoConfig-djConfig-require":
				dojoConfig= _dojoConfig;
				djConfig= _djConfig;
				require= _require;
				expect= expectDojoConfig;
				break;
			case "?dojoConfig-djConfig":
				dojoConfig= _dojoConfig;
				djConfig= _djConfig;
				expect= expectDojoConfig;
				break;
			case "?dojoConfig-require":
				dojoConfig= _dojoConfig;
				require= _require;
				expect= expectDojoConfig;
				break;
			case "?djConfig-require":
				djConfig= _djConfig;
				require= _require;
				expect= expectDjConfig;
				break;
			case "?djConfig":
				djConfig= _djConfig;
				expect= expectDjConfig;
				break;
			case "?require":
				require= _require;
				expect= expectRequireConfig;
				break;
			case "?dojoConfig":
				dojoConfig= _dojoConfig;
				expect= expectDojoConfig;
				break;
		}
	</script>
	<script type="text/javascript" src="../../../dojo.js" data-dojo-config="isDebug:1, async:1"></script>
	<script type="text/javascript">
		require(["dojo", "doh", "dojo/has"], function(dojo, doh, has) {
			dojo.ready(function() {
				dojoAlias= dojo;
				hasAlias= has;
				doh.register("dojoConfig-test", [expect]);
				doh.runOnLoad();
			});
		});
	</script>
</head>
<body>
</body>
</html>