bug 469855 - allow test parameter to be placed anywhere in query string.
authorBob Clary <bclary@bclary.com>
Wed, 14 Jan 2009 07:16:16 -0800
changeset 23668 364b477f377eff1403c7f9abcc69b5a6227c77e7
parent 23667 753e6b1c05c52287207514d2cb0798d3007f2007
child 23669 98e0818f1bb4003d45e1745fac9a0b09f8de65ef
push id4667
push userbclary@mozilla.com
push dateWed, 14 Jan 2009 15:24:17 +0000
treeherdermozilla-central@03d4e7eb5fcb [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
bugs469855
milestone1.9.2a1pre
bug 469855 - allow test parameter to be placed anywhere in query string.
js/tests/browser.js
--- a/js/tests/browser.js
+++ b/js/tests/browser.js
@@ -605,172 +605,153 @@ function jsTestDriverBrowserInit()
   optionsClear();
 
   if (document.location.search.indexOf('?') != 0)
   {
     // not called with a query string
     return;
   }
 
-  var re = /test=([^;]+);language=(language|type);([a-zA-Z0-9.=;\/]+)/;
-  var matches = re.exec(document.location.search);
-
-  // testpath http://machine/path-to-suite/sub-suite/test.js
-  var testpath  = matches[1];
-  var attribute = matches[2];
-  var value     = matches[3];
-
-  if (testpath)
+  var properties = {};
+  var fields = document.location.search.slice(1).split(';');
+  for (var ifield = 0; ifield < fields.length; ifield++)
   {
-    testpath = decodeURIComponent(testpath);
-    gTestPath = testpath;
-  }
-
-  var ise4x = /e4x\//.test(testpath);
-
-  var gczealmatches = /gczeal=([0-9]*)/.exec(document.location.search);
-
-  if (gczealmatches)
-  {
-    var zeal = Number(gczealmatches[1]);
-    gczeal(zeal);
+    var propertycaptures = /^([^=]+)=(.*)$/.exec(fields[ifield]);
+    if (!propertycaptures)
+    {
+      properties[fields[ifield]] = true;
+    }
+    else
+    {
+      properties[propertycaptures[1]] = decodeURIComponent(propertycaptures[2]);
+      if (propertycaptures[1] == 'language')
+      {
+        // language=(type|language);mimetype
+        properties.mimetype = fields[ifield+1];
+      }
+    }
   }
 
-/*
- * since the default setting of jit changed from false to true
- * in http://hg.mozilla.org/tracemonkey/rev/685e00e68be9
- * bisections which depend upon jit settings can be thrown off.
- * default jit(false) to make bisections depending upon jit settings
- * consistent over time. This is not needed in shell tests as the default
- * jit setting has not changed there.
- */
-
-  var jitmatches = /;jit/.exec(document.location.search);
-
-  if (jitmatches)
+  if (properties.language != 'type')
   {
-    jit(true);
-  }
-  else
-  {
-    jit(false);
+    try
+    {
+      properties.version = /javascript([.0-9]+)/.exec(properties.mimetype)[1];
+    }
+    catch(ex)
+    {
+    }
   }
 
-  var versionmatches;
-
-  if (attribute == 'type')
-  {
-    versionmatches = /version=([.0-9]+)/.exec(value);
-  }
-  else
-  {
-    versionmatches = /javascript([.0-9]+)/.exec(value);
-  }
-
-  if (versionmatches)
-  {
-    gVersion = 10*parseInt(versionmatches[1].replace(/\./g, ''));
-  }
-  else if (navigator.userAgent.indexOf('Gecko/') != -1)
+  if (!properties.version && navigator.userAgent.indexOf('Gecko/') != -1)
   {
     // If the version is not specified, and the browser is Gecko,
     // adjust the version to match the suite version.
-    if (attribute == 'type')
+    if (properties.test.match(/^js1_6/))
+    {
+      properties.version = '1.6';
+    }
+    else if (properties.test.match(/^js1_7/))
     {
-      value = 'text/javascript;version=';
+      properties.version = '1.7';
+    }
+    else if (properties.test.match(/^js1_8/))
+    {
+      properties.version = '1.8';
+    }
+    else if (properties.test.match(/^js1_8_1/))
+    {
+      properties.version = '1.8';
     }
     else
     {
-      value = 'javascript';
-    }
-
-    if (testpath.match(/^js1_6/))
-    {
-      gVersion = 160;
-      value += '1.6';
-    }
-    else if (testpath.match(/^js1_7/))
-    {
-      gVersion = 170;
-      value += '1.7';
-    }
-    else if (testpath.match(/^js1_8/))
-    {
-      gVersion = 180;
-      value += '1.8';
-    }
-    else if (testpath.match(/^js1_8_1/))
-    {
-      gVersion = 180;
-      value += '1.8';
-    }
-    else
-    {
-      gVersion = 150;
-      value += '1.5';
+      properties.version = '1.5';
     }
   }
 
-  var testpathparts = testpath.split(/\//);
+  gTestPath = properties.test;
+
+  gVersion = 10*parseInt(properties.version.replace(/\./g, ''));
+
+  if (properties.gczeal)
+  {
+    gczeal(Number(properties.gczeal));
+  }
+
+  /*
+   * since the default setting of jit changed from false to true
+   * in http://hg.mozilla.org/tracemonkey/rev/685e00e68be9
+   * bisections which depend upon jit settings can be thrown off.
+   * default jit(false) to make bisections depending upon jit settings
+   * consistent over time. This is not needed in shell tests as the default
+   * jit setting has not changed there.
+   */
+
+  jit(properties.jit);
+
+  var testpathparts = properties.test.split(/\//);
 
   if (testpathparts.length < 3)
   {
     // must have at least suitepath/subsuite/testcase.js
     return;
   }
   var suitepath = testpathparts.slice(0,testpathparts.length-2).join('/');
   var subsuite = testpathparts[testpathparts.length - 2];
   var test     = testpathparts[testpathparts.length - 1];
 
-  outputscripttag(suitepath + '/shell.js', attribute, value,
-                  ise4x);
-  outputscripttag(suitepath + '/browser.js', attribute, value,
-                  ise4x);
-  outputscripttag(suitepath + '/' + subsuite + '/shell.js', attribute, value,
-                  ise4x);
-  outputscripttag(suitepath + '/' + subsuite + '/browser.js', attribute, value,
-                  ise4x);
-  outputscripttag(suitepath + '/' + subsuite + '/' + test, attribute, value,
-                  ise4x);
+  outputscripttag(suitepath + '/shell.js', properties);
+  outputscripttag(suitepath + '/browser.js', properties);
+  outputscripttag(suitepath + '/' + subsuite + '/shell.js', properties);
+  outputscripttag(suitepath + '/' + subsuite + '/browser.js', properties);
+  outputscripttag(suitepath + '/' + subsuite + '/' + test, properties,
+  	properties.e4x || /e4x\//.test(properties.test));
 
-  document.write('<title>' + suitepath + '/' + subsuite + '/' + test +
-                 '<\/title>');
+  document.write('<title>' + suitepath + '/' + subsuite + '/' + test + '<\/title>');
 
-  outputscripttag('js-test-driver-end.js', attribute, value,
-                  false);
+  outputscripttag('js-test-driver-end.js', properties);
   return;
 }
 
-function outputscripttag(src, attribute, value, ise4x)
+function outputscripttag(src, properties, e4x)
 {
   if (!src)
   {
     return;
   }
 
+  if (e4x)
+  {
+    // e4x requires type=mimetype;e4x=1
+    properties.language = 'type';
+  }
+
   var s = '<script src="' +  src + '" ';
 
-  if (ise4x)
+  if (properties.language != 'type')
   {
-    if (attribute == 'type')
+    s += 'language="javascript';
+    if (properties.version)
     {
-      value += ';e4x=1 ';
-    }
-    else
-    {
-      s += ' type="text/javascript';
-      if (gVersion != 150)
-      {
-        s += ';version=' + gVersion/100;
-      }
-      s += ';e4x=1" ';
+      s += properties.version;
     }
   }
-
-  s +=  attribute + '="' + value + '"><\/script>';
+  else
+  {
+    s += 'type="' + properties.mimetype;
+    if (properties.version)
+    {
+      s += ';version=' + properties.version;
+    }
+    if (e4x)
+    {
+      s += ';e4x=1';
+    }
+  }
+  s += '"><\/script>';
 
   document.write(s);
 }
 
 function jsTestDriverEnd()
 {
   // gDelayTestDriverEnd is used to
   // delay collection of the test result and