diff --git a/xpfe/test/winopen.js b/xpfe/test/winopen.js
--- a/xpfe/test/winopen.js
+++ b/xpfe/test/winopen.js
@@ -20,16 +20,21 @@ var CYCLES        = 1;
 
 // autoclose flag
 var AUTOCLOSE = 1;
 
 // Chrome url for child windows.
 var KID_CHROME   = null;
 var SAVED_CHROME = null;
 
+// Shark profiling (requires --enable-shark)
+// See https://developer.mozilla.org/en/Profiling_JavaScript_with_Shark
+const SHARK = true;
+var sharkStarted = false;
+
 // URL options and correspnding vars.
 const options = [ [ "phase1", "PHASE_ONE", false ],
                   [ "phase2", "PHASE_TWO", false ],
                   [ "phase3", "PHASE_THREE", false ],
                   [ "overlap", "OVERLAP_COUNT", false ],
                   [ "cycles", "CYCLES", false ],
                   [ "chrome", "KID_CHROME", true ],
                   [ "close", "AUTOCLOSE", false ] ];
@@ -96,16 +101,21 @@ function updateDisplay(index, time) {
         formIndex.setAttribute("value", index+1);
     var formTime  = document.getElementById("formTime");
     if (formTime) 
         formTime.setAttribute("value", time);
 }
 
 
 function scheduleNextWindow() {
+    if (SHARK && !sharkStarted) {
+        window.connectShark();
+        window.startShark();
+        sharkStarted = true;
+    }
     window.setTimeout(openWindow, OPENER_DELAY);
 }
 
 
 function closeOneWindow(aIndex) {
     var win = windowList[aIndex];
     // no-op if window is already closed
     if (win && !win.closed) {
@@ -164,16 +174,22 @@ function calcMedian( numbers ) {
     } else {
         numbers.sort( function (a,b){ return a-b; } );
         var n = Math.floor( numbers.length / 2 );
         return numbers.length % 2 ? numbers[n] : ( numbers[n-1] + numbers[n] ) / 2;
     }
 }
 
 function reportResults() {
+    if (sharkStarted) {
+        window.stopShark();
+        window.disconnectShark();
+        sharkStarted = false;
+    }
+
     //XXX need to create a client-side method to do this?
     var opening = openingTimes.join(':'); // times for each window open
     var closing = closingTimes.join(':'); // these are for >1 url, as a group
     //var ua = escape(navigator.userAgent).replace(/\+/g, "%2B"); // + == ' ', on servers
     //var reportURL = SERVER_URL + 
     //    "?opening="    + opening + 
     //    "&closing="    + closing + 
     //    "&maxIndex="   + MAX_INDEX + 
