[Pkg-mozext-commits] [firebug] 17/35: Issue 7470: Breakpoint conditions are disregarde

David Prévot taffit at moszumanska.debian.org
Sat May 24 14:54:28 UTC 2014


This is an automated email from the git hooks/post-receive script.

taffit pushed a commit to branch master
in repository firebug.

commit 905ce2f56527981033f75ee7233b2729810534db
Author: Jan Odvarko <odvarko at gmail.com>
Date:   Thu May 22 10:05:41 2014 +0200

    Issue 7470: Breakpoint conditions are disregarde
---
 .../debugger/breakpoints/breakpointStore.js        |  2 +-
 .../firebug/debugger/breakpoints/breakpointTool.js | 91 +++++++++++++++++++++-
 2 files changed, 91 insertions(+), 2 deletions(-)

diff --git a/extension/content/firebug/debugger/breakpoints/breakpointStore.js b/extension/content/firebug/debugger/breakpoints/breakpointStore.js
index cf7506c..e17af1b 100644
--- a/extension/content/firebug/debugger/breakpoints/breakpointStore.js
+++ b/extension/content/firebug/debugger/breakpoints/breakpointStore.js
@@ -458,7 +458,7 @@ var BreakpointStore = Obj.extend(Module,
 
         this.save(url);
 
-        this.dispatch("onModifyBreakpoint", [bp]);
+        this.dispatch("onModifyCondition", [bp]);
     },
 
     isBreakpointDisabled: function(url, lineNo)
diff --git a/extension/content/firebug/debugger/breakpoints/breakpointTool.js b/extension/content/firebug/debugger/breakpoints/breakpointTool.js
index a60974a..d63f09e 100644
--- a/extension/content/firebug/debugger/breakpoints/breakpointTool.js
+++ b/extension/content/firebug/debugger/breakpoints/breakpointTool.js
@@ -180,6 +180,41 @@ BreakpointTool.prototype = Obj.extend(new Tool(),
         this.dispatch("onBreakpointModified", [this.context, bp]);
     },
 
+    onModifyCondition: function(bp)
+    {
+        var client = this.getBreakpointClient(bp.href, bp.lineNo);
+
+        if (!client)
+        {
+            TraceError.sysout("breakpointTool.onModifyCondition; ERROR no client!");
+            return;
+        }
+
+        var condition = bp.condition || "";
+
+        Trace.sysout("breakpointTool.onModifyCondition; set bp condition: " +
+            condition, bp);
+
+        // xxxHonza: BreakpointClient.setCondition() has been introduced in
+        // Firefox 31 [Fx31], and so use internal implementation cloned from
+        // Firefox 32 in that case.
+        var set;
+        if (client.setCondition)
+            set = client.setCondition.bind(client, this.context.activeThread, bp.condition);
+        else
+            set = setCondition.bind(this, this.context, client, bp.condition);
+
+        set().then((newBpClient) =>
+        {
+            Trace.sysout("breakpointTool.onModifyCondition; Done", newBpClient);
+
+            this.removeBreakpointClient(bp.href, bp.lineNo);
+            this.context.breakpointClients.push(newBpClient);
+
+            this.dispatch("onBreakpointModified", [this.context, bp]);
+        });
+    },
+
     onRemoveAllBreakpoints: function(bps)
     {
         Trace.sysout("breakpointTool.onRemoveAllBreakpoints; (" + bps.length + ")", bps);
@@ -317,9 +352,12 @@ BreakpointTool.prototype = Obj.extend(new Tool(),
 
         function doSetBreakpoint(callback)
         {
+            var bp = BreakpointStore.findBreakpoint(url, lineNumber);
+
             var location = {
                 url: url,
-                line: lineNumber + 1
+                line: lineNumber + 1,
+                condition: bp.condition,
             };
 
             Trace.sysout("breakpointTool.doSetBreakpoint; (" + lineNumber + ")", location);
@@ -686,6 +724,57 @@ BreakpointTool.prototype = Obj.extend(new Tool(),
 });
 
 // ********************************************************************************************* //
+// Set Condition
+
+/**
+ * Set the condition of this breakpoint.
+ * xxxHonza: cloned from dbg-client.jsm and modifed [Fx32].
+ */
+function setCondition(context, bpClient, aCondition)
+{
+    let threadClient = context.activeThread;
+    let root = bpClient._client.mainRoot;
+    let deferred = context.defer();
+
+    if (root.traits.conditionalBreakpoints) {
+      let info = {
+        url: bpClient.location.url,
+        line: bpClient.location.line,
+        column: bpClient.location.column,
+        condition: aCondition
+      };
+
+      // Remove the current breakpoint and add a new one with the
+      // condition.
+      bpClient.remove(aResponse => {
+        if (aResponse && aResponse.error) {
+          deferred.reject(aResponse);
+          return;
+        }
+
+        threadClient.setBreakpoint(info, (aResponse, aNewBreakpoint) => {
+          if (aResponse && aResponse.error) {
+            deferred.reject(aResponse);
+          } else {
+            deferred.resolve(aNewBreakpoint);
+          }
+        });
+      });
+    } else {
+      // The property shouldn't even exist if the condition is blank
+      if(aCondition === "") {
+        delete bpClient.conditionalExpression;
+      }
+      else {
+        bpClient.conditionalExpression = aCondition;
+      }
+      deferred.resolve(bpClient);
+    }
+
+    return deferred.promise;
+}
+
+// ********************************************************************************************* //
 // Registration
 
 Firebug.registerTool("breakpoint", BreakpointTool);

-- 
Alioth's /usr/local/bin/git-commit-notice on /srv/git.debian.org/git/pkg-mozext/firebug.git



More information about the Pkg-mozext-commits mailing list