Bug 847881 - adjust test_sizetocontent_clamp for minimum window size constraints on Win8. r=mounir
authorJim Mathies <jmathies@mozilla.com>
Fri, 08 Mar 2013 05:22:36 -0600
changeset 124220 41efbfe49d6681067455f7645f8b337b7033857d
parent 124219 5f5bf431f520bb7ab0a5dc0be3163fdd811fecb3
child 124221 1e5fa603b569b3c5cedef40f6d13df195d19de47
push id24412
push userryanvm@gmail.com
push dateSun, 10 Mar 2013 00:01:53 +0000
treeherdermozilla-central@9e6232e86000 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersmounir
bugs847881
milestone22.0a1
first release with
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
last release without
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
Bug 847881 - adjust test_sizetocontent_clamp for minimum window size constraints on Win8. r=mounir
dom/tests/mochitest/bugs/test_sizetocontent_clamp.html
--- a/dom/tests/mochitest/bugs/test_sizetocontent_clamp.html
+++ b/dom/tests/mochitest/bugs/test_sizetocontent_clamp.html
@@ -18,40 +18,42 @@ https://bugzilla.mozilla.org/show_bug.cg
 </div>
 <pre id="test">
 <script type="application/javascript">
 
 /** Test for Bug 764240 **/
 
 SimpleTest.waitForExplicitFinish();
 
-// Error margin allowed for the window's size.
-// The window size being set by the platform, we can't guarantee it will be respected.
-// In platforms other than Windows, 5 is a good epsilon. On windows, it seems
-// that most of the time, the width is 14/15 higher than expected so we need
-// to have an epsilon that matches this difference.
-// Actually, on platforms other than Windows, epsilon of 0 might work.
-// Only innerWidth on Windows has a 14/15 pixels difference to what is
-// requested.
+// Error margin allowed for the window's size. Windows has varying minimum
+// sizes depending on the os due to outer window chrome. Unix is given 5
+// pixels to protect against minor variances.
 var epsilon =  navigator.platform.indexOf("Win") == -1 ? 5 : 20;
 
+// Windows 8 has a minimum 122 pixel inner window width due to
+// outer window chrome.
+var isWin8 = (navigator.userAgent.indexOf("Windows NT 6.2") != -1);
+
+var innerWidthMin = (isWin8 ? 120 : 100);
+var innerWidthMax = (isWin8 ? 125 : 100);
+
 function test() {
   var w = window.open('data:text/html,null', null, 'width=300,height=300');
   var nbResize = 0;
 
   SimpleTest.waitForFocus(function() {
     w.onresize = function() {
       nbResize++;
 
       if (nbResize == 1) {
         return;
       }
 
-      ok(w.innerWidth + epsilon >= 100 && w.innerWidth - epsilon <= 100,
-         "innerWidth should be around 100");
+      ok(w.innerWidth + epsilon >= innerWidthMin && w.innerWidth - epsilon <= innerWidthMax,
+         "innerWidth should be between " + innerWidthMin + " and " + innerWidthMax);
       ok(w.innerHeight + epsilon >= 100 && w.innerHeight - epsilon <= 100,
          "innerHeight should be around 100");
 
       // It's not clear why 2 events are coming...
       is(nbResize, 2, "We should get 2 events.");
 
       w.close();