Bug 1530612 - Pass CSS warning column through viewSouceInStyleEditor; r=nchevobbe.
authorAaditya Arora <b17071@students.iitmandi.ac.in>
Fri, 01 Mar 2019 16:43:02 +0000
changeset 520081 d860aa8a661bd0270ea6282a43e41e7027aea899
parent 520080 f362c19c19633e5c4d9dad794b85a9ad6905b9c5
child 520082 90615191631a422dff6c730390980e360b6b465e
push id10862
push userffxbld-merge
push dateMon, 11 Mar 2019 13:01:11 +0000
treeherdermozilla-beta@a2e7f5c935da [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersnchevobbe
bugs1530612
milestone67.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 1530612 - Pass CSS warning column through viewSouceInStyleEditor; r=nchevobbe. Pass CSS warning column location through viewSourceInStyleEditor so clicking on CSS warnings in console jumps to the right location in style editor Differential Revision: https://phabricator.services.mozilla.com/D21682
devtools/client/framework/toolbox.js
devtools/client/shared/view-source.js
devtools/client/webconsole/test/mochitest/browser_webconsole_location_styleeditor_link.js
devtools/client/webconsole/webconsole-wrapper.js
--- a/devtools/client/framework/toolbox.js
+++ b/devtools/client/framework/toolbox.js
@@ -3188,18 +3188,18 @@ Toolbox.prototype = {
   get gViewSourceUtils() {
     return this.win.gViewSourceUtils;
   },
 
   /**
    * Opens source in style editor. Falls back to plain "view-source:".
    * @see devtools/client/shared/source-utils.js
    */
-  viewSourceInStyleEditor: function(sourceURL, sourceLine) {
-    return viewSource.viewSourceInStyleEditor(this, sourceURL, sourceLine);
+  viewSourceInStyleEditor: function(sourceURL, sourceLine, sourceColumn) {
+    return viewSource.viewSourceInStyleEditor(this, sourceURL, sourceLine, sourceColumn);
   },
 
   /**
    * Opens source in debugger. Falls back to plain "view-source:".
    * @see devtools/client/shared/source-utils.js
    */
   viewSourceInDebugger: function(sourceURL, sourceLine, sourceId, reason) {
     return viewSource.viewSourceInDebugger(this, sourceURL, sourceLine, sourceId, reason);
--- a/devtools/client/shared/view-source.js
+++ b/devtools/client/shared/view-source.js
@@ -16,21 +16,21 @@ var { gDevTools } = require("devtools/cl
  *
  * @param {Toolbox} toolbox
  * @param {string} sourceURL
  * @param {number} sourceLine
  *
  * @return {Promise<boolean>}
  */
 exports.viewSourceInStyleEditor = async function(toolbox, sourceURL,
-                                                        sourceLine) {
+                                                        sourceLine, sourceColumn) {
   const panel = await toolbox.loadTool("styleeditor");
 
   try {
-    await panel.selectStyleSheet(sourceURL, sourceLine);
+    await panel.selectStyleSheet(sourceURL, sourceLine, sourceColumn);
     await toolbox.selectTool("styleeditor");
     return true;
   } catch (e) {
     exports.viewSource(toolbox, sourceURL, sourceLine);
     return false;
   }
 };
 
--- a/devtools/client/webconsole/test/mochitest/browser_webconsole_location_styleeditor_link.js
+++ b/devtools/client/webconsole/test/mochitest/browser_webconsole_location_styleeditor_link.js
@@ -36,21 +36,22 @@ async function testViewSource(hud, toolb
   const panel = await onStyleEditorSelected;
   ok(true, "The style editor is selected when clicking on the location element");
 
   await onStyleEditorReady(panel);
 
   info("style editor window focused");
   const href = frameLinkNode.getAttribute("data-url");
   const line = frameLinkNode.getAttribute("data-line");
+  const column = frameLinkNode.getAttribute("data-column");
   ok(line, "found source line");
 
   const editor = getEditorForHref(panel.UI, href);
   ok(editor, "found style editor for " + href);
-  await performLineCheck(panel.UI, editor, line - 1);
+  await checkCursorPosition(panel.UI, editor, line - 1, column - 1);
 }
 
 async function onStyleEditorReady(panel) {
   const win = panel.panelWindow;
   ok(win, "Style Editor Window is defined");
   ok(panel.UI, "Style Editor UI is defined");
 
   info("Waiting the style editor to be focused");
@@ -67,18 +68,20 @@ function getEditorForHref(styleEditorUI,
     if (editor.styleSheet.href == href) {
       foundEditor = editor;
       break;
     }
   }
   return foundEditor;
 }
 
-async function performLineCheck(styleEditorUI, editor, line) {
+async function checkCursorPosition(styleEditorUI, editor, line, column) {
   info("wait for source editor to load");
   // Get out of the styleeditor-selected event loop.
   await waitForTick();
 
   is(editor.sourceEditor.getCursor().line, line,
      "correct line is selected");
+  is(editor.sourceEditor.getCursor().ch, column,
+     "correct column is selected");
   is(styleEditorUI.selectedStyleSheetIndex, editor.styleSheet.styleSheetIndex,
      "correct stylesheet is selected in the editor");
 }
--- a/devtools/client/webconsole/webconsole-wrapper.js
+++ b/devtools/client/webconsole/webconsole-wrapper.js
@@ -274,17 +274,18 @@ class WebConsoleWrapper {
             frame.line
           ).then(() => {
             this.telemetry.recordEvent("jump_to_source", "webconsole",
                                        null, { "session_id": this.toolbox.sessionId }
             );
           }),
           onViewSourceInStyleEditor: frame => this.toolbox.viewSourceInStyleEditor(
             frame.url,
-            frame.line
+            frame.line,
+            frame.column
           ).then(() => {
             this.telemetry.recordEvent("jump_to_source", "webconsole",
                                        null, { "session_id": this.toolbox.sessionId }
             );
           }),
           openNetworkPanel: (requestId) => {
             return this.toolbox.selectTool("netmonitor").then((panel) => {
               return panel.panelWin.Netmonitor.inspectRequest(requestId);