Backed out 2 changesets (bug 1544694) for XPCshell failures in devtools/server/tests/unit/test_blackboxing-01.js. CLOSED TREE
authorDorel Luca <dluca@mozilla.com>
Tue, 23 Apr 2019 13:09:41 +0300
changeset 470464 d6cdc1f35851af085218a5306a171599c92885fb
parent 470463 696aa652a9e1d48b993802b0c82dbb3f817a57f1
child 470465 113fa9baf3e0db62174708f2e97938356e0379ff
push id35906
push useraciure@mozilla.com
push dateTue, 23 Apr 2019 22:14:56 +0000
treeherdermozilla-central@0ce3633f8b80 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
bugs1544694
milestone68.0a1
backs out63d133aae187fde835f9f9a0b9f83bdbada8dcd8
fc739beb6782fc83f23b15fc383f7ca5887393bd
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
Backed out 2 changesets (bug 1544694) for XPCshell failures in devtools/server/tests/unit/test_blackboxing-01.js. CLOSED TREE Backed out changeset 63d133aae187 (bug 1544694) Backed out changeset fc739beb6782 (bug 1544694)
devtools/server/actors/source.js
devtools/server/tests/unit/test_get-executable-lines.js
devtools/server/tests/unit/xpcshell.ini
devtools/shared/client/source-client.js
devtools/shared/specs/source.js
--- a/devtools/server/actors/source.js
+++ b/devtools/server/actors/source.js
@@ -255,16 +255,35 @@ const SourceActor = ActorClassWithSpec(s
         this._contentType = result.contentType;
         return result;
       }, error => {
         this._reportLoadSourceError(error);
         throw error;
       });
   },
 
+  /**
+   * Get all executable lines from the current source
+   * @return Array - Executable lines of the current script
+   */
+  getExecutableLines: async function() {
+    const offsetsLines = new Set();
+    for (const s of this._findDebuggeeScripts()) {
+      for (const offset of s.getPossibleBreakpoints()) {
+        offsetsLines.add(offset.lineNumber);
+      }
+    }
+
+    const lines = [...offsetsLines];
+    lines.sort((a, b) => {
+      return a - b;
+    });
+    return lines;
+  },
+
   getBreakpointPositions(query) {
     const {
       start: {
         line: startLine = 0,
         column: startColumn = 0,
       } = {},
       end: {
         line: endLine = Infinity,
new file mode 100644
--- /dev/null
+++ b/devtools/server/tests/unit/test_get-executable-lines.js
@@ -0,0 +1,57 @@
+/* This Source Code Form is subject to the terms of the Mozilla Public
+ * License, v. 2.0. If a copy of the MPL was not distributed with this
+ * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
+
+"use strict";
+
+/**
+ * Test if getExecutableLines return correct information
+ */
+
+var gDebuggee;
+var gClient;
+var gThreadClient;
+
+const SOURCE_MAPPED_FILE = getFileUrl("sourcemapped.js");
+
+function run_test() {
+  initTestDebuggerServer();
+  gDebuggee = addTestGlobal("test-get-executable-lines");
+  gClient = new DebuggerClient(DebuggerServer.connectPipe());
+  gClient.connect().then(function _onConnect() {
+    attachTestTabAndResume(
+      gClient,
+      "test-get-executable-lines",
+      function(response, targetFront, threadClient) {
+        gThreadClient = threadClient;
+        test_executable_lines();
+      }
+    );
+  });
+
+  do_test_pending();
+}
+
+function test_executable_lines() {
+  gThreadClient.addOneTimeListener("newSource", function _onNewSource(evt, packet) {
+    Assert.equal(evt, "newSource");
+
+    gThreadClient.getSources(function({error, sources}) {
+      Assert.ok(!error);
+      const source = gThreadClient.source(sources[0]);
+      source.getExecutableLines(function(lines) {
+        Assert.ok(arrays_equal([2, 5, 7, 8, 10, 12, 14, 16, 17], lines));
+        finishClient(gClient);
+      });
+    });
+  });
+
+  const code = readFile("sourcemapped.js");
+
+  Cu.evalInSandbox(code, gDebuggee, "1.8",
+    SOURCE_MAPPED_FILE, 1);
+}
+
+function arrays_equal(a, b) {
+  return !(a < b || b < a);
+}
--- a/devtools/server/tests/unit/xpcshell.ini
+++ b/devtools/server/tests/unit/xpcshell.ini
@@ -212,16 +212,17 @@ skip-if = true # tests for breakpoint ac
 [test_requestTypes.js]
 reason = bug 937197
 [test_layout-reflows-observer.js]
 [test_protocolSpec.js]
 [test_registerClient.js]
 [test_client_request.js]
 [test_symbols-01.js]
 [test_symbols-02.js]
+[test_get-executable-lines.js]
 [test_xpcshell_debugging.js]
 support-files = xpcshell_debugging_script.js
 [test_setBreakpoint-at-the-beginning-of-a-minified-fn.js]
 [test_setBreakpoint-at-the-end-of-a-minified-fn.js]
 [test_setBreakpoint-on-column.js]
 [test_setBreakpoint-on-column-in-gcd-script.js]
 [test_setBreakpoint-on-line.js]
 [test_setBreakpoint-on-line-in-gcd-script.js]
--- a/devtools/shared/client/source-client.js
+++ b/devtools/shared/client/source-client.js
@@ -1,34 +1,42 @@
 /* This Source Code Form is subject to the terms of the Mozilla Public
  * License, v. 2.0. If a copy of the MPL was not distributed with this
  * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
 
 "use strict";
 
 const {arg, DebuggerClient} = require("devtools/shared/client/debugger-client");
 
+const noop = () => {};
+
 /**
  * A SourceClient provides a way to access the source text of a script.
  *
  * @param client ThreadClient
  *        The thread client parent.
  * @param form Object
  *        The form sent across the remote debugging protocol.
  */
 function SourceClient(client, form) {
   this._form = form;
   this._activeThread = client;
   this._client = client.client;
 }
 
 SourceClient.prototype = {
+  get _transport() {
+    return this._client._transport;
+  },
   get actor() {
     return this._form.actor;
   },
+  get request() {
+    return this._client.request;
+  },
   get url() {
     return this._form.url;
   },
 
   /**
    * Black box this SourceClient's source.
    */
   blackBox: DebuggerClient.requester(
@@ -49,16 +57,31 @@ SourceClient.prototype = {
       type: "unblackbox",
       range: arg(0),
     },
     {
       telemetry: "UNBLACKBOX",
     },
   ),
 
+  /**
+   * Get Executable Lines from a source
+   */
+  getExecutableLines: function(cb = noop) {
+    const packet = {
+      to: this._form.actor,
+      type: "getExecutableLines",
+    };
+
+    return this._client.request(packet).then(res => {
+      cb(res.lines);
+      return res.lines;
+    });
+  },
+
   getBreakpointPositions: function(query) {
     const packet = {
       to: this._form.actor,
       type: "getBreakpointPositions",
       query,
     };
     return this._client.request(packet);
   },
--- a/devtools/shared/specs/source.js
+++ b/devtools/shared/specs/source.js
@@ -17,16 +17,17 @@ types.addDictType("breakpointquery", {
   start: "nullable:nullablesourceposition",
   end: "nullable:nullablesourceposition",
 });
 
 const sourceSpec = generateActorSpec({
   typeName: "source",
 
   methods: {
+    getExecutableLines: { response: { lines: RetVal("json") } },
     getBreakpointPositions: {
       request: {
         query: Arg(0, "nullable:breakpointquery"),
       },
       response: {
         positions: RetVal("array:sourceposition"),
       },
     },