Bug 720341 - Fix error downloading Test Pilot tests and fix the endless "Loading, please wait..." message. r=mconley,a=Standard8
authorMark Banner <bugzilla@standard8.plus.com>
Tue, 24 Jan 2012 10:06:27 +0000
changeset 10123 ba2f0d434933f3c8a6b36a973c5194b31c94c034
parent 10122 93f5b1f340bbdb8cdc26fd4355a464acefe8060e
child 10124 1ce579a2554423acaa40725c723fb891f6feeee6
push idunknown
push userunknown
push dateunknown
reviewersmconley, Standard8
bugs720341
Bug 720341 - Fix error downloading Test Pilot tests and fix the endless "Loading, please wait..." message. r=mconley,a=Standard8
mail/app/profile/extensions/tbtestpilot@labs.mozilla.com/content/all-studies-window.js
mail/app/profile/extensions/tbtestpilot@labs.mozilla.com/modules/remote-experiment-loader.js
--- a/mail/app/profile/extensions/tbtestpilot@labs.mozilla.com/content/all-studies-window.js
+++ b/mail/app/profile/extensions/tbtestpilot@labs.mozilla.com/content/all-studies-window.js
@@ -226,28 +226,17 @@ var TestPilotXulWindow = {
 
   onTakeSurveyButton: function(taskId) {
     let task = TestPilotSetup.getTaskById(taskId);
     TestPilotWindowUtils.openChromeless(task.defaultUrl);
     task.onDetailPageOpened();
   },
 
   _init: function(aReload) {
-    let experiments;
-    let ready = false;
-
-    // Are we done loading tasks?
-    if (TestPilotSetup.startupComplete) {
-      experiments = TestPilotSetup.getAllTasks();
-      if (experiments.length > 0 ) {
-        ready = true;
-      }
-    }
-
-    if (!ready) {
+    if (!TestPilotSetup.startupComplete) {
       // If you opened the window before tasks are done loading, exit now
       // but try again in a few seconds.
       window.setTimeout(
         function() { TestPilotXulWindow._init(aReload); }, 2000);
       return;
     }
 
     let numFinishedStudies = 0;
@@ -267,16 +256,17 @@ var TestPilotXulWindow = {
         let listbox = document.getElementById(listboxIds[i]);
 
         while (listbox.lastChild) {
           listbox.removeChild(listbox.lastChild);
         }
       }
     }
 
+    let experiments = TestPilotSetup.getAllTasks();
     experiments = this._sortNewestFirst(experiments);
 
     for (let i = 0; i < experiments.length; i++) {
       let task = experiments[i];
       let newRow = document.createElement("richlistitem");
       newRow.setAttribute("class", "tp-study-list");
 
       this.addThumbnail(newRow, task.thumbnail);
--- a/mail/app/profile/extensions/tbtestpilot@labs.mozilla.com/modules/remote-experiment-loader.js
+++ b/mail/app/profile/extensions/tbtestpilot@labs.mozilla.com/modules/remote-experiment-loader.js
@@ -123,17 +123,18 @@ function downloadFile(url, cb, lastModif
   if (lastModified != undefined) {
     let d = new Date();
     d.setTime(lastModified);
     // example header: If-Modified-Since: Sat, 29 Oct 1994 19:43:31 GMT
     req.setRequestHeader("If-Modified-Since", d.toGMTString());
     console.info("Setting if-modified-since header to " + d.toGMTString());
   }
   //Use binary mode to download jars TODO find a better switch
-  if (url.indexOf(".jar") == url.length - 4) {
+  if (url.indexOf(".jar") == url.length - 4 ||
+      url.indexOf(".json") == url.length - 5) {
     console.info("Using binary mode to download jar file.");
     req.overrideMimeType('text/plain; charset=x-user-defined');
   }
   req.onreadystatechange = function(aEvt) {
     if (req.readyState == 4) {
       if (req.status == 200) {
         // check security channel:
         if (verifyChannelSecurity(req.channel)) {