[Pkg-mozext-commits] [firebug] 09/16: Issue 7621: Script panel causes 'Unresponsive script' dialog for trace.js:55

David Prévot taffit at moszumanska.debian.org
Thu Sep 18 18:10:14 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 a50d905ddb1c494dae624c7f73eac0f787399754
Author: Florent FAYOLLE <cold_sun at hotmail.fr>
Date:   Tue Sep 2 19:42:06 2014 +0200

    Issue 7621: Script panel causes 'Unresponsive script' dialog for trace.js:55
---
 .../content/firebug/debugger/script/sourceTool.js  | 53 ++++++++++------------
 1 file changed, 25 insertions(+), 28 deletions(-)

diff --git a/extension/content/firebug/debugger/script/sourceTool.js b/extension/content/firebug/debugger/script/sourceTool.js
index 19bfc1f..a13f2df 100644
--- a/extension/content/firebug/debugger/script/sourceTool.js
+++ b/extension/content/firebug/debugger/script/sourceTool.js
@@ -413,6 +413,7 @@ DynamicSourceCollector.prototype =
 
     addDynamicScript: function(script, type)
     {
+        Trace.sysout("sourceTool.addDynamicScript; enter in function", script);
         // Dynamic scripts use unique URL that is composed from script's location
         // such as line and column number.
         var url = computeDynamicUrl(script, this.context);
@@ -778,23 +779,35 @@ function computeDynamicUrl(script, context)
     var sourceFile = context.getSourceFile(uniqueUrl);
     if (sourceFile)
     {
-        // Use hash of the script source as unique identifier.
-        var hash = getSourceHash(script.source.text);
+        Trace.sysout("sourceTool.computeDynamicUrl; URL already computed. Testing whether " +
+            "the source is the same or not.", sourceFile);
 
-        if (!context.uniqueUrlMap)
+        if (!sourceFile.otherUniqueUrlsAtSameLocation)
+            sourceFile.otherUniqueUrlsAtSameLocation = [uniqueUrl];
+
+        // Lookup the matching source files.
+        var matchingSourceFileUrl = sourceFile.otherUniqueUrlsAtSameLocation.find((url) =>
         {
-            context.uniqueUrlMap = new Map();
-            context.uniqueUrlCounter = 0;
-        }
+            var sf = context.getSourceFile(url);
+            return sf.scripts && sf.scripts.length > 0 &&
+                (sf.scripts[0].source === script.source ||
+                sf.scripts[0].source.text === script.source.text);
+        });
 
-        var index = context.uniqueUrlMap.get(hash);
-        if (typeof index == "undefined")
+        if (matchingSourceFileUrl)
         {
-            index = ++context.uniqueUrlCounter;
-            context.uniqueUrlMap.set(hash, index);
+            uniqueUrl = matchingSourceFileUrl;
+        }
+        else
+        {
+            Trace.sysout("sourceTool.computeDynamicUrl; Creating a new unique URL for Source File",
+                sourceFile);
+            var index = (sourceFile.uniqueUrlIndex || 0) + 1;
+            sourceFile.uniqueUrlIndex = index;
+            // Update the unique URL so it is really unique.
+            uniqueUrl += " (" + index + ")";
+            sourceFile.otherUniqueUrlsAtSameLocation.push(uniqueUrl);
         }
-
-        uniqueUrl += " (" + index + ")";
     }
 
     return uniqueUrl;
@@ -802,22 +815,6 @@ function computeDynamicUrl(script, context)
 
 // ********************************************************************************************* //
 
-function getSourceHash(source)
-{
-    var converter = Cc["@mozilla.org/intl/scriptableunicodeconverter"].
-        createInstance(Ci.nsIScriptableUnicodeConverter);
-    converter.charset = "UTF-8";
-
-    var result = {};
-    var data = converter.convertToByteArray(source, result);
-    var ch = Cc["@mozilla.org/security/hash;1"].createInstance(Ci.nsICryptoHash);
-
-    ch.init(ch.MD5);
-    ch.update(data, data.length);
-
-    return ch.finish(true);
-}
-
 function getElementId(script)
 {
     var element = script.source.element;

-- 
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