Bug 941018 - Add default value for col in selectStyleSheet. r=paul, a=bajaj
authorAnton Kovalyov <anton@mozilla.com>
Tue, 26 Nov 2013 10:01:02 -0800
changeset 167608 9dc220412fa7aab1131eddfc86a7a9d0c23d4f38
parent 167607 881c0899f01326becf25f56e052b31c5cdbb354b
child 167609 e34cda9a452153970a785aaa0ed24103e4867113
push id428
push userbbajaj@mozilla.com
push dateTue, 28 Jan 2014 00:16:25 +0000
treeherdermozilla-release@cd72a7ff3a75 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewerspaul, bajaj
bugs941018
milestone27.0a2
Bug 941018 - Add default value for col in selectStyleSheet. r=paul, a=bajaj
browser/devtools/styleeditor/StyleEditorPanel.jsm
browser/devtools/styleeditor/test/browser.ini
browser/devtools/styleeditor/test/browser_styleeditor_selectstylesheet.js
--- a/browser/devtools/styleeditor/StyleEditorPanel.jsm
+++ b/browser/devtools/styleeditor/StyleEditorPanel.jsm
@@ -95,17 +95,17 @@ StyleEditorPanel.prototype = {
    * @param {number} col
    *        Column number to jump to after selecting. One-indexed
    */
   selectStyleSheet: function(href, line, col) {
     if (!this._debuggee || !this.UI) {
       return;
     }
     let stylesheet = this._debuggee.styleSheetFromHref(href);
-    this.UI.selectStyleSheet(href, line - 1, col - 1);
+    this.UI.selectStyleSheet(href, line - 1, col ? col - 1 : 0);
   },
 
   /**
    * Destroy the style editor.
    */
   destroy: function() {
     if (!this._destroyed) {
       this._destroyed = true;
--- a/browser/devtools/styleeditor/test/browser.ini
+++ b/browser/devtools/styleeditor/test/browser.ini
@@ -34,8 +34,9 @@ support-files =
 [browser_styleeditor_loading.js]
 [browser_styleeditor_new.js]
 [browser_styleeditor_nostyle.js]
 [browser_styleeditor_pretty.js]
 [browser_styleeditor_private_perwindowpb.js]
 [browser_styleeditor_reload.js]
 [browser_styleeditor_sv_keynav.js]
 [browser_styleeditor_sv_resize.js]
+[browser_styleeditor_selectstylesheet.js]
\ No newline at end of file
new file mode 100644
--- /dev/null
+++ b/browser/devtools/styleeditor/test/browser_styleeditor_selectstylesheet.js
@@ -0,0 +1,54 @@
+/* vim: set ts=2 et sw=2 tw=80: */
+/* Any copyright is dedicated to the Public Domain.
+   http://creativecommons.org/publicdomain/zero/1.0/ */
+
+const TESTCASE_URI = TEST_BASE_HTTPS + "simple.html";
+const NEW_URI = TEST_BASE_HTTPS + "media.html";
+
+const LINE_NO = 5;
+const COL_NO  = 0;
+
+let gContentWin;
+let gUI;
+
+function test()
+{
+  waitForExplicitFinish();
+
+  addTabAndOpenStyleEditor(function(panel) {
+    gContentWin = gBrowser.selectedTab.linkedBrowser.contentWindow.wrappedJSObject;
+    gUI = panel.UI;
+
+    let count = 0;
+    gUI.on("editor-added", function editorAdded(event, editor) {
+      if (++count == 2) {
+        gUI.off("editor-added", editorAdded);
+        gUI.editors[0].getSourceEditor().then(runTests);
+      }
+    })
+  });
+
+  content.location = TESTCASE_URI;
+}
+
+function runTests()
+{
+  let count = 0;
+
+  // Make sure Editor doesn't go into an infinite loop when
+  // column isn't passed. See bug 941018.
+  gUI.once("editor-selected", (event, editor) => {
+    editor.getSourceEditor().then(() => {
+      is(gUI.selectedEditor, gUI.editors[1], "second editor is selected");
+      let {line, ch} = gUI.selectedEditor.sourceEditor.getCursor();
+      
+      is(line, LINE_NO, "correct line selected");
+      is(ch, COL_NO, "correct column selected");
+
+      gUI = null;
+      finish();
+    });
+  });
+
+  gUI.selectStyleSheet(gUI.editors[1].styleSheet.href, LINE_NO);
+}
\ No newline at end of file