Bug 728830 - Intermittent browser_dbg_update-editor-mode.js | Found the expected editor mode. - Got js, expected html | The correct script was loaded initially. | The first script is displayed. | Test timed out; r=rcampbell
authorMihai Sucan <mihai.sucan@gmail.com>
Thu, 05 Apr 2012 13:47:26 +0300
changeset 94541 9f82d9ab3f1fa6da0058e09a68c3a9263acad720
parent 94304 ac5721fa4acba9a9bee19fe1088ae124c09e2475
child 94542 5d654a428c971c877dc9bf72727f4c47004e5e3e
push id886
push userlsblakk@mozilla.com
push dateMon, 04 Jun 2012 19:57:52 +0000
treeherdermozilla-beta@bbd8d5efd6d1 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersrcampbell
bugs728830
milestone14.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 728830 - Intermittent browser_dbg_update-editor-mode.js | Found the expected editor mode. - Got js, expected html | The correct script was loaded initially. | The first script is displayed. | Test timed out; r=rcampbell
browser/devtools/debugger/test/browser_dbg_update-editor-mode.js
--- a/browser/devtools/debugger/test/browser_dbg_update-editor-mode.js
+++ b/browser/devtools/debugger/test/browser_dbg_update-editor-mode.js
@@ -15,54 +15,73 @@ let SourceEditor = tempScope.SourceEdito
 var gPane = null;
 var gTab = null;
 var gDebuggee = null;
 var gDebugger = null;
 var gScripts = null;
 
 function test()
 {
+  let scriptShown = false;
+  let framesAdded = false;
+
   debug_tab_pane(TAB_URL, function(aTab, aDebuggee, aPane) {
     gTab = aTab;
     gDebuggee = aDebuggee;
     gPane = aPane;
     gDebugger = gPane.debuggerWindow;
 
-    testScriptsDisplay();
+    gPane.activeThread.addOneTimeListener("framesadded", function() {
+      framesAdded = true;
+      runTest();
+    });
+    gDebuggee.firstCall();
   });
+
+  window.addEventListener("Debugger:ScriptShown", function _onEvent(aEvent) {
+    let url = aEvent.detail.url;
+    if (url.indexOf("editor-mode") != -1) {
+      scriptShown = true;
+      window.removeEventListener(aEvent.type, _onEvent);
+      runTest();
+    }
+  });
+
+  function runTest()
+  {
+    if (scriptShown && framesAdded) {
+      Services.tm.currentThread.dispatch({ run: testScriptsDisplay }, 0);
+    }
+  }
 }
 
 function testScriptsDisplay() {
-  gPane.activeThread.addOneTimeListener("framesadded", function() {
-    Services.tm.currentThread.dispatch({ run: function() {
-      gScripts = gDebugger.DebuggerView.Scripts._scripts;
+  gScripts = gDebugger.DebuggerView.Scripts._scripts;
+
+  is(gDebugger.StackFrames.activeThread.state, "paused",
+    "Should only be getting stack frames while paused.");
 
-      is(gDebugger.StackFrames.activeThread.state, "paused",
-        "Should only be getting stack frames while paused.");
+  is(gScripts.itemCount, 2, "Found the expected number of scripts.");
 
-      is(gScripts.itemCount, 2, "Found the expected number of scripts.");
-
-      is(gDebugger.editor.getMode(), SourceEditor.MODES.HTML,
-         "Found the expected editor mode.");
+  is(gDebugger.editor.getMode(), SourceEditor.MODES.HTML,
+     "Found the expected editor mode.");
 
-      ok(gDebugger.editor.getText().search(/debugger/) != -1,
-        "The correct script was loaded initially.");
+  ok(gDebugger.editor.getText().search(/debugger/) != -1,
+    "The correct script was loaded initially.");
 
-      gDebugger.editor.addEventListener(SourceEditor.EVENTS.TEXT_CHANGED,
-                                        function onChange() {
-        gDebugger.editor.removeEventListener(SourceEditor.EVENTS.TEXT_CHANGED,
-                                             onChange);
-        testSwitchPaused();
-      });
-      gScripts.selectedIndex = 0;
-      gDebugger.SourceScripts.onChange({ target: gScripts });
-    }}, 0);
+  window.addEventListener("Debugger:ScriptShown", function _onEvent(aEvent) {
+    let url = aEvent.detail.url;
+    if (url.indexOf("switching-01.js") != -1) {
+      window.removeEventListener(aEvent.type, _onEvent);
+      testSwitchPaused();
+    }
   });
 
-  gDebuggee.firstCall();
+  let url = gDebuggee.document.querySelector("script").src;
+  gDebugger.DebuggerView.Scripts.selectScript(url);
 }
 
 function testSwitchPaused()
 {
   ok(gDebugger.editor.getText().search(/debugger/) == -1,
     "The second script is no longer displayed.");
 
   ok(gDebugger.editor.getText().search(/firstCall/) != -1,