Made _getScriptLocation smarter, and added it to SingleFile.js also. This means that single file builds no longer need to contain OpenLayers.js. r=eleomine (closes #2873)

git-svn-id: http://svn.openlayers.org/trunk/openlayers@10822 dc9f47b5-9b13-0410-9fdd-eb0c1a62fdaf
This commit is contained in:
ahocevar
2010-10-13 13:02:08 +00:00
parent 8dc19c84c7
commit 485ebaa316
10 changed files with 129 additions and 67 deletions
-31
View File
@@ -1,31 +0,0 @@
<html>
<head>
<script src="bogus/1/OpenLayers.js-foo"></script>
<script src="bogus/2/foo-OpenLayers.js"></script>
<script id="script" src="../lib/OpenLayers.js"></script>
<script type="text/javascript">
function test_OpenLayers(t) {
t.plan(3);
var script = document.getElementById("script");
t.eq(OpenLayers._getScriptLocation(), "../", "Script location correctly detected.");
// create a clone of OpenLayers._getScriptLocation
eval("var getScriptLocation = " + OpenLayers._getScriptLocation.toString());
var scriptLocation;
script.setAttribute("src", "../lib/OpenLayers.js?foo");
t.eq(getScriptLocation(), "../", "Script location with search string correctly detected.");
scriptLocation = null;
// now pretend we're using a built script
OpenLayers._scriptName = "OpenLayers.js";
t.eq(getScriptLocation(), "../lib/", "not fooled by bogus paths");
}
</script>
</head>
<body>
</body>
</html>
+32
View File
@@ -0,0 +1,32 @@
<html>
<head>
<script src="../lib/OpenLayers.js"></script>
<script type="text/javascript">
function test_OpenLayers(t) {
t.plan(1);
var script = document.getElementById("script");
t.eq(OpenLayers._getScriptLocation(), "../", "Script location correctly detected.");
}
</script>
</head>
<body>
</body>
</html>
<html>
<head>
<script src="../lib/OpenLayers.js"></script>
<script type="text/javascript">
function test_OpenLayers(t) {
t.plan(1);
var script = document.getElementById("script");
t.eq(OpenLayers._getScriptLocation(), "../", "Script location correctly detected.");
}
</script>
</head>
<body>
</body>
</html>
+38
View File
@@ -0,0 +1,38 @@
<html>
<head>
<script src="bogus/1/OpenLayers.js-foo"></script>
<script src="bogus/2/foo-OpenLayers.js"></script>
<script src="../lib/OpenLayers.js?foo"></script>
<script src="bogus/3/after-OpenLayers.js"></script>
<script type="text/javascript">
function test_OpenLayers(t) {
t.plan(1);
var script = document.getElementById("script");
t.eq(OpenLayers._getScriptLocation(), "../", "Script location with search string correctly detected, and not fooled by other scripts.");
}
</script>
</head>
<body>
</body>
</html>
<html>
<head>
<script src="bogus/1/OpenLayers.js-foo"></script>
<script src="bogus/2/foo-OpenLayers.js"></script>
<script src="../lib/OpenLayers.js?foo"></script>
<script src="bogus/3/after-OpenLayers.js"></script>
<script type="text/javascript">
function test_OpenLayers(t) {
t.plan(1);
var script = document.getElementById("script");
t.eq(OpenLayers._getScriptLocation(), "../", "Script location with search string correctly detected, and not fooled by other scripts.");
}
</script>
</head>
<body>
</body>
</html>
+38
View File
@@ -0,0 +1,38 @@
<html>
<head>
<script>
var OpenLayers = {singleFile: true};
</script>
<script src="../lib/OpenLayers.js"></script>
<script type="text/javascript">
function test_OpenLayers(t) {
t.plan(1);
var script = document.getElementById("script");
t.eq(OpenLayers._getScriptLocation(), "../lib/", "Script location for single file build correctly detected.");
}
</script>
</head>
<body>
</body>
</html>
<html>
<head>
<script>
var OpenLayers = {singleFile: true};
</script>
<script src="../lib/OpenLayers.js"></script>
<script type="text/javascript">
function test_OpenLayers(t) {
t.plan(1);
var script = document.getElementById("script");
t.eq(OpenLayers._getScriptLocation(), "../lib/", "Script location for single file build correctly detected.");
}
</script>
</head>
<body>
</body>
</html>
+3 -1
View File
@@ -156,7 +156,9 @@
<li>Map.html</li>
<li>Marker.html</li>
<li>Marker/Box.html</li>
<li>OpenLayers.html</li>
<li>OpenLayers1.html</li>
<li>OpenLayers2.html</li>
<li>OpenLayers3.html</li>
<li>Popup.html</li>
<li>Popup/Anchored.html</li>
<li>Popup/AnchoredBubble.html</li>