Bug 827050 - Clear cookies and stored data in the browser clears remember my choice permissions for PROMPT_ACTION WebAPIs, r=mounir
☠☠ backed out by 76100f3a59f0 ☠ ☠
authorAndrea Marchesini <amarchesini@mozilla.com>
Mon, 07 Jan 2013 18:37:01 +0100
changeset 118317 fef358e6d5e6b66dca672b0a12ac506d8624fc84
parent 118316 313ee823a942144e7440f6c98a722f982fbb8064
child 118326 54313af58e7fde38fba5a53ddc468c4d646e3135
push id270
push userpvanderbeken@mozilla.com
push dateThu, 06 Mar 2014 09:24:21 +0000
reviewersmounir
bugs827050
milestone20.0a1
Bug 827050 - Clear cookies and stored data in the browser clears remember my choice permissions for PROMPT_ACTION WebAPIs, r=mounir
dom/apps/src/Webapps.jsm
extensions/cookie/nsPermissionManager.cpp
extensions/cookie/nsPermissionManager.h
extensions/cookie/test/Makefile.in
extensions/cookie/test/frame_clear_browser_data.html
extensions/cookie/test/test_app_cleardata_permissions.html
layout/build/nsLayoutStatics.cpp
netwerk/base/public/nsIPermissionManager.idl
netwerk/test/unit/test_auth_jar.js
netwerk/test/unit/test_cache_jar.js
--- a/dom/apps/src/Webapps.jsm
+++ b/dom/apps/src/Webapps.jsm
@@ -309,17 +309,17 @@ this.DOMApplicationRegistry = {
         for (let id in this.webapps) {
           if (id in aData || this.webapps[id].removable)
             continue;
           delete this.webapps[id];
           // Remove the permissions, cookies and private data for this app.
           let localId = this.webapps[id].localId;
           let permMgr = Cc["@mozilla.org/permissionmanager;1"]
                           .getService(Ci.nsIPermissionManager);
-          permMgr.RemovePermissionsForApp(localId);
+          permMgr.RemovePermissionsForApp(localId, false);
           Services.cookies.removeCookiesForApp(localId, false);
           this._clearPrivateData(localId, false);
         }
 
         let appDir = FileUtils.getDir("coreAppsDir", ["webapps"], false);
         // c
         for (let id in aData) {
           // Core apps have ids matching their domain name (eg: dialer.gaiamobile.org)
--- a/extensions/cookie/nsPermissionManager.cpp
+++ b/extensions/cookie/nsPermissionManager.cpp
@@ -121,42 +121,47 @@ GetHostForPrincipal(nsIPrincipal* aPrinc
   rv = uri->GetAsciiHost(aHost);
   if (NS_FAILED(rv) || aHost.IsEmpty()) {
     return NS_ERROR_UNEXPECTED;
   }
 
   return NS_OK;
 }
 
-class AppUninstallObserver MOZ_FINAL : public nsIObserver {
+class AppClearDataObserver MOZ_FINAL : public nsIObserver {
 public:
   NS_DECL_ISUPPORTS
 
   // nsIObserver implementation.
   NS_IMETHODIMP
   Observe(nsISupports *aSubject, const char *aTopic, const PRUnichar *data)
   {
-    MOZ_ASSERT(!nsCRT::strcmp(aTopic, "webapps-uninstall"));
+    MOZ_ASSERT(!nsCRT::strcmp(aTopic, "webapps-clear-data"));
 
-    nsCOMPtr<nsIAppsService> appsService = do_GetService("@mozilla.org/AppsService;1");
-    nsCOMPtr<mozIApplication> app;
-
-    appsService->GetAppFromObserverMessage(nsAutoString(data), getter_AddRefs(app));
-    NS_ENSURE_TRUE(app, NS_ERROR_UNEXPECTED);
+    nsCOMPtr<mozIApplicationClearPrivateDataParams> params =
+      do_QueryInterface(aSubject);
+    if (!params) {
+      NS_ERROR("'webapps-clear-data' notification's subject should be a mozIApplicationClearPrivateDataParams");
+      return NS_ERROR_UNEXPECTED;
+    }
 
     uint32_t appId;
-    app->GetLocalId(&appId);
-    MOZ_ASSERT(appId != nsIScriptSecurityManager::NO_APP_ID);
+    nsresult rv = params->GetAppId(&appId);
+    NS_ENSURE_SUCCESS(rv, rv);
+
+    bool browserOnly;
+    rv = params->GetBrowserOnly(&browserOnly);
+    NS_ENSURE_SUCCESS(rv, rv);
 
     nsCOMPtr<nsIPermissionManager> permManager = do_GetService("@mozilla.org/permissionmanager;1");
-    return permManager->RemovePermissionsForApp(appId);
+    return permManager->RemovePermissionsForApp(appId, browserOnly);
   }
 };
 
-NS_IMPL_ISUPPORTS1(AppUninstallObserver, nsIObserver)
+NS_IMPL_ISUPPORTS1(AppClearDataObserver, nsIObserver)
 
 } // anonymous namespace
 
 ////////////////////////////////////////////////////////////////////////////////
 
 nsPermissionManager::PermissionKey::PermissionKey(nsIPrincipal* aPrincipal)
 {
   MOZ_ALWAYS_TRUE(NS_SUCCEEDED(GetHostForPrincipal(aPrincipal, mHost)));
@@ -266,20 +271,20 @@ NS_IMETHODIMP DeleteFromMozHostListener:
   if (aReason == REASON_ERROR) {
     manager->CloseDB(true);
   }
 
   return NS_OK;
 }
 
 /* static */ void
-nsPermissionManager::AppUninstallObserverInit()
+nsPermissionManager::AppClearDataObserverInit()
 {
   nsCOMPtr<nsIObserverService> observerService = do_GetService("@mozilla.org/observer-service;1");
-  observerService->AddObserver(new AppUninstallObserver(), "webapps-uninstall", /* holdsWeak= */ false);
+  observerService->AddObserver(new AppClearDataObserver(), "webapps-clear-data", /* holdsWeak= */ false);
 }
 
 ////////////////////////////////////////////////////////////////////////////////
 // nsPermissionManager Implementation
 
 static const char kPermissionsFileName[] = "permissions.sqlite";
 #define HOSTS_SCHEMA_VERSION 3
 
@@ -1151,33 +1156,37 @@ nsPermissionManager::GetPermissionsForAp
                                                     permEntry.mExpireType,
                                                     permEntry.mExpireTime));
   }
 
   return PL_DHASH_NEXT;
 }
 
 NS_IMETHODIMP
-nsPermissionManager::RemovePermissionsForApp(uint32_t aAppId)
+nsPermissionManager::RemovePermissionsForApp(uint32_t aAppId, bool aBrowserOnly)
 {
   ENSURE_NOT_CHILD_PROCESS;
   NS_ENSURE_ARG(aAppId != nsIScriptSecurityManager::NO_APP_ID);
 
   // We begin by removing all the permissions from the DB.
   // After clearing the DB, we call AddInternal() to make sure that all
   // processes are aware of this change and the representation of the DB in
   // memory is updated.
   // We have to get all permissions associated with an application and then
   // remove those because doing so in EnumerateEntries() would fail because
   // we might happen to actually delete entries from the list.
 
   nsAutoCString sql;
   sql.AppendLiteral("DELETE FROM moz_hosts WHERE appId=");
   sql.AppendInt(aAppId);
 
+  if (aBrowserOnly) {
+    sql.AppendLiteral(" AND isInBrowserElement=1");
+  }
+
   nsCOMPtr<mozIStorageAsyncStatement> removeStmt;
   nsresult rv = mDBConn->CreateAsyncStatement(sql, getter_AddRefs(removeStmt));
   NS_ENSURE_SUCCESS(rv, rv);
 
   nsCOMPtr<mozIStoragePendingStatement> pending;
   rv = removeStmt->ExecuteAsync(nullptr, getter_AddRefs(pending));
   NS_ENSURE_SUCCESS(rv, rv);
 
--- a/extensions/cookie/nsPermissionManager.h
+++ b/extensions/cookie/nsPermissionManager.h
@@ -195,17 +195,17 @@ public:
                        DBOperationType aDBOperation);
 
   /**
    * Initialize the "webapp-uninstall" observing.
    * Will create a nsPermissionManager instance if needed.
    * That way, we can prevent have nsPermissionManager created at startup just
    * to be able to clear data when an application is uninstalled.
    */
-  static void AppUninstallObserverInit();
+  static void AppClearDataObserverInit();
 
 private:
   int32_t GetTypeIndex(const char *aTypeString,
                        bool        aAdd);
 
   PermissionHashKey* GetPermissionHashKey(const nsACString& aHost,
                                           uint32_t aAppId,
                                           bool aIsInBrowserElement,
--- a/extensions/cookie/test/Makefile.in
+++ b/extensions/cookie/test/Makefile.in
@@ -49,18 +49,20 @@ MOCHITEST_FILES = \
   file_localhost_inner.html \
   test_same_base_domain_5.html \
   test_same_base_domain_6.html \
   file_loopback_inner.html \
   $(NULL)
 
 MOCHITEST_CHROME_FILES = \
   test_permissionmanager_app_isolation.html \
+  test_app_cleardata_permissions.html \
   test_app_uninstall_permissions.html \
   test_app_uninstall_cookies.html \
+  frame_clear_browser_data.html \
   channel_utils.js \
   $(NULL)
 
 MOCHITEST_BROWSER_FILES = \
   browser_test_favicon.js \
   $(NULL)
 
 XPCSHELL_TESTS = unit
copy from dom/tests/mochitest/localstorage/frame_clear_browser_data.html
copy to extensions/cookie/test/frame_clear_browser_data.html
copy from extensions/cookie/test/test_app_uninstall_permissions.html
copy to extensions/cookie/test/test_app_cleardata_permissions.html
--- a/extensions/cookie/test/test_app_uninstall_permissions.html
+++ b/extensions/cookie/test/test_app_cleardata_permissions.html
@@ -1,44 +1,47 @@
 <!DOCTYPE HTML>
 <html>
-<!--
-https://bugzilla.mozilla.org/show_bug.cgi?id=786296
--->
 <head>
   <meta charset="utf-8">
-  <title>Tests that uninstalling app removes the permissions</title>
+  <title>Tests that clearing mozbrowser private data removes the onlyInBrowser permissions</title>
   <script type="application/javascript" src="chrome://mochikit/content/tests/SimpleTest/SimpleTest.js"></script>
   <link rel="stylesheet" type="text/css" href="chrome://mochikit/content/tests/SimpleTest/test.css"?>
 </head>
 <body>
-<a target="_blank" href="https://bugzilla.mozilla.org/show_bug.cgi?id=786296">Mozilla Bug 786296</a>
 <p id="display"></p>
 <div id="content">
-  
+  <iframe src="http://example.com/tests/error404"></iframe>
 </div>
 <pre id="test">
 <script type="application/javascript;version=1.7">
 
-/** Test for Bug 786296 **/
-
-var Ci = Components.interfaces;
-var Cc = Components.classes;
+const Ci = Components.interfaces;
+const Cc = Components.classes;
+const Cu = Components.utils;
 
 SimpleTest.waitForExplicitFinish();
 
 var permManager = Cc["@mozilla.org/permissionmanager;1"]
                     .getService(Ci.nsIPermissionManager);
 var appsService = Cc['@mozilla.org/AppsService;1']
                     .getService(Ci.nsIAppsService);
 var secMan = Cc['@mozilla.org/scriptsecuritymanager;1']
                .getService(Ci.nsIScriptSecurityManager);
 var ioService = Cc["@mozilla.org/network/io-service;1"]
                   .getService(Components.interfaces.nsIIOService);
 
+var Webapps = {};
+Cu.import("resource://gre/modules/Webapps.jsm", Webapps);
+
+/**
+ * This function will make sure that the next applications we try to install
+ * will be installed. That means it will behave like if the user allowed the app
+ * to be installed in the door hanger.
+ */
 function confirmNextInstall() {
   var panel = window.top.QueryInterface(Ci.nsIInterfaceRequestor)
                         .getInterface(Ci.nsIWebNavigation)
                         .QueryInterface(Ci.nsIDocShell)
                         .chromeEventHandler.ownerDocument.defaultView
                         .PopupNotifications.panel
 
   panel.addEventListener("popupshown", function() {
@@ -58,72 +61,153 @@ function getPermissionCountForApp(aAppId
     if (permission.appId == aAppId || aAppId == -1) {
       nbPermissions++;
     }
   }
 
   return nbPermissions;
 }
 
-var previousDryRunValue = null;
-try {
-  previousDryRunValue = SpecialPowers.getBoolPref('browser.mozApps.installer.dry_run');
-} catch(e) {
-}
-
-SpecialPowers.setBoolPref('browser.mozApps.installer.dry_run', true);
 permManager.addFromPrincipal(window.document.nodePrincipal, "webapps-manage",
                              Ci.nsIPermissionManager.ALLOW_ACTION);
+permManager.addFromPrincipal(window.document.nodePrincipal, "browser",
+                             Ci.nsIPermissionManager.ALLOW_ACTION);
 
-var gManifestURL = "http://www.example.com:80/chrome/dom/tests/mochitest/webapps/apps/basic.webapp";
+var previousPrefs = {
+  mozBrowserFramesEnabled: null,
+  installerDryRun: null,
+};
 
-confirmNextInstall();
+// Save the prefs we want to change (so we can re-set them later) and set them
+// to the needed value.
+try {
+  previousPrefs.mozBrowserFramesEnabled = SpecialPowers.getBoolPref('dom.mozBrowserFramesEnabled');
+} catch(e)
+{
+}
+SpecialPowers.setBoolPref('dom.mozBrowserFramesEnabled', true);
 
-navigator.mozApps.install(gManifestURL, null).onsuccess = function() {
-  var testAppId = appsService.getAppLocalIdByManifestURL(gManifestURL);
+try {
+  previousPrefs.installerDryRun = SpecialPowers.getBoolPref('browser.mozApps.installer.dry_run');
+} catch(e) {
+}
+SpecialPowers.setBoolPref('browser.mozApps.installer.dry_run', true);
+
+// We want to simulate that all apps are launchable, for testing purpose.
+var gPreviousLaunchableValue = Webapps.DOMApplicationRegistry.allAppsLaunchable;
+Webapps.DOMApplicationRegistry.allAppsLaunchable = true;
 
-  is(getPermissionCountForApp(testAppId), 0, "App should have no permission");
+// URL of the manifest of the app we want to install.
+const gManifestURL = "http://www.example.com:80/chrome/dom/tests/mochitest/webapps/apps/basic.webapp";
+// ID of the installed app.
+var gTestAppId = 0;
+
+addLoadEvent(function() {
+  confirmNextInstall();
+
+  navigator.mozApps.install(gManifestURL, null).onsuccess = function() {
+    gTestAppId = appsService.getAppLocalIdByManifestURL(gManifestURL);
+
+    is(getPermissionCountForApp(gTestAppId), 0, "App should have no permission");
 
-  var currentPermissionCount = getPermissionCountForApp(-1);
+    var currentPermissionCount = getPermissionCountForApp(-1);
+
+    var principal = secMan.getAppCodebasePrincipal(ioService.newURI("http://www.example.com", null, null),
+                                                   gTestAppId, true);
 
-  var principal = secMan.getAppCodebasePrincipal(ioService.newURI("http://www.example.com", null, null),
-                                                 testAppId, false);
+    permManager.addFromPrincipal(principal, "foobar", Ci.nsIPermissionManager.ALLOW_ACTION);
+    permManager.addFromPrincipal(principal, "foo", Ci.nsIPermissionManager.DENY_ACTION);
+    permManager.addFromPrincipal(principal, "bar", Ci.nsIPermissionManager.ALLOW_ACTION, Ci.nsIPermissionManager.EXPIRE_SESSION, 0);
+
+    principal = secMan.getAppCodebasePrincipal(ioService.newURI("http://www.example.org", null, null),
+                                               gTestAppId, true);
+    permManager.addFromPrincipal(principal, "foobar", Ci.nsIPermissionManager.ALLOW_ACTION);
+
+    is(getPermissionCountForApp(gTestAppId), 4, "App should have 4 permissions");
 
-  permManager.addFromPrincipal(principal, "foobar", Ci.nsIPermissionManager.ALLOW_ACTION);
-  permManager.addFromPrincipal(principal, "foo", Ci.nsIPermissionManager.DENY_ACTION);
-  permManager.addFromPrincipal(principal, "bar", Ci.nsIPermissionManager.ALLOW_ACTION, Ci.nsIPermissionManager.EXPIRE_SESSION, 0);
+    var frame = document.createElement('iframe');
+    frame.setAttribute('mozbrowser', '');
+    frame.setAttribute('mozapp', gManifestURL);
+    frame.src = 'http://www.example.com/chrome/extensions/cookie/test/frame_clear_browser_data.html';
+    frame.name = 'app';
+
+    frame.addEventListener('load', appFrameLoadEvent);
+
+    document.body.appendChild(frame);
+  };
+});
 
-  principal = secMan.getAppCodebasePrincipal(ioService.newURI("http://www.example.com", null, null),
-                                             testAppId, true);
-  permManager.addFromPrincipal(principal, "foobar", Ci.nsIPermissionManager.ALLOW_ACTION);
+function appFrameLoadEvent() {
+  /*
+   * The app frame has been loaded. We can now add permissions for the app to
+   * create browsers and we will load a page in this browser and wait for the
+   * load event.
+   */
+  permManager.addFromPrincipal(window.frames[1].document.nodePrincipal, "browser",
+                               Ci.nsIPermissionManager.ALLOW_ACTION);
+
+  var frame = document.createElement('iframe');
+  frame.setAttribute('mozbrowser', '');
+  frame.src = 'http://example.com/tests/error404_2';
 
-  principal = secMan.getAppCodebasePrincipal(ioService.newURI("http://www.example.org", null, null),
-                                             testAppId, false);
-  permManager.addFromPrincipal(principal, "foobar", Ci.nsIPermissionManager.ALLOW_ACTION);
+  frame.addEventListener('load', browserLoadEvent);
+
+  document.getElementsByName('app')[0].contentDocument.body.appendChild(frame);
+}
+
+function browserLoadEvent() {
+  /*
+   * The browser inside the app has loaded.
+   */
+
+  frames[1].postMessage("clear", "http://www.example.com");
 
-  is(getPermissionCountForApp(testAppId), 5, "App should have 5 permissions");
+  waitForClearBrowserData();
+};
 
-  // Not installed means not installed as native app.
-  navigator.mozApps.mgmt.getNotInstalled().onsuccess = function() {
+function waitForClearBrowserData() {
+  SimpleTest.executeSoon(function() {
+    if (frames[1].document.getElementsByTagName('done').length == 0) {
+      waitForClearBrowserData();
+    } else {
+      checks();
+    }
+  });
+}
+function checks() {
+  navigator.mozApps.mgmt.getAll().onsuccess = function() {
     for (i in this.result) {
       var app = this.result[i];
       if (app.manifestURL == gManifestURL) {
-        app.uninstall().onsuccess = function() {
-          is(getPermissionCountForApp(testAppId), 0, "App should have no permissions");
+        is(getPermissionCountForApp(gTestAppId), 0, "App should have 0 permissions");
 
-          is(getPermissionCountForApp(-1), currentPermissionCount,
-             "Number of permissions should not have changed");
+        Webapps.DOMApplicationRegistry.allAppsLaunchable = gPreviousLaunchableValue;
 
-          SpecialPowers.setBoolPref('browser.mozApps.installer.dry_run', previousDryRunValue);
-          permManager.removeFromPrincipal(window.document.nodePrincipal, "webapps-manage",
-                                       Ci.nsIPermissionManager.ALLOW_ACTION);
-          SimpleTest.finish();
-          return;
+        // Now we uninstall the app and make sure everything is clean.
+        app.uninstall().onsuccess = function() {
+          is(getPermissionCountForApp(gTestAppId), 0, "App should have 0 permissions");
+          finish();
         };
       }
     }
   };
-};
+}
+
+/**
+ * This method will be called when the test will be done. It is going to clear
+ * all storage data, permissions, etc.
+ */
+function finish() {
+  permManager.removeFromPrincipal(window.document.nodePrincipal, "webapps-manage",
+                                  Ci.nsIPermissionManager.ALLOW_ACTION);
+  permManager.removeFromPrincipal(window.document.nodePrincipal, "browser",
+                                  Ci.nsIPermissionManager.ALLOW_ACTION);
+
+  SpecialPowers.setBoolPref('dom.mozBrowserFramesEnabled', previousPrefs.mozBrowserFramesEnabled);
+  SpecialPowers.setBoolPref('browser.mozApps.installer.dry_run', previousPrefs.installerDryRun);
+
+  SimpleTest.finish();
+}
 
 </script>
 </pre>
 </body>
 </html>
--- a/layout/build/nsLayoutStatics.cpp
+++ b/layout/build/nsLayoutStatics.cpp
@@ -260,17 +260,17 @@ nsLayoutStatics::Initialize()
   NS_SealStaticAtomTable();
 
   nsWindowMemoryReporter::Init();
 
   nsSVGUtils::Init();
 
   InitProcessPriorityManager();
 
-  nsPermissionManager::AppUninstallObserverInit();
+  nsPermissionManager::AppClearDataObserverInit();
   nsCookieService::AppClearDataObserverInit();
   nsApplicationCacheService::AppClearDataObserverInit();
 
   nsDOMStorageBaseDB::Init();
 
   InitializeDateCacheCleaner();
 
   return NS_OK;
--- a/netwerk/base/public/nsIPermissionManager.idl
+++ b/netwerk/base/public/nsIPermissionManager.idl
@@ -31,17 +31,17 @@
 #include "nsISupports.idl"
 #include "nsISimpleEnumerator.idl"
 
 interface nsIURI;
 interface nsIObserver;
 interface nsIPrincipal;
 interface nsIDOMWindow;
 
-[scriptable, uuid(6c68cd87-4569-4695-8bc8-ad609f624b96)]
+[scriptable, uuid(9b6ffbb9-5536-4216-afcf-1b7cd7b54005)]
 interface nsIPermissionManager : nsISupports
 {
   /**
    * Predefined return values for the testPermission method and for
    * the permission param of the add method
    * NOTE: UNKNOWN_ACTION (0) is reserved to represent the
    * default permission when no entry is found for a host, and
    * should not be used by consumers to indicate otherwise.
@@ -187,17 +187,21 @@ interface nsIPermissionManager : nsISupp
    * Allows enumeration of all stored permissions
    * @return an nsISimpleEnumerator interface that allows access to
    *         nsIPermission objects
    */
   readonly attribute nsISimpleEnumerator enumerator;
 
   /**
    * Remove all permissions associated with a given app id.
+   * @param aAppId       The appId of the app
+   * @param aBrowserOnly Whether we should remove permissions associated with
+   *                     a browser element (true) or all permissions (false).
    */
-  void removePermissionsForApp(in unsigned long appId);
+  void removePermissionsForApp(in unsigned long appId,
+                               in boolean browserOnly);
 };
 
 %{ C++
 #define NS_PERMISSIONMANAGER_CONTRACTID "@mozilla.org/permissionmanager;1"
 
 #define PERM_CHANGE_NOTIFICATION "perm-changed"
 %}
--- a/netwerk/test/unit/test_auth_jar.js
+++ b/netwerk/test/unit/test_auth_jar.js
@@ -5,16 +5,19 @@ Components.utils.import("resource://gre/
 
 function createURI(s) {
   let service = Components.classes["@mozilla.org/network/io-service;1"]
                 .getService(Components.interfaces.nsIIOService);
   return service.newURI(s, null, null);
 }
  
 function run_test() {
+  // Set up a profile.
+  do_get_profile();
+
   var secMan = Cc["@mozilla.org/scriptsecuritymanager;1"].getService(Ci.nsIScriptSecurityManager);
   const kURI1 = "http://example.com";
   var app1 = secMan.getAppCodebasePrincipal(createURI(kURI1), 1, false);
   var app10 = secMan.getAppCodebasePrincipal(createURI(kURI1), 10, false);
   var app1browser = secMan.getAppCodebasePrincipal(createURI(kURI1), 1, true);
 
   var am = Cc["@mozilla.org/network/http-auth-manager;1"].
            getService(Ci.nsIHttpAuthManager);
@@ -44,9 +47,9 @@ function run_test() {
   do_check_eq(user.value, "user");
   do_check_eq(pass.value, "pass");
 
 
   am.getAuthIdentity("http", "a.example.com", -1, "basic", "realm", "", domain, user, pass, false, app10);
   do_check_eq(domain.value, "example.com");
   do_check_eq(user.value, "user2");
   do_check_eq(pass.value, "pass2");
-}
\ No newline at end of file
+}
--- a/netwerk/test/unit/test_cache_jar.js
+++ b/netwerk/test/unit/test_cache_jar.js
@@ -79,16 +79,17 @@ function run_all_tests() {
     var chan = makeChan("http://localhost:4444/cached", test[0], test[1]);
     chan.asyncOpen(new ChannelListener(doneFirstLoad, test[2]), null);
     yield;
   }
 }
 
 let gTests;
 function run_test() {
+  do_get_profile();
   do_test_pending();
   httpserv = new HttpServer();
   httpserv.registerPathHandler("/cached", cached_handler);
   httpserv.start(4444);
   gTests = run_all_tests();
   gTests.next();
 }
 
@@ -100,9 +101,9 @@ function doneFirstLoad(req, buffer, expe
 
 function doneSecondLoad(req, buffer, expected) {
   do_check_eq(handlers_called, expected);
   try {
     gTests.next();
   } catch (x) {
     do_test_finished();
   }
-}
\ No newline at end of file
+}