fix test_Handler_Box_draw by using another method to check whether we can get computed dimensions of an element (closes #3240)
git-svn-id: http://svn.openlayers.org/trunk/openlayers@11863 dc9f47b5-9b13-0410-9fdd-eb0c1a62fdaf
This commit is contained in:
+31
-11
@@ -18,15 +18,6 @@
|
|||||||
}
|
}
|
||||||
|
|
||||||
function test_Handler_Box_draw(t) {
|
function test_Handler_Box_draw(t) {
|
||||||
var testAll = true;
|
|
||||||
if (document.defaultView && document.defaultView.getComputedStyle &&
|
|
||||||
!document.defaultView.getComputedStyle(document.body, null)) {
|
|
||||||
// we don't get dimensions for hidden frames in FF4, and our test
|
|
||||||
// runs in a hidden frame.
|
|
||||||
testAll = false;
|
|
||||||
}
|
|
||||||
|
|
||||||
t.plan(testAll ? 12 : 2);
|
|
||||||
|
|
||||||
var map = new OpenLayers.Map('map');
|
var map = new OpenLayers.Map('map');
|
||||||
var control = new OpenLayers.Control();
|
var control = new OpenLayers.Control();
|
||||||
@@ -35,9 +26,38 @@
|
|||||||
t.ok(e.equals(new OpenLayers.Bounds(5, 11, 11, 5)), "box result correct");
|
t.ok(e.equals(new OpenLayers.Bounds(5, 11, 11, 5)), "box result correct");
|
||||||
}});
|
}});
|
||||||
handler.activate();
|
handler.activate();
|
||||||
|
|
||||||
|
// determine whether we can test the box position, the hidden frame
|
||||||
|
// our tests run in causes us problem here in FF and IE:
|
||||||
|
// IE8: left is NaN
|
||||||
|
// FF3: left is NaN
|
||||||
|
// FF4; left is NaN
|
||||||
|
// Chromium 10: left is 0
|
||||||
|
var testdiv = OpenLayers.Util.createDiv('testdiv', new OpenLayers.Pixel(5, 5));
|
||||||
|
map.div.appendChild(testdiv);
|
||||||
|
var left = parseInt(OpenLayers.Element.getStyle(testdiv, 'border-left-width'));
|
||||||
|
map.div.removeChild(testdiv);
|
||||||
|
var testAll = !isNaN(left);
|
||||||
|
|
||||||
|
t.plan(testAll ? 12 : 2);
|
||||||
|
|
||||||
|
// we change NaN values to 0 values in the handler's
|
||||||
|
// boxOffsets object, this is to prevent "invalid
|
||||||
|
// "argument" errors in IE
|
||||||
|
if(!testAll) {
|
||||||
|
var offset = handler.getBoxOffsets();
|
||||||
|
offset.left = 0;
|
||||||
|
offset.right = 0;
|
||||||
|
offset.top = 0;
|
||||||
|
offset.bottom = 0;
|
||||||
|
offset.width = 0;
|
||||||
|
offset.height = 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
handler.dragHandler.start = {x: 5, y: 5};
|
handler.dragHandler.start = {x: 5, y: 5};
|
||||||
handler.startBox({x: 5, y: 5});
|
handler.startBox();
|
||||||
var offset = handler.getBoxOffsets();
|
offset = handler.getBoxOffsets();
|
||||||
if (testAll) {
|
if (testAll) {
|
||||||
t.eq(parseInt(handler.zoomBox.style.left), 5 - offset.left, "x position of box correct");
|
t.eq(parseInt(handler.zoomBox.style.left), 5 - offset.left, "x position of box correct");
|
||||||
t.eq(parseInt(handler.zoomBox.style.top), 5 - offset.top, "y position of box correct");
|
t.eq(parseInt(handler.zoomBox.style.top), 5 - offset.top, "y position of box correct");
|
||||||
|
|||||||
Reference in New Issue
Block a user