Tests for vendor prefix detection
This commit is contained in:
+67
-1
@@ -1119,6 +1119,71 @@
|
|||||||
t.eq(OpenLayers.Util.getFormattedLonLat(-181, "lon"), "179°00'00\"E", "crossing dateline from the west results in correct east coordinate");
|
t.eq(OpenLayers.Util.getFormattedLonLat(-181, "lon"), "179°00'00\"E", "crossing dateline from the west results in correct east coordinate");
|
||||||
t.eq(OpenLayers.Util.getFormattedLonLat(181, "lon"), "179°00'00\"W", "crossing dateline from the east results in correct west coordinate");
|
t.eq(OpenLayers.Util.getFormattedLonLat(181, "lon"), "179°00'00\"W", "crossing dateline from the east results in correct west coordinate");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Test vendor prefixing
|
||||||
|
*/
|
||||||
|
function test_vendor_prefixes(t) {
|
||||||
|
t.plan(12);
|
||||||
|
var o = {}, err;
|
||||||
|
var orgCreateElement = document.createElement;
|
||||||
|
// wrap document.createElement to control property values
|
||||||
|
document.createElement = function(type) {
|
||||||
|
var el = orgCreateElement.call(document, type);
|
||||||
|
// Since o is an object we can change prop for each test
|
||||||
|
if(o.prop) {
|
||||||
|
el.style[o.prop] = o.val;
|
||||||
|
}
|
||||||
|
return el;
|
||||||
|
};
|
||||||
|
|
||||||
|
function curryTestPrefix(type) {
|
||||||
|
return function(standardProp, expectedPrefix, msg) {
|
||||||
|
var prefixedProp, err, method = "getVendorPrefixed" + type;
|
||||||
|
try {
|
||||||
|
OpenLayers.Util[method]("clear cache");
|
||||||
|
prefixedProp = OpenLayers.Util[method](standardProp);
|
||||||
|
} catch(e) {
|
||||||
|
err = e;
|
||||||
|
}
|
||||||
|
if(!err) {
|
||||||
|
t.eq(prefixedProp, expectedPrefix, msg);
|
||||||
|
} else {
|
||||||
|
t.fail("Error when testing " + type.toUpperCase() + " vendor prefix: " + err.message);
|
||||||
|
}
|
||||||
|
};
|
||||||
|
}
|
||||||
|
var testDomPrefix = curryTestPrefix("Dom"),
|
||||||
|
testCssPrefix = curryTestPrefix("Css");
|
||||||
|
|
||||||
|
o.prop = "test";
|
||||||
|
o.val = "";
|
||||||
|
testDomPrefix("test", "test", "DOM vendor prefix - single word");
|
||||||
|
testCssPrefix("test", "test", "CSS vendor prefix - single word");
|
||||||
|
|
||||||
|
o.prop = "testMultiWord";
|
||||||
|
testDomPrefix("testMultiWord", "testMultiWord", "DOM vendor prefix - multiple words");
|
||||||
|
testCssPrefix("test-multi-word", "test-multi-word", "CSS vendor prefix - multiple words");
|
||||||
|
|
||||||
|
o.prop = "WebkitMultiWord";
|
||||||
|
testDomPrefix("multiWord", "WebkitMultiWord", "DOM vendor prefix - multiple words for WebKit");
|
||||||
|
testCssPrefix("multi-word", "-webkit-multi-word", "CSS vendor prefix - multiple words for WebKit");
|
||||||
|
|
||||||
|
o.prop = "MozMultiWord";
|
||||||
|
testDomPrefix("multiWord", "MozMultiWord", "DOM vendor prefix - multiple words for Mozilla");
|
||||||
|
testCssPrefix("multi-word", "-moz-multi-word", "CSS vendor prefix - multiple words for Mozilla");
|
||||||
|
|
||||||
|
o.prop = "OMultiWord";
|
||||||
|
testDomPrefix("multiWord", "OMultiWord", "DOM vendor prefix - multiple words for Opera");
|
||||||
|
testCssPrefix("multi-word", "-o-multi-word", "CSS vendor prefix - multiple words for Opera");
|
||||||
|
|
||||||
|
o.prop = "msMultiWord";
|
||||||
|
testDomPrefix("multiWord", "msMultiWord", "DOM vendor prefix - multiple words for Internet Explorer");
|
||||||
|
testCssPrefix("multi-word", "-ms-multi-word", "CSS vendor prefix - multiple words for Internet Explorer");
|
||||||
|
|
||||||
|
// unwrap document.createElement
|
||||||
|
document.createElement = orgCreateElement;
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* To test that we can safely call OpenLayers.Util.extend with an Event
|
* To test that we can safely call OpenLayers.Util.extend with an Event
|
||||||
@@ -1127,7 +1192,7 @@
|
|||||||
var loadEvent;
|
var loadEvent;
|
||||||
window.onload = function(evt) {
|
window.onload = function(evt) {
|
||||||
loadEvent = evt || window.event;
|
loadEvent = evt || window.event;
|
||||||
}
|
};
|
||||||
function test_extend_event(t) {
|
function test_extend_event(t) {
|
||||||
t.plan(2);
|
t.plan(2);
|
||||||
t.ok(loadEvent, "loadEvent recorded");
|
t.ok(loadEvent, "loadEvent recorded");
|
||||||
@@ -1143,6 +1208,7 @@
|
|||||||
t.eq(extended && extended.foo, "bar", "extended with event");
|
t.eq(extended && extended.foo, "bar", "extended with event");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
</script>
|
</script>
|
||||||
</head>
|
</head>
|
||||||
|
|||||||
Reference in New Issue
Block a user