IE6, FF, Moz, Opera, IE7, Safari. This may not work in all situations. It's included in util for utility, but it is possible it may fail in some cases in some environments. If you find this to be the case, please open a bug and we will work to resolve it. git-svn-id: http://svn.openlayers.org/trunk/openlayers@2162 dc9f47b5-9b13-0410-9fdd-eb0c1a62fdaf
565 lines
22 KiB
HTML
565 lines
22 KiB
HTML
<html>
|
|
<head>
|
|
<script src="../lib/OpenLayers.js"></script>
|
|
<script type="text/javascript"><!--
|
|
var isMozilla = (navigator.userAgent.indexOf("compatible") == -1);
|
|
var map;
|
|
function test_01_Util_getImagesLocation (t) {
|
|
t.plan( 1 );
|
|
t.ok( OpenLayers.Util.getImagesLocation(), "../img/",
|
|
"getImagesLocation()" );
|
|
}
|
|
|
|
function test_02_Util_Strings(t) {
|
|
t.plan(5);
|
|
|
|
var str = " chicken pox ";
|
|
|
|
t.ok(str.contains("chicken"), "contains() function correctly finds an embedded string");
|
|
t.ok(!str.contains("marsupial"), "contains() function correctly does not finds an random string");
|
|
|
|
|
|
var trimmedStr = str.trim();
|
|
|
|
t.eq(trimmedStr, "chicken pox", "String.trim works correctly");
|
|
|
|
t.eq(trimmedStr.startsWith("chicken"), true, "String.startsWith correctly finds chicken");
|
|
t.eq(trimmedStr.startsWith("dolphin"), false, "String.startsWith correctly does not find turkey");
|
|
|
|
|
|
}
|
|
|
|
function test_03_Util_Array(t) {
|
|
t.plan( 2 );
|
|
|
|
var array = new Array(1,2,3,4,5);
|
|
|
|
OpenLayers.Util.removeItem(array, 3);
|
|
t.eq( array.toString(), "1,2,4,5", "Util.removeItem works");
|
|
|
|
OpenLayers.Util.clearArray(array);
|
|
t.eq( array.toString(), "", "Util.clearArray works");
|
|
|
|
}
|
|
|
|
function test_04_Util_createDiv(t) {
|
|
t.plan( 24 );
|
|
|
|
var id = "boo";
|
|
var px = new OpenLayers.Pixel(5,5);
|
|
var sz = new OpenLayers.Size(10,10);
|
|
var img = "http://www.openlayers.org/images/OpenLayers.trac.png";
|
|
var position = "absolute";
|
|
var border = "13px solid";
|
|
var overflow = "hidden";
|
|
var opacity = 0.5;
|
|
|
|
var div = OpenLayers.Util.createDiv(id, px, sz, img, position, border, overflow, opacity);
|
|
|
|
if (!isMozilla)
|
|
t.ok( true, "skipping element test outside of Mozilla");
|
|
else
|
|
t.ok( div instanceof HTMLDivElement, "createDiv creates a valid HTMLDivElement" );
|
|
t.eq( div.id, id, "div.id set correctly");
|
|
t.eq( div.style.left, px.x + "px", "div.style.left set correctly");
|
|
t.eq( div.style.top, px.y + "px", "div.style.top set correctly");
|
|
|
|
t.eq( div.style.width, sz.w + "px", "div.style.width set correctly");
|
|
t.eq( div.style.height, sz.h + "px", "div.style.height set correctly");
|
|
|
|
bImg = div.style.backgroundImage;
|
|
imgCorrect = ( (bImg == "url(" + img + ")") ||
|
|
(bImg == "url(\"" + img + "\")") );
|
|
t.ok(imgCorrect, "div.style.backgroundImage correctly");
|
|
|
|
t.eq( div.style.position, position, "div.style.positionset correctly");
|
|
t.ok( (div.style.border.indexOf(border) != -1), "div.style.border set correctly");
|
|
t.eq( div.style.overflow, overflow, "div.style.overflow set correctly");
|
|
t.eq( parseFloat(div.style.opacity), opacity, "element.style.opacity set correctly");
|
|
var filterString = 'alpha(opacity=' + (opacity * 100) + ')';
|
|
t.eq( div.style.filter, filterString, "element.style.filter set correctly");
|
|
|
|
//test defaults
|
|
var div = OpenLayers.Util.createDiv();
|
|
|
|
if (!isMozilla)
|
|
t.ok( true, "skipping element test outside of Mozilla");
|
|
else
|
|
t.ok( div instanceof HTMLDivElement, "createDiv creates a valid HTMLDivElement" );
|
|
t.ok( (div.id != ""), "div.id set correctly");
|
|
t.eq(div.style.left, "", "div.style.left set correctly");
|
|
t.eq(div.style.top, "", "div.style.top set correctly");
|
|
|
|
t.eq( div.style.width, "", "div.style.width set correctly");
|
|
t.eq( div.style.height, "", "div.style.height set correctly");
|
|
|
|
t.eq(div.style.backgroundImage, "", "div.style.backgroundImage correctly");
|
|
|
|
t.eq( div.style.position, "absolute", "div.style.positionset correctly");
|
|
t.eq( div.style.border, "", "div.style.border set correctly");
|
|
t.eq(div.style.overflow, "", "div.style.overflow set correctly");
|
|
t.ok( !div.style.opacity, "element.style.opacity set correctly");
|
|
t.ok( !div.style.filter, "element.style.filter set correctly");
|
|
|
|
}
|
|
|
|
function test_05_Util_createImage(t) {
|
|
t.plan( 22 );
|
|
|
|
var img = "http://www.openlayers.org/images/OpenLayers.trac.png";
|
|
var sz = new OpenLayers.Size(10,10);
|
|
var xy = new OpenLayers.Pixel(5,5);
|
|
var position = "absolute";
|
|
var id = "boo";
|
|
var border = "1px solid";
|
|
var opacity = 0.5;
|
|
|
|
var image = OpenLayers.Util.createImage(id, xy, sz, img, position, border, opacity);
|
|
|
|
if (!isMozilla)
|
|
t.ok( true, "skipping element test outside of Mozilla");
|
|
else
|
|
t.ok( image.nodeName == "IMG", "createImage creates a valid HTMLImageElement" );
|
|
t.eq( image.id, id, "image.id set correctly");
|
|
t.eq( image.style.left, xy.x + "px", "image.style.left set correctly");
|
|
t.eq( image.style.top, xy.y + "px", "image.style.top set correctly");
|
|
|
|
t.eq( image.style.width, sz.w + "px", "image.style.width set correctly");
|
|
t.eq( image.style.height, sz.h + "px", "image.style.height set correctly");
|
|
|
|
t.ok( (image.style.border.indexOf(border) != -1), "image.style.border set correctly");
|
|
t.eq( image.src, img, "image.style.backgroundImage correctly");
|
|
t.eq( image.style.position, position, "image.style.position set correctly");
|
|
t.eq( parseFloat(image.style.opacity), opacity, "image.style.opacity set correctly");
|
|
var filterString = 'alpha(opacity=' + (opacity * 100) + ')';
|
|
t.eq( image.style.filter, filterString, "element.style.filter set correctly");
|
|
|
|
//test defaults
|
|
var image = OpenLayers.Util.createImage();
|
|
|
|
if (!isMozilla)
|
|
t.ok( true, "skipping element test outside of Mozilla");
|
|
else
|
|
t.ok( image.nodeName == "IMG", "createDiv creates a valid HTMLDivElement" );
|
|
t.ok( (image.id != ""), "image.id set to something");
|
|
t.eq( image.style.left, "", "image.style.left set correctly");
|
|
t.eq( image.style.top, "", "image.style.top set correctly");
|
|
|
|
t.eq( image.style.width, "", "image.style.width set correctly");
|
|
t.eq( image.style.height, "", "image.style.height set correctly");
|
|
|
|
t.ok((image.style.border == ""), "image.style.border set correctly");
|
|
t.eq(image.src, "", "image.style.backgroundImage correctly");
|
|
t.eq( image.style.position, "relative", "image.style.positionset correctly");
|
|
t.ok( !image.style.opacity, "element.style.opacity default unset");
|
|
t.ok( !image.style.filter, "element.style.filter default unset");
|
|
|
|
}
|
|
|
|
function test_06_Util_applyDefaults(t) {
|
|
|
|
t.plan(4);
|
|
|
|
var to = { a: "abra",
|
|
b: "blorg"
|
|
};
|
|
|
|
var from = { b: "zoink",
|
|
c: "press"
|
|
};
|
|
|
|
OpenLayers.Util.applyDefaults(to, from);
|
|
|
|
t.ok( to instanceof Object, " applyDefaults returns an object");
|
|
t.eq( to["a"], "abra", "key present in to but not from maintained");
|
|
t.eq( to["b"], "blorg", "key present in to and from, maintained in to");
|
|
t.eq( to["c"], "press", "key present in from and not to successfully copied to to");
|
|
}
|
|
|
|
function test_07_Util_getParameterString(t) {
|
|
t.plan( 2 );
|
|
|
|
var params = { foo: "bar",
|
|
chicken: 1.5
|
|
}
|
|
|
|
t.eq( OpenLayers.Util.getParameterString(params), "foo=bar&chicken=1.5", "getParameterString returns correctly");
|
|
t.eq( OpenLayers.Util.getParameterString({'a:':'b='}), "a%3A=b%3D", "getParameterString returns correctly with non-ascii keys/values");
|
|
}
|
|
|
|
function test_08_Util_createAlphaImageDiv(t) {
|
|
t.plan( 19 );
|
|
|
|
var img = "http://www.openlayers.org/images/OpenLayers.trac.png";
|
|
var sz = new OpenLayers.Size(10,10);
|
|
var xy = new OpenLayers.Pixel(5,5);
|
|
var position = "absolute";
|
|
var id = "boo";
|
|
var border = "1px solid";
|
|
var sizing = "crop";
|
|
var opacity = 0.5;
|
|
|
|
var imageDiv = OpenLayers.Util.createAlphaImageDiv(id, xy, sz, img, position, border, sizing, opacity);
|
|
|
|
if (!isMozilla)
|
|
t.ok( true, "skipping element test outside of Mozilla");
|
|
else
|
|
t.ok( imageDiv instanceof HTMLDivElement, "createDiv creates a valid HTMLDivElement" );
|
|
|
|
t.eq( imageDiv.id, id, "image.id set correctly");
|
|
t.eq( imageDiv.style.left, xy.x + "px", "image.style.left set correctly");
|
|
t.eq( imageDiv.style.top, xy.y + "px", "image.style.top set correctly");
|
|
|
|
t.eq( imageDiv.style.width, sz.w + "px", "image.style.width set correctly");
|
|
t.eq( imageDiv.style.height, sz.h + "px", "image.style.height set correctly");
|
|
|
|
t.eq( imageDiv.style.position, position, "image.style.positionset correctly");
|
|
t.eq( parseFloat(imageDiv.style.opacity), opacity, "element.style.opacity set correctly");
|
|
|
|
var filterString;
|
|
if (OpenLayers.Util.alphaHack()) {
|
|
filterString = "progid:DXImageTransform.Microsoft.AlphaImageLoader(src='http://www.openlayers.org/images/OpenLayers.trac.png', sizingMethod='crop') alpha(opacity=50)";
|
|
} else {
|
|
filterString = 'alpha(opacity=' + (opacity * 100) + ')';
|
|
}
|
|
t.eq( imageDiv.style.filter, filterString, "element.style.filter set correctly");
|
|
|
|
|
|
image = imageDiv.firstChild;
|
|
if (!isMozilla)
|
|
t.ok( true, "skipping element test outside of Mozilla");
|
|
else
|
|
t.ok( image.nodeName == "IMG", "createImage creates a valid HTMLImageElement" );
|
|
t.eq( image.id, id + "_innerImage", "image.id set correctly");
|
|
|
|
t.eq( image.style.width, sz.w + "px", "image.style.width set correctly");
|
|
t.eq( image.style.height, sz.h + "px", "image.style.height set correctly");
|
|
|
|
t.ok( (image.style.border.indexOf(border) != -1), "image.style.border set correctly");
|
|
t.eq( image.style.position, "relative", "image.style.positionset correctly");
|
|
|
|
if (OpenLayers.Util.alphaHack()) {
|
|
|
|
t.eq(imageDiv.style.display, "inline-block", "imageDiv.style.display set correctly");
|
|
|
|
var filter = "progid:DXImageTransform.Microsoft" +
|
|
".AlphaImageLoader(src='" + img + "', " +
|
|
"sizingMethod='" + sizing + "') alpha(opacity=50)";
|
|
t.eq(imageDiv.style.filter, filter, "div filter value correctly set");
|
|
|
|
filter = "progid:DXImageTransform.Microsoft.Alpha(opacity=0)";
|
|
t.eq(image.style.filter, filter, "image filter set correctly");
|
|
|
|
} else {
|
|
t.eq( image.src, img, "image.style.backgroundImage correctly");
|
|
t.ok(true, "div filter value not set (not in IE)");
|
|
t.ok(true, "image filter value not set (not in IE)");
|
|
}
|
|
|
|
var imageDiv = OpenLayers.Util.createAlphaImageDiv(id, xy, sz, img, position, border);
|
|
if (OpenLayers.Util.alphaHack()) {
|
|
var filter = "progid:DXImageTransform.Microsoft" +
|
|
".AlphaImageLoader(src='" + img + "', " +
|
|
"sizingMethod='scale')";
|
|
t.eq(imageDiv.style.filter, filter, "sizingMethod default correctly set to scale");
|
|
} else {
|
|
t.ok(true);
|
|
}
|
|
|
|
}
|
|
|
|
function test_09_Util_modifyDOMElement(t) {
|
|
|
|
t.plan( 10 );
|
|
|
|
var id = "boo";
|
|
var px = new OpenLayers.Pixel(5,5);
|
|
var sz = new OpenLayers.Size(10,10);
|
|
var position = "absolute";
|
|
var border = "1px solid";
|
|
var overflow = "hidden";
|
|
var opacity = 1/2;
|
|
|
|
var element = document.createElement("div");
|
|
|
|
OpenLayers.Util.modifyDOMElement(element, id, px, sz, position,
|
|
border, overflow, opacity);
|
|
|
|
t.eq( element.id, id, "element.id set correctly");
|
|
t.eq( element.style.left, px.x + "px", "element.style.left set correctly");
|
|
t.eq( element.style.top, px.y + "px", "element.style.top set correctly");
|
|
|
|
t.eq( element.style.width, sz.w + "px", "element.style.width set correctly");
|
|
t.eq( element.style.height, sz.h + "px", "element.style.height set correctly");
|
|
|
|
t.eq( element.style.position, position, "element.style.position set correctly");
|
|
t.ok( (element.style.border.indexOf(border) != -1), "element.style.border set correctly");
|
|
t.eq( element.style.overflow, overflow, "element.style.overflow set correctly");
|
|
t.eq( parseFloat(element.style.opacity), opacity, "element.style.opacity set correctly");
|
|
var filterString = 'alpha(opacity=' + (opacity * 100) + ')';
|
|
t.eq( element.style.filter, filterString, "element.style.filter set correctly");
|
|
}
|
|
|
|
function test_09_Util_modifyAlphaImageDiv(t) {
|
|
t.plan( 19 );
|
|
|
|
var imageDiv = OpenLayers.Util.createAlphaImageDiv();
|
|
|
|
var img = "http://www.openlayers.org/images/OpenLayers.trac.png";
|
|
var sz = new OpenLayers.Size(10,10);
|
|
var xy = new OpenLayers.Pixel(5,5);
|
|
var position = "absolute";
|
|
var id = "boo";
|
|
var border = "1px solid";
|
|
var sizing = "crop";
|
|
var opacity = 0.5;
|
|
|
|
OpenLayers.Util.modifyAlphaImageDiv(imageDiv, id, xy, sz, img, position, border, sizing, opacity);
|
|
if (OpenLayers.Util.alphaHack())
|
|
t.ok( true, "skipping element test outside of Mozilla");
|
|
else
|
|
t.ok( imageDiv.nodeName == "DIV", "createDiv creates a valid HTMLDivElement" );
|
|
|
|
t.eq( imageDiv.id, id, "image.id set correctly");
|
|
t.eq( imageDiv.style.left, xy.x + "px", "image.style.left set correctly");
|
|
t.eq( imageDiv.style.top, xy.y + "px", "image.style.top set correctly");
|
|
|
|
t.eq( imageDiv.style.width, sz.w + "px", "image.style.width set correctly");
|
|
t.eq( imageDiv.style.height, sz.h + "px", "image.style.height set correctly");
|
|
|
|
t.eq( imageDiv.style.position, position, "image.style.position set correctly");
|
|
t.eq( parseFloat(imageDiv.style.opacity), opacity, "element.style.opacity set correctly");
|
|
|
|
|
|
|
|
image = imageDiv.firstChild;
|
|
|
|
var filterString;
|
|
if (OpenLayers.Util.alphaHack()) {
|
|
filterString = "progid:DXImageTransform.Microsoft.AlphaImageLoader(src='http://www.openlayers.org/images/OpenLayers.trac.png', sizingMethod='crop') alpha(opacity=50)";
|
|
t.ok( true, "skipping element test outside of Mozilla");
|
|
} else {
|
|
var filterString = 'alpha(opacity=' + (opacity * 100) + ')';
|
|
t.ok( image.nodeName == "IMG", "createImage creates a valid HTMLImageElement" );
|
|
}
|
|
t.eq( imageDiv.style.filter, filterString, "element.style.filter set correctly");
|
|
t.eq( image.id, id + "_innerImage", "image.id set correctly");
|
|
|
|
t.eq( image.style.width, sz.w + "px", "image.style.width set correctly");
|
|
t.eq( image.style.height, sz.h + "px", "image.style.height set correctly");
|
|
|
|
t.ok( (image.style.border.indexOf(border) != -1), "image.style.border set correctly");
|
|
t.eq( image.style.position, "relative", "image.style.positionset correctly");
|
|
|
|
if (OpenLayers.Util.alphaHack()) {
|
|
|
|
t.eq(imageDiv.style.display, "inline-block", "imageDiv.style.display set correctly");
|
|
|
|
var filter = "progid:DXImageTransform.Microsoft" +
|
|
".AlphaImageLoader(src='" + img + "', " +
|
|
"sizingMethod='" + sizing + "') alpha(opacity=" + opacity *100 + ")";
|
|
t.eq(imageDiv.style.filter, filter, "div filter value correctly set");
|
|
|
|
filter = "progid:DXImageTransform.Microsoft.Alpha(opacity=0)";
|
|
t.eq(image.style.filter, filter, "image filter set correctly");
|
|
|
|
} else {
|
|
t.eq( image.src, img, "image.style.backgroundImage correctly");
|
|
t.ok(true, "div filter value not set (not in IE)");
|
|
t.ok(true, "image filter value not set (not in IE)");
|
|
}
|
|
|
|
var imageDiv = OpenLayers.Util.createAlphaImageDiv(id, xy, sz, img, position, border, "scale", opacity);
|
|
if (OpenLayers.Util.alphaHack()) {
|
|
var filter = "progid:DXImageTransform.Microsoft" +
|
|
".AlphaImageLoader(src='" + img + "', " +
|
|
"sizingMethod='scale') alpha(opacity=" + opacity *100 + ")";
|
|
t.eq(imageDiv.style.filter, filter, "sizingMethod default correctly set to scale");
|
|
} else {
|
|
t.ok(true);
|
|
}
|
|
|
|
}
|
|
|
|
function test_10_Util_upperCaseObject(t) {
|
|
|
|
t.plan(8);
|
|
|
|
var aKey = "chicken";
|
|
var aValue = "pot pie";
|
|
|
|
var bKey = "blorg";
|
|
var bValue = "us maximus";
|
|
|
|
var obj = new Object();
|
|
obj[aKey] = aValue;
|
|
obj[bKey] = bValue;
|
|
|
|
var uObj = OpenLayers.Util.upperCaseObject(obj);
|
|
|
|
//make sure old object not modified
|
|
t.eq(obj[aKey], aValue, "old lowercase value still present in old obj");
|
|
t.eq(obj[bKey], bValue, "old lowercase value still present in old obj");
|
|
|
|
t.eq(obj[aKey.toUpperCase()], null, "new uppercase value not present in old obj");
|
|
t.eq(obj[bKey.toUpperCase()], null, "new uppercase value not present in old obj");
|
|
|
|
//make sure new object modified
|
|
t.eq(uObj[aKey], null, "old lowercase value not present");
|
|
t.eq(uObj[bKey], null, "old lowercase value not present");
|
|
|
|
t.eq(uObj[aKey.toUpperCase()], aValue, "new uppercase value present");
|
|
t.eq(uObj[bKey.toUpperCase()], bValue, "new uppercase value present");
|
|
}
|
|
|
|
function test_11_Util_createUniqueID(t) {
|
|
t.plan(2);
|
|
|
|
var id = OpenLayers.Util.createUniqueID();
|
|
t.ok( id.startsWith("id_"), "default OpenLayers.Util.createUniqueID starts id correctly");
|
|
|
|
var id = OpenLayers.Util.createUniqueID("chicken");
|
|
t.ok( id.startsWith("chicken"), "OpenLayers.Util.createUniqueID starts id correctly");
|
|
}
|
|
|
|
function test_12_Util_limitSigDigs(t) {
|
|
|
|
t.plan(7);
|
|
|
|
var x;
|
|
|
|
x = 123456;
|
|
t.eq(x.limitSigDigs(3), 123000, "correctly rounds down");
|
|
|
|
x = 555555;
|
|
t.eq(x.limitSigDigs(3), 556000, "correctly rounds up");
|
|
|
|
x = 66;
|
|
t.eq(x.limitSigDigs(3), 66, "correctly handles number smaller than sigdig");
|
|
|
|
t.eq(x.limitSigDigs(null), 0, "correctly handles null sigdig");
|
|
t.eq(x.limitSigDigs(0), 0, "correctly handles 0 sigdig");
|
|
t.eq(x.limitSigDigs(-1), 0, "correctly handles negative sigdig");
|
|
|
|
x = 0;
|
|
t.eq(x.limitSigDigs(2), 0, "correctly handles 0 number");
|
|
|
|
|
|
|
|
}
|
|
|
|
function test_13_Util_normalizeScale(t) {
|
|
t.plan(2);
|
|
|
|
//normal scale
|
|
var scale = 1/5;
|
|
t.eq( OpenLayers.Util.normalizeScale(scale), scale, "normalizing a normal scale does nothing");
|
|
|
|
//funky scale
|
|
var scale = 5;
|
|
t.eq( OpenLayers.Util.normalizeScale(scale), 1/5, "normalizing a wrong scale works!");
|
|
|
|
|
|
}
|
|
|
|
function test_13_Util_getScaleResolutionTranslation(t) {
|
|
t.plan(4);
|
|
|
|
var scale = 1/150000000;
|
|
var resolution = OpenLayers.Util.getResolutionFromScale(scale);
|
|
t.eq(resolution.toFixed(6), "0.476217", "Calculated correct resolution for " + scale);
|
|
|
|
var scale = 1/150000000;
|
|
var resolution = OpenLayers.Util.getResolutionFromScale(scale, 'm');
|
|
t.eq(resolution.toFixed(6), "52916.638092", "Calculated correct resolution for " + scale);
|
|
|
|
scale = 150000000;
|
|
resolution = OpenLayers.Util.getResolutionFromScale(scale);
|
|
t.eq(resolution.toFixed(6), "0.476217", "Calculated correct resolution for " + scale);
|
|
|
|
scale = 150000000;
|
|
resolution = OpenLayers.Util.getResolutionFromScale(scale);
|
|
t.eq(OpenLayers.Util.getScaleFromResolution(resolution), scale, "scale->resolution->scale works");
|
|
}
|
|
function test_14_Util_getImgLocation(t) {
|
|
t.plan(3);
|
|
OpenLayers.ImgPath = "foo/";
|
|
t.eq(OpenLayers.Util.getImagesLocation(), "foo/", "ImgPath works as expected.");
|
|
OpenLayers.ImgPath = null;
|
|
t.eq(OpenLayers.Util.getImagesLocation().substr(OpenLayers.Util.getImagesLocation().length-4,4), "img/", "ImgPath works as expected when not set.");
|
|
|
|
OpenLayers.ImgPath = '';
|
|
t.eq(OpenLayers.Util.getImagesLocation().substr(OpenLayers.Util.getImagesLocation().length-4,4), "img/", "ImgPath works as expected when set to ''.");
|
|
}
|
|
|
|
function test_15_Util_isEquivalentUrl(t) {
|
|
t.plan(8);
|
|
|
|
var url1, url2, options;
|
|
|
|
//CASE
|
|
|
|
url1 = "http://www.openlayers.org";
|
|
url2 = "HTTP://WWW.OPENLAYERS.ORG";
|
|
|
|
t.ok(OpenLayers.Util.isEquivalentUrl(url1, url2), "default ignoreCase works");
|
|
|
|
//ARGS
|
|
|
|
url1 = "http://www.openlayers.org?foo=5;bar=6";
|
|
url2 = "http://www.openlayers.org?bar=6;foo=5";
|
|
|
|
t.ok(OpenLayers.Util.isEquivalentUrl(url1, url2), "shuffled arguments works");
|
|
|
|
//PORT
|
|
|
|
url1 = "http://www.openlayers.org:80";
|
|
url2 = "http://www.openlayers.org";
|
|
|
|
t.ok(OpenLayers.Util.isEquivalentUrl(url1, url2), "default ignorePort80 works");
|
|
|
|
options = {
|
|
'ignorePort80': false
|
|
}
|
|
url1 = "http://www.openlayers.org:80";
|
|
url2 = "http://www.openlayers.org:50";
|
|
|
|
t.ok(!OpenLayers.Util.isEquivalentUrl(url1, url2, options), "port check works");
|
|
|
|
|
|
//HASH
|
|
|
|
url1 = "http://www.openlayers.org#barf";
|
|
url2 = "http://www.openlayers.org";
|
|
|
|
t.ok(OpenLayers.Util.isEquivalentUrl(url1, url2), "default ignoreHash works");
|
|
options = {
|
|
'ignoreHash': false
|
|
}
|
|
t.ok(!OpenLayers.Util.isEquivalentUrl(url1, url2, options), "ignoreHash FALSE works");
|
|
|
|
//PROTOCOL
|
|
|
|
url1 = "http://www.openlayers.org";
|
|
url2 = "ftp://www.openlayers.org";
|
|
|
|
t.ok(!OpenLayers.Util.isEquivalentUrl(url1, url2), "default ignoreHash works");
|
|
|
|
|
|
//PATHNAME
|
|
url1 = "foo.html?bar=now#go";
|
|
url2 = "../tests/../tests/foo.html?bar=now#go";
|
|
|
|
t.ok(OpenLayers.Util.isEquivalentUrl(url1, url2), "relative vs. absolute paths works");
|
|
|
|
|
|
}
|
|
|
|
// -->
|
|
</script>
|
|
</head>
|
|
<body>
|
|
<div id="map" style="width: 1024px; height: 512px;"/>
|
|
</body>
|
|
</html>
|