Bug 674770 part.2 Fix new test_bug597331.html failure and test_bug600570.html failur on Windows r=ehsan, a=lsblakk
authorMasayuki Nakano <masayuki@d-toybox.com>
Sat, 26 Nov 2011 13:51:48 +0900
changeset 81943 c8c9093bbb517002fc3630402ddfe4afafc48025
parent 81942 2a45f89808a57e83d4cfab6c8102b88176b2acbc
child 81944 012144090a5dae1c7c3174a442b18d5d7ccfa276
push id239
push usermasayuki@d-toybox.com
push dateFri, 10 Aug 2012 01:28:27 +0000
reviewersehsan, lsblakk
bugs674770, 597331, 600570
milestone10.0.7esrpre
Bug 674770 part.2 Fix new test_bug597331.html failure and test_bug600570.html failur on Windows r=ehsan, a=lsblakk
editor/libeditor/text/tests/test_bug597331.html
editor/libeditor/text/tests/test_bug600570.html
--- a/editor/libeditor/text/tests/test_bug597331.html
+++ b/editor/libeditor/text/tests/test_bug597331.html
@@ -20,44 +20,51 @@ line3
 </textarea>
 </div>
 <pre id="test">
 <script type="application/javascript">
 
 /** Test for Bug 597331 **/
 SimpleTest.waitForExplicitFinish();
 addLoadEvent(function() {
-  var t = document.querySelector("textarea");
-  t.focus();
-  t.selectionStart = 4;
-  t.selectionEnd = 4;
   SimpleTest.executeSoon(function() {
-    var before = snapshotWindow(window, true);
-    t.selectionStart = 5;
-    t.selectionEnd = 5;
-    t.addEventListener("keydown", function() {
-      t.removeEventListener("keydown", arguments.callee, false);
+    var t = document.querySelector("textarea");
+    t.focus();
+    t.selectionStart = 4;
+    t.selectionEnd = 4;
+    SimpleTest.executeSoon(function() {
+      var before = snapshotWindow(window, true);
+      t.selectionStart = 5;
+      t.selectionEnd = 5;
+      t.addEventListener("keydown", function() {
+        t.removeEventListener("keydown", arguments.callee, false);
+
+        SimpleTest.executeSoon(function() {
+          t.style.display = 'block';
+          document.body.offsetWidth;
+          t.style.display = '';
+          document.body.offsetWidth;
 
-      SimpleTest.executeSoon(function() {
-        t.style.display = 'block';
-        document.body.offsetWidth;
-        t.style.display = '';
-        document.body.offsetWidth;
+          is(t.selectionStart, 4, "Cursor should be moved correctly");
+          is(t.selectionEnd, 4, "Cursor should be moved correctly");
 
-        is(t.selectionStart, 4, "Cursor should be moved correctly");
-        is(t.selectionEnd, 4, "Cursor should be moved correctly");
+          var after = snapshotWindow(window, true);
 
-        var after = snapshotWindow(window, true);
-
-        var result = compareSnapshots(before, after, true);
-        ok(result[0], "The caret should be displayed correctly after reframing");
+          var result = compareSnapshots(before, after, true);
+          var msg = "The caret should be displayed correctly after reframing";
+          if (!result[0]) {
+            msg += "\nRESULT:\n" + result[2];
+            msg += "\nREFERENCE:\n" + result[1];
+          }
+          ok(result[0], msg);
 
-        SimpleTest.finish();
-      });
-    }, false);
-    synthesizeKey("VK_LEFT", {});
+          SimpleTest.finish();
+        });
+      }, false);
+      synthesizeKey("VK_LEFT", {});
+    });
   });
 });
 
 </script>
 </pre>
 </body>
 </html>
--- a/editor/libeditor/text/tests/test_bug600570.html
+++ b/editor/libeditor/text/tests/test_bug600570.html
@@ -25,49 +25,55 @@ aaa
 
 SimpleTest.waitForExplicitFinish();
 SimpleTest.waitForFocus(function() {
   var t = document.querySelector("textarea");
   t.value = "[aaa\nbbb]";
   t.focus();
   synthesizeKey("A", {accelKey: true});
 
-  var afterSetValue = snapshotWindow(window);
+  SimpleTest.executeSoon(function() {
+    var afterSetValue = snapshotWindow(window);
 
-  t.value = t.defaultValue;
+    t.value = t.defaultValue;
 
-  t.selectionStart = 0;
-  t.selectionEnd = 4;
-  SimpleTest.waitForClipboard("aaa\n",
-    function() {
-      synthesizeKey("X", {accelKey: true});
-    },
-    function() {
-      t.addEventListener("input", function() {
-        t.removeEventListener("input", arguments.callee, false);
+    t.selectionStart = 0;
+    t.selectionEnd = 4;
+    SimpleTest.waitForClipboard("aaa\n",
+      function() {
+        synthesizeKey("X", {accelKey: true});
+      },
+      function() {
+        t.addEventListener("input", function() {
+          t.removeEventListener("input", arguments.callee, false);
+
+          setTimeout(function() { // Avoid the assertion in bug 649797
+            is(t.value, "[aaa\nbbb]", "The value of the textarea should be correct");
+            synthesizeKey("A", {accelKey: true});
+            is(t.selectionStart, 0, "Select all should set the selection start to the beginning of textarea");
+            is(t.selectionEnd, 9, "Select all should set the selection end to the end of textarea");
 
-        setTimeout(function() { // Avoid the assertion in bug 649797
-          is(t.value, "[aaa\nbbb]", "The value of the textarea should be correct");
-          synthesizeKey("A", {accelKey: true});
-          is(t.selectionStart, 0, "Select all should set the selection start to the beginning of textarea");
-          is(t.selectionEnd, 9, "Select all should set the selection end to the end of textarea");
+            var afterPaste = snapshotWindow(window);
 
-          var afterPaste = snapshotWindow(window);
-
-          var res = compareSnapshots(afterSetValue, afterPaste, true);
-          ok(res[0], "Pasting and setting the value directly should result in the same rendering");
+            var res = compareSnapshots(afterSetValue, afterPaste, true);
+            var msg = "Pasting and setting the value directly should result in the same rendering";
+            if (!res[0]) {
+              msg += "\nRESULT:\n" + res[2] + "\nREFERENCE:\n" + res[1];
+            }
+            ok(res[0], msg);
 
-          SimpleTest.finish();
-        }, 0);
-      }, false);
-      synthesizeKey("VK_RIGHT", {});
-      synthesizeKey("V", {accelKey: true});
-    },
-    function() {
-      SimpleTest.finish();
-    }
-  );
+            SimpleTest.finish();
+          }, 0);
+        }, false);
+        synthesizeKey("VK_RIGHT", {});
+        synthesizeKey("V", {accelKey: true});
+      },
+      function() {
+        SimpleTest.finish();
+      }
+    );
+  });
 });
 
 </script>
 </pre>
 </body>
 </html>