From 60a966714d17c89b658c7ede35f05d0e53811d24 Mon Sep 17 00:00:00 2001 From: ahocevar Date: Tue, 23 Apr 2013 14:22:31 +0200 Subject: [PATCH] Hack for making page position calculations work Many browsers do very limited rendering/reflow on hidden IFrames. By making the test IFrame visible, we get everything rendered like a real page. This is a partial fix for #947. --- tests/Util.html | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/tests/Util.html b/tests/Util.html index 3972d68d84..528a932cce 100644 --- a/tests/Util.html +++ b/tests/Util.html @@ -111,6 +111,16 @@ function test_Util_pagePosition(t) { t.plan( 2 ); + + // making sure that the test iframe is visible + var origDisplay; + var parents = window.parent.document.getElementsByTagName('iframe'); + if (parents.length) { + origDisplay = parents[1].parentNode.style.display; + // span containing the test iframe is the invisible element + parents[1].parentNode.style.display = ""; + } + var pp = OpenLayers.Util.pagePosition(window); t.eq( pp.toString(), "0,0", "Page position doesn't bail if passed 'window'"); @@ -118,6 +128,11 @@ var mapDiv = document.getElementById("map"); pp = OpenLayers.Util.pagePosition(mapDiv); t.eq( pp.toString(), "123,1234", "Page position should work after page has been scrolled"); + + // reset test iframe visibility + if (parents.length) { + parents[1].parentNode.style.display = origDisplay; + } } function test_Util_createDiv(t) {