Bug 726609 - Intermittent browser_dbg_select-line.js | The correct line is selected. - Got 0, expected 5; r=msucan
authorPanos Astithas <past@mozilla.com>
Wed, 15 Feb 2012 16:12:27 +0200
changeset 89849 4f8f17eacf31390bb66954fee225582f0548ab82
parent 89667 81f6b9cbb2a92ac08d1ccc0c1b44d6a5c28f6e2a
child 89850 ec0c67eda91eb2964ad595cac14d7f62ccec0aca
push idunknown
push userunknown
push dateunknown
reviewersmsucan
bugs726609
milestone13.0a1
Bug 726609 - Intermittent browser_dbg_select-line.js | The correct line is selected. - Got 0, expected 5; r=msucan
browser/devtools/debugger/test/browser_dbg_select-line.js
--- a/browser/devtools/debugger/test/browser_dbg_select-line.js
+++ b/browser/devtools/debugger/test/browser_dbg_select-line.js
@@ -38,44 +38,48 @@ function testSelectLine() {
       is(gDebugger.StackFrames.activeThread.state, "paused",
         "Should only be getting stack frames while paused.");
 
       is(gScripts.itemCount, 2, "Found the expected number of scripts.");
 
       ok(gDebugger.editor.getText().search(/debugger/) != -1,
         "The correct script was loaded initially.");
 
-      // getCaretPosition is 0-based.
-      is(gDebugger.editor.getCaretPosition().line, 5,
-         "The correct line is selected.");
+      // Yield control back to the event loop so that the debugger has a
+      // chance to highlight the proper line.
+      executeSoon(function(){
+        // getCaretPosition is 0-based.
+        is(gDebugger.editor.getCaretPosition().line, 5,
+           "The correct line is selected.");
 
-      gDebugger.editor.addEventListener(SourceEditor.EVENTS.TEXT_CHANGED,
-                                        function onChange() {
-        gDebugger.editor.removeEventListener(SourceEditor.EVENTS.TEXT_CHANGED,
-                                             onChange);
-        ok(gDebugger.editor.getText().search(/debugger/) == -1,
-          "The second script is no longer displayed.");
+        gDebugger.editor.addEventListener(SourceEditor.EVENTS.TEXT_CHANGED,
+                                          function onChange() {
+          gDebugger.editor.removeEventListener(SourceEditor.EVENTS.TEXT_CHANGED,
+                                               onChange);
+          ok(gDebugger.editor.getText().search(/debugger/) == -1,
+            "The second script is no longer displayed.");
 
-        ok(gDebugger.editor.getText().search(/firstCall/) != -1,
-          "The first script is displayed.");
+          ok(gDebugger.editor.getText().search(/firstCall/) != -1,
+            "The first script is displayed.");
 
-        // Yield control back to the event loop so that the debugger has a
-        // chance to highlight the proper line.
-        executeSoon(function(){
-          // getCaretPosition is 0-based.
-          is(gDebugger.editor.getCaretPosition().line, 4,
-             "The correct line is selected.");
+          // Yield control back to the event loop so that the debugger has a
+          // chance to highlight the proper line.
+          executeSoon(function(){
+            // getCaretPosition is 0-based.
+            is(gDebugger.editor.getCaretPosition().line, 4,
+               "The correct line is selected.");
 
-          gDebugger.StackFrames.activeThread.resume(function() {
-            removeTab(gTab);
-            finish();
+            gDebugger.StackFrames.activeThread.resume(function() {
+              removeTab(gTab);
+              finish();
+            });
           });
         });
+
+        // Click the oldest stack frame.
+        let element = gDebugger.document.getElementById("stackframe-3");
+        EventUtils.synthesizeMouseAtCenter(element, {}, gDebugger);
       });
-
-      // Click the oldest stack frame.
-      let element = gDebugger.document.getElementById("stackframe-3");
-      EventUtils.synthesizeMouseAtCenter(element, {}, gDebugger);
     }}, 0);
   });
 
   gDebuggee.firstCall();
 }