Bug 703774 Cast the result of getAttribute() as Number before comparing the values r=enn
authorMasayuki Nakano <masayuki@d-toybox.com>
Thu, 29 Mar 2012 00:20:13 +0900
changeset 90526 c514f0c6098cc895175acbd575e4ad57c777b00a
parent 90525 2961cc5557921d26a33f4964897151b94d3f4948
child 90527 15a4628f412e69f70a4fb82ab9345dfed9bcdc51
push id1
push userroot
push dateMon, 20 Oct 2014 17:29:22 +0000
reviewersenn
bugs703774
milestone14.0a1
Bug 703774 Cast the result of getAttribute() as Number before comparing the values r=enn
layout/xul/test/test_bug159346.xul
--- a/layout/xul/test/test_bug159346.xul
+++ b/layout/xul/test/test_bug159346.xul
@@ -22,92 +22,95 @@ var downButton =
                                           "scrollbar-down-bottom");
 
 function init()
 {
   downButton.style.display = "-moz-box";
   SimpleTest.executeSoon(doTest1);
 }
 
+function getCurrentPos()
+{
+  return Number(scrollbar.getAttribute("curpos"));
+}
+
 function doTest1()
 {
   var lastPos = 0;
 
   synthesizeMouseAtCenter(downButton, { type: "mousedown" });
-  ok(scrollbar.getAttribute("curpos") > lastPos,
+  ok(getCurrentPos() > lastPos,
      "scrollbar didn't change curpos by mousedown #1");
-  lastPos = scrollbar.getAttribute("curpos");
+  lastPos = getCurrentPos();
 
   setTimeout(function () {
-    ok(scrollbar.getAttribute("curpos") > lastPos,
+    ok(getCurrentPos() > lastPos,
        "scrollbar didn't change curpos by auto repeat #1");
     synthesizeMouseAtCenter(downButton, { type: "mouseup" });
-    lastPos = scrollbar.getAttribute("curpos");
+    lastPos = getCurrentPos();
 
     setTimeout(function () {
-      is(scrollbar.getAttribute("curpos"), lastPos,
+      is(getCurrentPos(), lastPos,
          "scrollbar changed curpos after mouseup #1");
       SimpleTest.executeSoon(doTest2);
     }, 1000);
   }, 1000);
 }
 
 function doTest2()
 {
   SpecialPowers.setIntPref("ui.scrollbarButtonAutoRepeatBehavior", 0);
 
   scrollbar.setAttribute("curpos", 0);
   var lastPos = 0;
 
   synthesizeMouseAtCenter(downButton, { type: "mousedown" });
-  ok(scrollbar.getAttribute("curpos") > lastPos,
+  ok(getCurrentPos() > lastPos,
      "scrollbar didn't change curpos by mousedown #2");
-  lastPos = scrollbar.getAttribute("curpos");
+  lastPos = getCurrentPos();
 
   synthesizeMouse(downButton, -10, -10, { type: "mousemove" });
-  lastPos = scrollbar.getAttribute("curpos");
+  lastPos = getCurrentPos();
 
   setTimeout(function () {
-    is(scrollbar.getAttribute("curpos"), lastPos,
+    is(getCurrentPos(), lastPos,
        "scrollbar changed curpos by auto repeat when cursor is outside of scrollbar button #2");
     synthesizeMouseAtCenter(downButton, { type: "mousemove" });
-    lastPos = scrollbar.getAttribute("curpos");
+    lastPos = getCurrentPos();
 
     setTimeout(function () {
-      ok(scrollbar.getAttribute("curpos") > lastPos,
+      ok(getCurrentPos() > lastPos,
          "scrollbar didn't change curpos by mousemove after cursor is back on the scrollbar button #2");
       synthesizeMouseAtCenter(downButton, { type: "mouseup" });
       SimpleTest.executeSoon(doTest3);
     }, 1000);
   }, 1000);
 }
 
 function doTest3()
 {
   SpecialPowers.setIntPref("ui.scrollbarButtonAutoRepeatBehavior", 1);
 
   scrollbar.setAttribute("curpos", 0);
   var lastPos = 0;
 
   synthesizeMouseAtCenter(downButton, { type: "mousedown" });
-  ok(scrollbar.getAttribute("curpos") > lastPos,
+  ok(getCurrentPos() > lastPos,
      "scrollbar didn't change curpos by mousedown #3");
-  lastPos = scrollbar.getAttribute("curpos");
-
   synthesizeMouse(downButton, -10, -10, { type: "mousemove" });
-  lastPos = scrollbar.getAttribute("curpos");
+  lastPos = getCurrentPos();
 
   setTimeout(function () {
-    ok(scrollbar.getAttribute("curpos") > lastPos,
+    ok(getCurrentPos() > lastPos,
        "scrollbar didn't change curpos by auto repeat when cursor is outside of scrollbar button #3");
     synthesizeMouseAtCenter(downButton, { type: "mousemove" });
-    lastPos = scrollbar.getAttribute("curpos");
+    lastPos = getCurrentPos();
 
     setTimeout(function () {
-      ok(scrollbar.getAttribute("curpos") > lastPos,
+      ok(getCurrentPos() > lastPos,
          "scrollbar didn't change curpos by mousemove after cursor is back on the scrollbar button #3");
       synthesizeMouseAtCenter(downButton, { type: "mouseup" });
 
       SpecialPowers.clearUserPref("ui.scrollbarButtonAutoRepeatBehavior");
       SimpleTest.finish();
     }, 1000);
   }, 1000);
 }