bug 428645 QAC hang fix - r=jay
authorctalbert@mozilla.com
Thu, 17 Apr 2008 05:00:48 -0700
changeset 14420 c8164be42671c8ee8160c218147da219c507253f
parent 14419 8822304e916cca09b6d3688249314c99a671d72c
child 14421 c961bb6dbbe9227c99fce0fbb7904d94d797cca5
push id14
push userbsmedberg@mozilla.com
push dateTue, 29 Apr 2008 14:30:10 +0000
treeherdermozilla-central@78e482f2d4be [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersjay
bugs428645
milestone1.9pre
bug 428645 QAC hang fix - r=jay
testing/extensions/community/chrome/content/tabs/bugAccess.js
--- a/testing/extensions/community/chrome/content/tabs/bugAccess.js
+++ b/testing/extensions/community/chrome/content/tabs/bugAccess.js
@@ -47,17 +47,16 @@
 function bugAccess()
 {
   var onloadBugList;
   var onloadBugSpecs;
   var onloadBugSearch;
   var onloadBugSave;
   var onloadLogin;
 
-
   this.getBugSpecs = function(inputId,inUrl,onloadFunc)
   {
     if(onloadFunc!=undefined)
     {
       onloadBugSpecs = onloadFunc;
     }else
       alert("ERROR: getBugList called without function parameter");
     var url = inUrl+"show_bug.cgi?ctype=xml&id=";
@@ -133,17 +132,17 @@ function bugAccess()
     // leave true for Gecko
     xmlHttp.send(null);
     if(mode == 1)//list mode
       xmlHttp.onload=this.parseBugList;
     else if(mode == 0)//search mode
       xmlHttp.onload=this.parseBugSearch;
   }
 
-
+  
   this.parseBugList = function(e)
   {
     var bugData = parseList(e.target.responseText);
     onloadBugList(bugData);
   }
 
   this.parseBugSearch = function(e)
   {
@@ -288,16 +287,33 @@ function bugAccess()
   {
   var beginLoc=0;
   var endLoc=0;
   var id;
   var summary;
 
   bugData=new Array();
   //dump(xmlHttp);
+  // Ideally, we'd load the contents of xmlHttp into a document node and do
+  // XPATH queries to get these rather than this brute force parsing, but there
+  // isn't a very clean way to load text/HTML into a document (bug 102699).
+  // So, for now, be sure that we are beginning in the right part of the page,
+  // And not catching bugzilla maintenance bug references in the header it.
+  // So we look for the bugs table, i.e. this line: 
+  // <table class="bz_buglist sortable" ...> We set that to our end, so that
+  // the beginLoc is set properly the first time through the loop.
+  endLoc = xmlHttp.search(/<table class=\"bz_buglist sortable\"/);
+  if (endLoc <= 0) {
+    // You should never see this, but if you do, then that means the format
+    // of the bugzilla page has changed and we want to return rather than go
+    // into an infinite loop.
+    alert("ERROR: No Bugs Found.");
+    return bugData;
+  }
+
   for(var i = 0;(beginLoc = xmlHttp.indexOf('show_bug.cgi?id',endLoc)) != -1; i++)
   {
     endLoc = xmlHttp.indexOf('"',beginLoc);
     beginLoc = xmlHttp.indexOf('=',beginLoc);
 
     id=xmlHttp.substring(beginLoc+1, endLoc);