Bug 774585: Fix browser code and tests to be aware of app principals. r=mounir
authorJonas Sicking <jonas@sicking.cc>
Sat, 21 Jul 2012 00:29:40 -0700
changeset 100030 c3972de3f4a56b467a31a843a3be7c3670de25a0
parent 100029 224e9f2148b217f5657ec4c17570cf167679d681
child 100031 2328647c5d6dd4135a62c1bb98b3e4d233e1d0d2
push id23162
push userryanvm@gmail.com
push dateSat, 21 Jul 2012 21:38:42 +0000
treeherdermozilla-central@defbe00ca091 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersmounir
bugs774585
milestone17.0a1
first release with
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
last release without
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
Bug 774585: Fix browser code and tests to be aware of app principals. r=mounir
browser/base/content/test/browser_aboutHome.js
browser/base/content/test/browser_sanitizeDialog.js
browser/base/content/test/newtab/head.js
browser/components/nsBrowserContentHandler.js
browser/components/privatebrowsing/test/unit/do_test_removeDataFromDomain.js
browser/modules/NewTabUtils.jsm
dom/tests/mochitest/localstorage/test_localStorageFromChrome.xhtml
dom/tests/unit/test_domstorage_aboutpages.js
--- a/browser/base/content/test/browser_aboutHome.js
+++ b/browser/base/content/test/browser_aboutHome.js
@@ -159,13 +159,13 @@ function runNextTest()
   }
 }
 
 function getStorage()
 {
   let aboutHomeURI = Services.io.newURI("moz-safe-about:home", null, null);
   let principal = Components.classes["@mozilla.org/scriptsecuritymanager;1"].
                   getService(Components.interfaces.nsIScriptSecurityManager).
-                  getCodebasePrincipal(Services.io.newURI("about:home", null, null));
+                  getNoAppCodebasePrincipal(Services.io.newURI("about:home", null, null));
   let dsm = Components.classes["@mozilla.org/dom/storagemanager;1"].
             getService(Components.interfaces.nsIDOMStorageManager);
   return dsm.getLocalStorageForPrincipal(principal, "");
 };
--- a/browser/base/content/test/browser_sanitizeDialog.js
+++ b/browser/base/content/test/browser_sanitizeDialog.js
@@ -441,17 +441,17 @@ var gAllTests = [
     var URL = "http://www.example.com";
 
     var ios = Cc["@mozilla.org/network/io-service;1"]
               .getService(Ci.nsIIOService);
     var URI = ios.newURI(URL, null, null);
 
     var sm = Cc["@mozilla.org/scriptsecuritymanager;1"]
              .getService(Ci.nsIScriptSecurityManager);
-    var principal = sm.getCodebasePrincipal(URI);
+    var principal = sm.getNoAppCodebasePrincipal(URI);
 
     // Give www.example.com privileges to store offline data
     var pm = Cc["@mozilla.org/permissionmanager;1"]
              .getService(Ci.nsIPermissionManager);
     pm.add(URI, "offline-app", Ci.nsIPermissionManager.ALLOW_ACTION);
     pm.add(URI, "offline-app", Ci.nsIOfflineCacheUpdateService.ALLOW_NO_WARN);
 
     // Store some user data to localStorage
--- a/browser/base/content/test/newtab/head.js
+++ b/browser/base/content/test/newtab/head.js
@@ -9,17 +9,17 @@ let tmp = {};
 Cu.import("resource:///modules/NewTabUtils.jsm", tmp);
 Cc["@mozilla.org/moz/jssubscript-loader;1"]
   .getService(Ci.mozIJSSubScriptLoader)
   .loadSubScript("chrome://browser/content/sanitize.js", tmp);
 
 let {NewTabUtils, Sanitizer} = tmp;
 
 let uri = Services.io.newURI("about:newtab", null, null);
-let principal = Services.scriptSecurityManager.getCodebasePrincipal(uri);
+let principal = Services.scriptSecurityManager.getNoAppCodebasePrincipal(uri);
 
 let sm = Services.domStorageManager;
 let storage = sm.getLocalStorageForPrincipal(principal, "");
 
 registerCleanupFunction(function () {
   while (gBrowser.tabs.length > 1)
     gBrowser.removeTab(gBrowser.tabs[1]);
 
--- a/browser/components/nsBrowserContentHandler.js
+++ b/browser/components/nsBrowserContentHandler.js
@@ -836,17 +836,17 @@ nsDefaultCommandLineHandler.prototype = 
 };
 
 let AboutHomeUtils = {
   SNIPPETS_URL_PREF: "browser.aboutHomeSnippets.updateUrl",
   get _storage() {
     let aboutHomeURI = Services.io.newURI("moz-safe-about:home", null, null);
     let principal = Components.classes["@mozilla.org/scriptsecuritymanager;1"].
                     getService(Components.interfaces.nsIScriptSecurityManager).
-                    getCodebasePrincipal(aboutHomeURI);
+                    getNoAppCodebasePrincipal(aboutHomeURI);
     let dsm = Components.classes["@mozilla.org/dom/storagemanager;1"].
               getService(Components.interfaces.nsIDOMStorageManager);
     return dsm.getLocalStorageForPrincipal(principal, "");
   },
 
   loadDefaultSearchEngine: function AHU_loadDefaultSearchEngine()
   {
     let defaultEngine = Services.search.originalDefaultEngine;
--- a/browser/components/privatebrowsing/test/unit/do_test_removeDataFromDomain.js
+++ b/browser/components/privatebrowsing/test/unit/do_test_removeDataFromDomain.js
@@ -538,17 +538,17 @@ function test_cache_cleared()
 }
 
 function test_storage_cleared()
 {
   function getStorageForURI(aURI)
   {
     let principal = Cc["@mozilla.org/scriptsecuritymanager;1"].
                     getService(Ci.nsIScriptSecurityManager).
-                    getCodebasePrincipal(aURI);
+                    getNoAppCodebasePrincipal(aURI);
     let dsm = Cc["@mozilla.org/dom/storagemanager;1"].
               getService(Ci.nsIDOMStorageManager);
     return dsm.getLocalStorageForPrincipal(principal, "");
   }
 
   let s = [
     getStorageForURI(uri("http://mozilla.org")),
     getStorageForURI(uri("http://my.mozilla.org")),
--- a/browser/modules/NewTabUtils.jsm
+++ b/browser/modules/NewTabUtils.jsm
@@ -13,17 +13,17 @@ const Cu = Components.utils;
 Cu.import("resource://gre/modules/Services.jsm");
 Cu.import("resource://gre/modules/XPCOMUtils.jsm");
 
 XPCOMUtils.defineLazyModuleGetter(this, "PlacesUtils",
   "resource://gre/modules/PlacesUtils.jsm");
 
 XPCOMUtils.defineLazyGetter(this, "gPrincipal", function () {
   let uri = Services.io.newURI("about:newtab", null, null);
-  return Services.scriptSecurityManager.getCodebasePrincipal(uri);
+  return Services.scriptSecurityManager.getNoAppCodebasePrincipal(uri);
 });
 
 // The preference that tells whether this feature is enabled.
 const PREF_NEWTAB_ENABLED = "browser.newtabpage.enabled";
 
 // The maximum number of results we want to retrieve from history.
 const HISTORY_RESULTS_LIMIT = 100;
 
--- a/dom/tests/mochitest/localstorage/test_localStorageFromChrome.xhtml
+++ b/dom/tests/mochitest/localstorage/test_localStorageFromChrome.xhtml
@@ -13,17 +13,17 @@ function startTest()
   var ios = Components.classes["@mozilla.org/network/io-service;1"]
     .getService(Components.interfaces.nsIIOService);
   var ssm = Components.classes["@mozilla.org/scriptsecuritymanager;1"]
     .getService(Components.interfaces.nsIScriptSecurityManager);
   var dsm = Components.classes["@mozilla.org/dom/storagemanager;1"]
     .getService(Components.interfaces.nsIDOMStorageManager);
 
   var uri = ios.newURI(url, "", null);
-  var principal = ssm.getCodebasePrincipal(uri);
+  var principal = ssm.getNoAppCodebasePrincipal(uri);
   var storage = dsm.getLocalStorageForPrincipal(principal, "");
   
   storage.setItem("chromekey", "chromevalue");
   
   var aframe = document.getElementById("aframe");
   aframe.onload = function()
   {
     is(storage.getItem("chromekey"), "chromevalue");
--- a/dom/tests/unit/test_domstorage_aboutpages.js
+++ b/dom/tests/unit/test_domstorage_aboutpages.js
@@ -152,17 +152,17 @@ function testURIWithCasing(aURI) {
   do_check_eq(storage.length, 0);
   do_check_eq(storage.getItem("test-item"), null);
 }
 
 function getStorageForURI(aURI)
 {
   let principal = Components.classes["@mozilla.org/scriptsecuritymanager;1"].
                   getService(Components.interfaces.nsIScriptSecurityManager).
-                  getCodebasePrincipal(aURI);
+                  getNoAppCodebasePrincipal(aURI);
   let dsm = Components.classes["@mozilla.org/dom/storagemanager;1"].
             getService(Components.interfaces.nsIDOMStorageManager);
   return dsm.getLocalStorageForPrincipal(principal, "");
 }
 
 function togglePBMode(aEnable)
 {
   let pb = Components.classes["@mozilla.org/privatebrowsing;1"].