[Pkg-mozext-commits] [firebug] 18/55: Issue 4171: Expanding an XMLHttpRequest in Console tab before it ends makes JSON tab disappear

David Prévot taffit at moszumanska.debian.org
Mon Mar 31 22:46:08 UTC 2014


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

taffit pushed a commit to tag firebug-1.10.1
in repository firebug.

commit 01f3a77630ccaf67109ad5235186a97fe65070e4
Author: Jan Odvarko <odvarko at gmail.com>
Date:   Wed Jul 18 13:17:40 2012 +0200

    Issue 4171: 	Expanding an XMLHttpRequest in Console tab before it ends makes JSON tab disappear
---
 extension/content/firebug/cookies/cookieModule.js |  2 +-
 extension/content/firebug/net/netReps.js          | 10 ++--
 extension/content/firebug/net/spy.js              | 58 +++++++++++++++++++----
 3 files changed, 56 insertions(+), 14 deletions(-)

diff --git a/extension/content/firebug/cookies/cookieModule.js b/extension/content/firebug/cookies/cookieModule.js
index 6250981..0015b05 100644
--- a/extension/content/firebug/cookies/cookieModule.js
+++ b/extension/content/firebug/cookies/cookieModule.js
@@ -1136,7 +1136,7 @@ Firebug.CookieModule.NetInfoBody = domplate(Firebug.Rep,
     updateTabBody: function(infoBox, file, context)
     {
         var tab = infoBox.selectedTab;
-        if (tab.dataPresented || !Css.hasClass(tab, "netInfoCookiesTab"))
+        if (!tab || tab.dataPresented || !Css.hasClass(tab, "netInfoCookiesTab"))
             return;
 
         tab.dataPresented = true;
diff --git a/extension/content/firebug/net/netReps.js b/extension/content/firebug/net/netReps.js
index bc01d07..480aa0a 100644
--- a/extension/content/firebug/net/netReps.js
+++ b/extension/content/firebug/net/netReps.js
@@ -980,9 +980,13 @@ Firebug.NetMonitor.NetInfoBody = domplate(Firebug.Rep, new Firebug.Listener(),
 
     selectTabByName: function(netInfoBox, tabName)
     {
-        var tab = Dom.getChildByClass(netInfoBox, "netInfoTabs", "netInfo"+tabName+"Tab");
-        if (tab)
-            this.selectTab(tab);
+        var tab = Dom.getChildByClass(netInfoBox, "netInfoTabs", "netInfo" + tabName + "Tab");
+        if (!tab)
+            return false;
+
+        this.selectTab(tab);
+
+        return true;
     },
 
     selectTab: function(tab)
diff --git a/extension/content/firebug/net/spy.js b/extension/content/firebug/net/spy.js
index 29e36ac..121a9be 100644
--- a/extension/content/firebug/net/spy.js
+++ b/extension/content/firebug/net/spy.js
@@ -407,9 +407,11 @@ var SpyHttpObserver =
             Arr.remove(spy.context.spies, spy);
 
         if (FBTrace.DBG_SPY)
+        {
             FBTrace.sysout("spy.requestStopped: " + spy.href + ", responseTime: " +
                 spy.responseTime + "ms, spy.responseText: " +
                 (spy.reponseText ? spy.responseText.length : 0) + " bytes");
+        }
     }
 };
 
@@ -548,8 +550,10 @@ function getSpyForXHR(request, xhrRequest, context, noCreate)
         spy.attach();
 
     if (FBTrace.DBG_SPY)
+    {
         FBTrace.sysout("spy.getSpyForXHR; New spy object created (" +
             (name == origName ? "new XHR" : "redirected XHR") + ") for: " + name);
+    }
 
     return spy;
 }
@@ -721,7 +725,7 @@ function onHTTPSpyReadyStateChange(spy, event)
 
         // Update UI.
         updateLogRow(spy);
-        updateHttpSpyInfo(spy);
+        updateHttpSpyInfo(spy, true);
 
         // Notify the Net panel about a request being loaded.
         // xxxHonza: I don't think this is necessary.
@@ -759,6 +763,7 @@ function onHTTPSpyLoad(spy)
         spy.responseText = Http.safeGetXHRResponseText(spy.xhrRequest);
 
         updateLogRow(spy);
+        updateHttpSpyInfo(spy, true);
     }
 }
 
@@ -798,8 +803,10 @@ function onHTTPSpyAbort(spy)
     // xxxHonza: the net panel shoud find out this itself.
     var netProgress = spy.context.netProgress;
     if (netProgress)
+    {
         netProgress.post(netProgress.abortFile, [spy.request, spy.endTime, spy.postText,
             spy.responseText]);
+    }
 }
 
 // ********************************************************************************************* //
@@ -821,7 +828,7 @@ function callPageHandler(spy, event, originalHandler)
     catch (exc)
     {
         if (FBTrace.DBG_ERRORS)
-            FBTrace.sysout("spy.onHTTPSpyReadyStateChange: EXCEPTION "+exc, [exc, event]);
+            FBTrace.sysout("spy.onHTTPSpyReadyStateChange: EXCEPTION " + exc, [exc, event]);
 
         var xpcError = Firebug.Errors.reparseXPC(exc, spy.context);
         if (xpcError) //
@@ -918,8 +925,9 @@ Firebug.Spy.XHR = domplate(Firebug.Rep,
             if (Css.hasClass(logRow, "opened"))
             {
                 updateHttpSpyInfo(spy);
+
                 if (spyHeadTable)
-                    spyHeadTable.setAttribute('aria-expanded', 'true');
+                    spyHeadTable.setAttribute("aria-expanded", "true");
             }
             else
             {
@@ -928,7 +936,11 @@ Firebug.Spy.XHR = domplate(Firebug.Rep,
                     [netInfoBox, spy]);
 
                 if (spyHeadTable)
-                    spyHeadTable.setAttribute('aria-expanded', 'false');
+                    spyHeadTable.setAttribute("aria-expanded", "false");
+
+                // Remove the info box, it'll be re-created (together with custom tabs)
+                // the next time the XHR entry is opened/updated.
+                netInfoBox.parentNode.removeChild(netInfoBox);
             }
         }
     },
@@ -1036,7 +1048,7 @@ Firebug.Spy.XHR = domplate(Firebug.Rep,
             id: "fbSpyOpenInTab",
             command: Obj.bindFixed(this.openInTab, this, spy)
         });
-        
+
         items.push({
             label: "Open_Response_In_New_Tab",
             tooltiptext: "net.tip.Open_Response_In_New_Tab",
@@ -1108,13 +1120,13 @@ function updateLogRow(spy)
     }
 }
 
-function updateHttpSpyInfo(spy)
+function updateHttpSpyInfo(spy, updateInfoBody)
 {
     if (!spy.logRow || !Css.hasClass(spy.logRow, "opened"))
         return;
 
     if (!spy.params)
-        spy.params = Url.parseURLParams(spy.href+"");
+        spy.params = Url.parseURLParams(spy.href + "");
 
     if (!spy.requestHeaders)
         spy.requestHeaders = getRequestHeaders(spy);
@@ -1124,12 +1136,34 @@ function updateHttpSpyInfo(spy)
 
     var template = Firebug.NetMonitor.NetInfoBody;
     var netInfoBox = Dom.getChildByClass(spy.logRow, "spyHead", "netInfoBody");
+
+    var defaultTab;
+
+    // If the associated XHR row is currently expanded, make sure to recreate
+    // the info bodies if the flag says so.
+    if (updateInfoBody)
+    {
+        // Remember the current selected info tab.
+        if (netInfoBox.selectedTab)
+            defaultTab = netInfoBox.selectedTab.getAttribute("view");
+
+        // Remove the info box so, it's recreated below.
+        netInfoBox.parentNode.removeChild(netInfoBox);
+        netInfoBox = null;
+    }
+
     if (!netInfoBox)
     {
         var head = Dom.getChildByClass(spy.logRow, "spyHead");
         netInfoBox = template.tag.append({"file": spy}, head);
+
+        // Notify listeners so, custom info tabs can be appended
         Events.dispatch(template.fbListeners, "initTabBody", [netInfoBox, spy]);
-        template.selectTabByName(netInfoBox, "Response");
+
+        // If the response tab isn't available/visible (perhaps the response didn't came yet),
+        // select the 'Headers' tab by default or keep the default tab.
+        defaultTab = defaultTab || (template.hideResponse(spy) ? "Headers" : "Response");
+        template.selectTabByName(netInfoBox, defaultTab);
     }
     else
     {
@@ -1146,7 +1180,8 @@ function getRequestHeaders(spy)
     var channel = spy.xhrRequest.channel;
     if (channel instanceof Ci.nsIHttpChannel)
     {
-        channel.visitRequestHeaders({
+        channel.visitRequestHeaders(
+        {
             visitHeader: function(name, value)
             {
                 headers.push({name: name, value: value});
@@ -1166,7 +1201,8 @@ function getResponseHeaders(spy)
         var channel = spy.xhrRequest.channel;
         if (channel instanceof Ci.nsIHttpChannel)
         {
-            channel.visitResponseHeaders({
+            channel.visitResponseHeaders(
+            {
                 visitHeader: function(name, value)
                 {
                     headers.push({name: name, value: value});
@@ -1177,8 +1213,10 @@ function getResponseHeaders(spy)
     catch (exc)
     {
         if (FBTrace.DBG_SPY || FBTrace.DBG_ERRORS)
+        {
             FBTrace.sysout("spy.getResponseHeaders; EXCEPTION " +
                 Http.safeGetRequestName(spy.request), exc);
+        }
     }
 
     return headers;

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