Bug 841954 - Make sure onOpen callback fires in all cases, r=past
authorAnton Kovalyov <anton@mozilla.com>
Mon, 18 Feb 2013 11:29:20 -0800
changeset 122282 e884af799de8a163fd41b327dab601ebc5dbdb86
parent 122281 32f30440ced7a0bfcedef76c4e0927f074f06ac1
child 122283 3f0f2fc4bd0f4c9df2061a1ce9fd462a1a86fa4c
push id24328
push userttaubert@mozilla.com
push dateTue, 19 Feb 2013 09:39:45 +0000
treeherdermozilla-central@3f0f2fc4bd0f [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewerspast
bugs841954
milestone21.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 841954 - Make sure onOpen callback fires in all cases, r=past
browser/devtools/profiler/ProfilerPanel.jsm
browser/devtools/profiler/test/browser_profiler_bug_834878_source_buttons.js
--- a/browser/devtools/profiler/ProfilerPanel.jsm
+++ b/browser/devtools/profiler/ProfilerPanel.jsm
@@ -465,18 +465,20 @@ ProfilerPanel.prototype = {
         viewSource(data.uri, null, this.document, data.line);
     }
 
     gDevTools.showToolbox(this.target, "jsdebugger").then(function (toolbox) {
       let dbg = toolbox.getCurrentPanel();
       panelWin = dbg.panelWin;
 
       let view = dbg.panelWin.DebuggerView;
-      if (view.Source && view.Sources.selectedValue === data.uri) {
-        return void view.editor.setCaretPosition(data.line - 1);
+      if (view.Sources.selectedValue === data.uri) {
+        view.editor.setCaretPosition(data.line - 1);
+        onOpen();
+        return;
       }
 
       panelWin.addEventListener("Debugger:SourceShown", onSourceShown, false);
       panelWin.DebuggerView.Sources.preferredSource = data.uri;
     }.bind(this));
   },
 
   /**
--- a/browser/devtools/profiler/test/browser_profiler_bug_834878_source_buttons.js
+++ b/browser/devtools/profiler/test/browser_profiler_bug_834878_source_buttons.js
@@ -13,17 +13,26 @@ function test() {
       let data = { uri: SCRIPT, line: 5, isChrome: false };
 
       panel.displaySource(data, function onOpen() {
         let target = TargetFactory.forTab(tab);
         let dbg = gDevTools.getToolbox(target).getPanel("jsdebugger");
         let view = dbg.panelWin.DebuggerView;
 
         is(view.Sources.selectedValue, data.uri, "URI is different");
-        is(view.editor.getCaretPosition().line, data.line - 1, "Line is different");
+        is(view.editor.getCaretPosition().line, data.line - 1,
+          "Line is different");
 
-        tearDown(tab);
+        // Test the case where script is already loaded.
+        view.editor.setCaretPosition(1);
+        gDevTools.showToolbox(target, "jsprofiler").then(function () {
+          panel.displaySource(data, function onOpenAgain() {
+            is(view.editor.getCaretPosition().line, data.line - 1,
+              "Line is different");
+            tearDown(tab);
+          });
+        });
       });
     });
 
     panel.createProfile();
   });
 }