Bug 800231 - Intermittent browser_webconsole_bug_782653_CSS_links_in_Style_Editor.js | Test timed out, | Found a Tools:StyleEditor after previous test timed out; r=msucan
authorGirish Sharma <scrapmachines@gmail.com>
Fri, 02 Nov 2012 18:24:42 +0530
changeset 112173 0574e555e545df03117c04077faf8effdff88d62
parent 112172 577a6ac727ae731777869c865069af6e192d3341
child 112174 1ef4d2e4a07ec04732d0e20be5cf590a0e5bebe3
push id23798
push userryanvm@gmail.com
push dateSat, 03 Nov 2012 00:06:35 +0000
treeherdermozilla-central@6134edeea902 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersmsucan
bugs800231
milestone19.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 800231 - Intermittent browser_webconsole_bug_782653_CSS_links_in_Style_Editor.js | Test timed out, | Found a Tools:StyleEditor after previous test timed out; r=msucan
browser/devtools/webconsole/test/browser_webconsole_bug_782653_CSS_links_in_Style_Editor.js
--- a/browser/devtools/webconsole/test/browser_webconsole_bug_782653_CSS_links_in_Style_Editor.js
+++ b/browser/devtools/webconsole/test/browser_webconsole_bug_782653_CSS_links_in_Style_Editor.js
@@ -39,62 +39,54 @@ function testViewSource(hud) {
   });
 }
 
 function checkStyleEditorForSheetAndLine(aStyleSheetIndex, aLine, aCallback) {
 
   function doCheck(aEditor) {
     function checkLineAndCallback() {
       info("In checkLineAndCallback()");
-      ok(aEditor.sourceEditor != null, "sourceeditor not null");
-      ok(aEditor.sourceEditor.getCaretPosition() != null, "position not null");
-      ok(aEditor.sourceEditor.getCaretPosition().line != null, "line not null");
       is(aEditor.sourceEditor.getCaretPosition().line, aLine,
          "Correct line is selected");
       if (aCallback) {
         aCallback();
       }
     }
 
-    ok(aEditor, "aEditor is defined.");
-
-    // Source-editor is already loaded, check the current line of caret.
-    if (aEditor.sourceEditor) {
+    function checkForCorrectSheet() {
       if (aEditor.styleSheetIndex != SEC.selectedStyleSheetIndex) {
         ok(false, "Correct Style Sheet was not selected.");
         if (aCallback) {
           executeSoon(aCallback);
         }
         return;
       }
 
-      info("Correct Style Sheet is selected in the editor");
       info("Editor is already loaded, check the current line of caret");
       executeSoon(checkLineAndCallback);
+    }
+
+    ok(aEditor, "aEditor is defined.");
+
+    // Source-editor is already loaded, check the current sheet and line.
+    if (aEditor.sourceEditor) {
+      checkForCorrectSheet();
       return;
     }
 
     info("source editor is not loaded, waiting for it.");
-    // Wait for source editor to be loaded.
-    aEditor.addActionListener({
-      onAttach: function onAttach() {
-        info("on attach happened");
-        aEditor.removeActionListener(this);
-        info("this removed");
-        executeSoon(function() {
-          if (aEditor.styleSheetIndex != SEC.selectedStyleSheetIndex) {
-            ok(false, "Correct Style Sheet was not selected.");
-            if (aCallback) {
-              aCallback();
-            }
-            return;
-          }
-          checkLineAndCallback()
-        });
-      }
+    // Source-editor is not loaded, polling regularly and waiting for it to load
+    waitForSuccess({
+      name: "Wait for the source-editor to load",
+      validatorFn: function()
+      {
+        return aEditor.sourceEditor;
+      },
+      successFn: checkForCorrectSheet,
+      failureFn: aCallback,
     });
   }
 
   let SEC = styleEditorWin.styleEditorChrome;
   ok(SEC, "Syle Editor Chrome is defined properly while calling for [" +
           aStyleSheetIndex + ", " + aLine + "]");
 
   // Editors are not ready, so wait for them.
@@ -133,24 +125,20 @@ let observer = {
          "the location node");
 
     executeSoon(function() {
       styleEditorWin = window.StyleEditor
                              .StyleEditorManager
                              .getEditorForWindow(content.window);
       ok(styleEditorWin, "Style Editor Window is defined");
       waitForFocus(function() {
-        //styleEditorWin.addEventListener("load", function onStyleEditorWinLoad() {
-          //styleEditorWin.removeEventListener("load", onStyleEditorWinLoad);
-
-          checkStyleEditorForSheetAndLine(0, 7, function() {
-            checkStyleEditorForSheetAndLine(1, 6, function() {
-              window.StyleEditor.toggle();
-              styleEditorWin = null;
-              finishTest();
-            });
-            EventUtils.sendMouseEvent({ type: "click" }, nodes[1]);
+        checkStyleEditorForSheetAndLine(0, 7, function() {
+          checkStyleEditorForSheetAndLine(1, 6, function() {
+            window.StyleEditor.toggle();
+            styleEditorWin = null;
+            finishTest();
           });
-        //});
+          EventUtils.sendMouseEvent({ type: "click" }, nodes[1]);
+        });
       }, styleEditorWin);
     });
   }
 };