[OpenLayers-Commits] r11863 - trunk/openlayers/tests/Handler
commits-20090109 at openlayers.org
commits-20090109 at openlayers.org
Mon Apr 4 03:19:50 EDT 2011
Author: erilem
Date: 2011-04-04 00:19:46 -0700 (Mon, 04 Apr 2011)
New Revision: 11863
Modified:
trunk/openlayers/tests/Handler/Box.html
Log:
fix test_Handler_Box_draw by using another method to check whether we can get computed dimensions of an element (closes #3240)
Modified: trunk/openlayers/tests/Handler/Box.html
===================================================================
--- trunk/openlayers/tests/Handler/Box.html 2011-04-03 19:49:01 UTC (rev 11862)
+++ trunk/openlayers/tests/Handler/Box.html 2011-04-04 07:19:46 UTC (rev 11863)
@@ -18,15 +18,6 @@
}
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 control = new OpenLayers.Control();
@@ -35,9 +26,38 @@
t.ok(e.equals(new OpenLayers.Bounds(5, 11, 11, 5)), "box result correct");
}});
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.startBox({x: 5, y: 5});
- var offset = handler.getBoxOffsets();
+ handler.startBox();
+ offset = handler.getBoxOffsets();
if (testAll) {
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");
More information about the Commits
mailing list