From fd98ffd5d7527ef04bfeddc0f17416f0e0949df8 Mon Sep 17 00:00:00 2001 From: Yoshi Huang Date: Tue, 18 Aug 2015 15:01:42 +0800 Subject: [PATCH] Bug 1165272 - Part 2: replace getNoAppCodebasePrincipal. r=bholley --- browser/base/content/aboutSocialError.xhtml | 3 ++- .../browser_offlineQuotaNotification.js | 2 +- .../test/general/browser_sanitizeDialog.js | 4 ++-- .../general/test_offlineNotification.html | 10 ++++------ .../test/general/test_offline_gzip.html | 6 +++--- browser/base/content/test/newtab/head.js | 2 +- browser/components/feeds/FeedConverter.js | 2 +- .../preferences/aboutPermissions.js | 6 +++--- browser/components/preferences/permissions.js | 4 ++-- .../preferences/tests/browser_permissions.js | 6 ++++-- ...einspector_csslogic-content-stylesheets.js | 6 +++--- .../pdfjs/content/PdfStreamConverter.jsm | 17 ++++++++++++----- .../shumway/chrome/SpecialStorage.jsm | 6 +++--- browser/modules/Feeds.jsm | 3 ++- caps/nsIScriptSecurityManager.idl | 6 ++++-- .../mochitest/test_chrome_constructor.html | 2 +- dom/indexedDB/test/head.js | 18 +++++++++--------- .../test/unit/test_defaultStorageUpgrade.js | 12 ++++-------- .../test/unit/test_idle_maintenance.js | 6 +++--- .../test/unit/test_metadataRestore.js | 2 +- .../test/unit/test_open_for_principal.js | 6 +++--- .../test/unit/test_temporary_storage.js | 6 +++--- .../chrome/test_MozDomFullscreen_event.xul | 6 +++--- .../test_localStorageFromChrome.xhtml | 6 +++--- extensions/cookie/nsPermission.cpp | 10 +++------- extensions/cookie/nsPermissionManager.cpp | 8 +++++--- .../test/unit/test_permmanager_defaults.js | 11 ++++++----- .../test/unit/test_permmanager_expiration.js | 2 +- .../test_permmanager_getPermissionObject.js | 9 +++++---- .../cookie/test/unit/test_permmanager_idn.js | 9 +++++---- .../test_permmanager_load_invalid_entries.js | 7 ++++--- .../test/unit/test_permmanager_local_files.js | 3 ++- .../test/unit/test_permmanager_matches.js | 12 ++++++------ .../test/unit/test_permmanager_matchesuri.js | 5 ++--- .../unit/test_permmanager_notifications.js | 7 ++++--- .../test/unit/test_permmanager_removesince.js | 4 ++-- .../test/unit/test_permmanager_subdomains.js | 11 ++++++----- extensions/cookie/test/unit_ipc/test_child.js | 6 +++--- .../cookie/test/unit_ipc/test_parent.js | 6 +++--- gfx/thebes/gfxSVGGlyphs.cpp | 9 +++++---- js/xpconnect/src/Sandbox.cpp | 13 ++++++------- .../test/unit/test_auth_dialog_permission.js | 9 ++++----- .../test_fallback_no-cache-entry_canceled.js | 6 +++--- .../test_fallback_no-cache-entry_passing.js | 6 +++--- ...k_redirect-to-different-origin_canceled.js | 6 +++--- ...ck_redirect-to-different-origin_passing.js | 6 +++--- .../test_fallback_request-error_canceled.js | 6 +++--- .../test_fallback_request-error_passing.js | 6 +++--- .../test_fallback_response-error_canceled.js | 6 +++--- .../test_fallback_response-error_passing.js | 6 +++--- .../test_offlinecache_custom-directory.js | 6 +++--- netwerk/test/unit/test_permmgr.js | 4 ++-- services/sync/Weave.js | 3 ++- .../tests/Harness_sanity/test_bug816847.html | 4 ++-- .../downloads/ApplicationReputation.cpp | 17 +++++++++-------- .../downloads/test/unit/test_app_rep.js | 6 +++--- .../components/places/BookmarkJSONUtils.jsm | 2 +- .../components/places/nsLivemarkService.js | 2 +- toolkit/components/social/SocialService.jsm | 6 +++--- .../tests/unit/head_urlclassifier.js | 2 +- .../tests/unit/test_dbservice.js | 11 ++++++----- .../tests/unit/test_digest256.js | 4 ++-- .../test/unit/test_removeDataFromDomain.js | 19 ++++++++++--------- toolkit/modules/NewTabUtils.jsm | 2 +- toolkit/modules/PermissionsUtils.jsm | 4 ++-- toolkit/webapps/NativeApp.jsm | 7 +++---- .../prefetch/nsOfflineCacheUpdateService.cpp | 13 ++++++------- 67 files changed, 230 insertions(+), 218 deletions(-) diff --git a/browser/base/content/aboutSocialError.xhtml b/browser/base/content/aboutSocialError.xhtml index b9d84190686..e4800db7239 100644 --- a/browser/base/content/aboutSocialError.xhtml +++ b/browser/base/content/aboutSocialError.xhtml @@ -55,7 +55,8 @@ // the error message. if (!config.origin) { let URI = Services.io.newURI(url, null, null); - config.origin = Services.scriptSecurityManager.getNoAppCodebasePrincipal(URI).origin; + config.origin = + Services.scriptSecurityManager.createCodebasePrincipal(URI, {}).origin; } switch (mode) { diff --git a/browser/base/content/test/general/browser_offlineQuotaNotification.js b/browser/base/content/test/general/browser_offlineQuotaNotification.js index 8a1fbdb1f79..6a53675b286 100644 --- a/browser/base/content/test/general/browser_offlineQuotaNotification.js +++ b/browser/base/content/test/general/browser_offlineQuotaNotification.js @@ -11,7 +11,7 @@ const URL = "http://mochi.test:8888/browser/browser/base/content/test/general/of registerCleanupFunction(function() { // Clean up after ourself let uri = Services.io.newURI(URL, null, null); - var principal = Services.scriptSecurityManager.getNoAppCodebasePrincipal(uri); + let principal = Services.scriptSecurityManager.createCodebasePrincipal(uri, {}); Services.perms.removeFromPrincipal(principal, "offline-app"); Services.prefs.clearUserPref("offline-apps.quota.warn"); Services.prefs.clearUserPref("offline-apps.allow_by_default"); diff --git a/browser/base/content/test/general/browser_sanitizeDialog.js b/browser/base/content/test/general/browser_sanitizeDialog.js index 67edca79f91..fa867128a4e 100644 --- a/browser/base/content/test/general/browser_sanitizeDialog.js +++ b/browser/base/content/test/general/browser_sanitizeDialog.js @@ -564,7 +564,7 @@ var gAllTests = [ var sm = Cc["@mozilla.org/scriptsecuritymanager;1"] .getService(Ci.nsIScriptSecurityManager); - var principal = sm.getNoAppCodebasePrincipal(URI); + var principal = sm.createCodebasePrincipal(URI, {}); // Give www.example.com privileges to store offline data var pm = Cc["@mozilla.org/permissionmanager;1"] @@ -634,7 +634,7 @@ var gAllTests = [ var sm = Cc["@mozilla.org/scriptsecuritymanager;1"] .getService(Ci.nsIScriptSecurityManager); - var principal = sm.getNoAppCodebasePrincipal(URI); + var principal = sm.createCodebasePrincipal(URI, {}); // Open the dialog let wh = new WindowHelper(); diff --git a/browser/base/content/test/general/test_offlineNotification.html b/browser/base/content/test/general/test_offlineNotification.html index 787dbb57692..4f78184b429 100644 --- a/browser/base/content/test/general/test_offlineNotification.html +++ b/browser/base/content/test/general/test_offlineNotification.html @@ -43,12 +43,10 @@ window.addEventListener("message", function(event) { var uri1 = ioService.newURI(frames.testFrame.location, null, null); var uri2 = ioService.newURI(frames.testFrame3.location, null, null); - var principal1 = Cc["@mozilla.org/scriptsecuritymanager;1"] - .getService(SpecialPowers.Ci.nsIScriptSecurityManager) - .getNoAppCodebasePrincipal(uri1); - var principal2 = Cc["@mozilla.org/scriptsecuritymanager;1"] - .getService(SpecialPowers.Ci.nsIScriptSecurityManager) - .getNoAppCodebasePrincipal(uri2); + var ssm = Cc["@mozilla.org/scriptsecuritymanager;1"] + .getService(SpecialPowers.Ci.nsIScriptSecurityManager); + var principal1 = ssm.createCodebasePrincipal(uri1, {}); + var principal2 = ssm.createCodebasePrincipal(uri2, {}); pm.removeFromPrincipal(principal1, "offline-app"); pm.removeFromPrincipal(principal2, "offline-app"); diff --git a/browser/base/content/test/general/test_offline_gzip.html b/browser/base/content/test/general/test_offline_gzip.html index 1d318b38e64..98cbdf9ac1c 100644 --- a/browser/base/content/test/general/test_offline_gzip.html +++ b/browser/base/content/test/general/test_offline_gzip.html @@ -39,9 +39,9 @@ function finishTest() { var uri = Cc["@mozilla.org/network/io-service;1"].getService(SpecialPowers.Ci.nsIIOService) .newURI(window.frames[0].location, null, null); - var principal = Cc["@mozilla.org/scriptsecuritymanager;1"] - .getService(SpecialPowers.Ci.nsIScriptSecurityManager) - .getNoAppCodebasePrincipal(uri); + var ssm = Cc["@mozilla.org/scriptsecuritymanager;1"] + .getService(SpecialPowers.Ci.nsIScriptSecurityManager); + var principal = ssm.createCodebasePrincipal(uri, {}); pm.removeFromPrincipal(principal, "offline-app"); diff --git a/browser/base/content/test/newtab/head.js b/browser/base/content/test/newtab/head.js index 6eb54ebf03f..d8433b2e621 100644 --- a/browser/base/content/test/newtab/head.js +++ b/browser/base/content/test/newtab/head.js @@ -18,7 +18,7 @@ Cu.import("resource://gre/modules/Timer.jsm", tmp); let {Promise, NewTabUtils, Sanitizer, clearTimeout, setTimeout, DirectoryLinksProvider, PlacesTestUtils} = tmp; let uri = Services.io.newURI("about:newtab", null, null); -let principal = Services.scriptSecurityManager.getNoAppCodebasePrincipal(uri); +let principal = Services.scriptSecurityManager.createCodebasePrincipal(uri, {}); let isMac = ("nsILocalFileMac" in Ci); let isLinux = ("@mozilla.org/gnome-gconf-service;1" in Cc); diff --git a/browser/components/feeds/FeedConverter.js b/browser/components/feeds/FeedConverter.js index 75115cc94d1..a6ecfb4575d 100644 --- a/browser/components/feeds/FeedConverter.js +++ b/browser/components/feeds/FeedConverter.js @@ -254,7 +254,7 @@ FeedConverter.prototype = { chromeChannel = ios.newChannelFromURIWithLoadInfo(aboutFeedsURI, loadInfo); chromeChannel.originalURI = result.uri; chromeChannel.owner = - Services.scriptSecurityManager.getNoAppCodebasePrincipal(aboutFeedsURI); + Services.scriptSecurityManager.createCodebasePrincipal(aboutFeedsURI, {}); } else { chromeChannel = ios.newChannelFromURIWithLoadInfo(result.uri, loadInfo); } diff --git a/browser/components/preferences/aboutPermissions.js b/browser/components/preferences/aboutPermissions.js index 763315e7b06..104793b97f7 100644 --- a/browser/components/preferences/aboutPermissions.js +++ b/browser/components/preferences/aboutPermissions.js @@ -505,7 +505,7 @@ let AboutPermissions = { while (row = aResults.getNextRow()) { let spec = row.getResultByName("url"); let uri = NetUtil.newURI(spec); - let principal = gSecMan.getNoAppCodebasePrincipal(uri); + let principal = gSecMan.createCodebasePrincipal(uri, {}); AboutPermissions.addPrincipal(principal); } @@ -556,7 +556,7 @@ let AboutPermissions = { try { // aLogin.hostname is a string in origin URL format (e.g. "http://foo.com") let uri = NetUtil.newURI(aLogin.hostname); - let principal = gSecMan.getNoAppCodebasePrincipal(uri); + let principal = gSecMan.createCodebasePrincipal(uri, {}); this.addPrincipal(principal); } catch (e) { // newURI will throw for add-ons logins stored in chrome:// URIs @@ -572,7 +572,7 @@ let AboutPermissions = { try { // aHostname is a string in origin URL format (e.g. "http://foo.com") let uri = NetUtil.newURI(aHostname); - let principal = gSecMan.getNoAppCodebasePrincipal(uri); + let principal = gSecMan.createCodebasePrincipal(uri, {}); this.addPrincipal(principal); } catch (e) { // newURI will throw for add-ons logins stored in chrome:// URIs diff --git a/browser/components/preferences/permissions.js b/browser/components/preferences/permissions.js index c3f5d717557..3a19a0612af 100644 --- a/browser/components/preferences/permissions.js +++ b/browser/components/preferences/permissions.js @@ -95,12 +95,12 @@ var gPermissionManager = { let uri; try { uri = Services.io.newURI(input_url, null, null); - principal = Services.scriptSecurityManager.getNoAppCodebasePrincipal(uri); + principal = Services.scriptSecurityManager.createCodebasePrincipal(uri, {}); // If we have ended up with an unknown scheme, the following will throw. principal.origin; } catch(ex) { uri = Services.io.newURI("http://" + input_url, null, null); - principal = Services.scriptSecurityManager.getNoAppCodebasePrincipal(uri); + principal = Services.scriptSecurityManager.createCodebasePrincipal(uri, {}); // If we have ended up with an unknown scheme, the following will throw. principal.origin; } diff --git a/browser/components/preferences/tests/browser_permissions.js b/browser/components/preferences/tests/browser_permissions.js index 6dc766e2a2b..620883e4be0 100644 --- a/browser/components/preferences/tests/browser_permissions.js +++ b/browser/components/preferences/tests/browser_permissions.js @@ -8,8 +8,10 @@ const ABOUT_PERMISSIONS_SPEC = "about:permissions"; const TEST_URI_1 = NetUtil.newURI("http://mozilla.com/"); const TEST_URI_2 = NetUtil.newURI("http://mozilla.org/"); -const TEST_PRINCIPAL_1 = Services.scriptSecurityManager.getNoAppCodebasePrincipal(TEST_URI_1); -const TEST_PRINCIPAL_2 = Services.scriptSecurityManager.getNoAppCodebasePrincipal(TEST_URI_2); +const TEST_PRINCIPAL_1 = + Services.scriptSecurityManager.createCodebasePrincipal(TEST_URI_1, {}); +const TEST_PRINCIPAL_2 = + Services.scriptSecurityManager.createCodebasePrincipal(TEST_URI_2, {}); // values from DefaultPermissions object const PERM_UNKNOWN = 0; diff --git a/browser/devtools/styleinspector/test/browser_styleinspector_csslogic-content-stylesheets.js b/browser/devtools/styleinspector/test/browser_styleinspector_csslogic-content-stylesheets.js index 0c68b7e5dd3..1255f8fb7e9 100644 --- a/browser/devtools/styleinspector/test/browser_styleinspector_csslogic-content-stylesheets.js +++ b/browser/devtools/styleinspector/test/browser_styleinspector_csslogic-content-stylesheets.js @@ -15,9 +15,9 @@ const TEST_URI_XUL = TEST_URL_ROOT + "doc_content_stylesheet.xul"; const XUL_URI = Cc["@mozilla.org/network/io-service;1"] .getService(Ci.nsIIOService) .newURI(TEST_URI_XUL, null, null); -const XUL_PRINCIPAL = Components.classes["@mozilla.org/scriptsecuritymanager;1"] - .getService(Ci.nsIScriptSecurityManager) - .getNoAppCodebasePrincipal(XUL_URI); +let ssm = Components.classes["@mozilla.org/scriptsecuritymanager;1"] + .getService(Ci.nsIScriptSecurityManager); +const XUL_PRINCIPAL = ssm.createCodebasePrincipal(XUL_URI, {}); add_task(function*() { info("Checking stylesheets on HTML document"); diff --git a/browser/extensions/pdfjs/content/PdfStreamConverter.jsm b/browser/extensions/pdfjs/content/PdfStreamConverter.jsm index b088bdf3025..1a38324d0b0 100644 --- a/browser/extensions/pdfjs/content/PdfStreamConverter.jsm +++ b/browser/extensions/pdfjs/content/PdfStreamConverter.jsm @@ -995,14 +995,21 @@ PdfStreamConverter.prototype = { // We can use resource principal when data is fetched by the chrome // e.g. useful for NoScript - var securityManager = Cc['@mozilla.org/scriptsecuritymanager;1'] - .getService(Ci.nsIScriptSecurityManager); + var ssm = Cc['@mozilla.org/scriptsecuritymanager;1'] + .getService(Ci.nsIScriptSecurityManager); var uri = NetUtil.newURI(PDF_VIEWER_WEB_PAGE, null, null); // FF16 and below had getCodebasePrincipal, it was replaced by // getNoAppCodebasePrincipal (bug 758258). - var resourcePrincipal = 'getNoAppCodebasePrincipal' in securityManager ? - securityManager.getNoAppCodebasePrincipal(uri) : - securityManager.getCodebasePrincipal(uri); + // FF 43 added createCodebasePrincipal to replace getNoAppCodebasePrincipal + // (bug 1165272). + var resourcePrincipal + if ('createCodebasePrincipal' in ssm) { + resourcePrincipal = ssm.createCodebasePrincipal(uri, {}); + } else if ('getNoAppCodebasePrincipal' in ssm) { + resourcePrincipal = ssm.getNoAppCodebasePrincipal(uri) + } else { + resourcePrincipal = ssm.getCodebasePrincipal(uri); + } aRequest.owner = resourcePrincipal; channel.asyncOpen(proxy, aContext); }, diff --git a/browser/extensions/shumway/chrome/SpecialStorage.jsm b/browser/extensions/shumway/chrome/SpecialStorage.jsm index 03815f6cc95..636d263eebe 100644 --- a/browser/extensions/shumway/chrome/SpecialStorage.jsm +++ b/browser/extensions/shumway/chrome/SpecialStorage.jsm @@ -22,9 +22,9 @@ var SpecialStorageUtils = { createWrappedSpecialStorage: function (sandbox, swfUrl, privateBrowsing) { // Creating internal localStorage object based on url and privateBrowsing setting. var uri = Services.io.newURI(swfUrl, null, null); - var principal = Components.classes["@mozilla.org/scriptsecuritymanager;1"] - .getService(Components.interfaces.nsIScriptSecurityManager) - .getNoAppCodebasePrincipal(uri); + var ssm = Components.classes["@mozilla.org/scriptsecuritymanager;1"] + .getService(Components.interfaces.nsIScriptSecurityManager); + var principal = ssm.createCodebasePrincipal(uri, {}); var dsm = Components.classes["@mozilla.org/dom/localStorage-manager;1"] .getService(Components.interfaces.nsIDOMStorageManager); var storage = dsm.createStorage(null, principal, privateBrowsing); diff --git a/browser/modules/Feeds.jsm b/browser/modules/Feeds.jsm index b2bdbe0422b..481095ff4b0 100644 --- a/browser/modules/Feeds.jsm +++ b/browser/modules/Feeds.jsm @@ -66,7 +66,8 @@ this.Feeds = { if (aIsFeed) { // re-create the principal as it may be a CPOW. let principalURI = BrowserUtils.makeURIFromCPOW(aPrincipal.URI); - let principalToCheck = Services.scriptSecurityManager.getNoAppCodebasePrincipal(principalURI); + let principalToCheck = + Services.scriptSecurityManager.createCodebasePrincipal(principalURI, {}); try { BrowserUtils.urlSecurityCheck(aLink.href, principalToCheck, Ci.nsIScriptSecurityManager.DISALLOW_INHERIT_PRINCIPAL); diff --git a/caps/nsIScriptSecurityManager.idl b/caps/nsIScriptSecurityManager.idl index e44cb07df91..916563d8587 100644 --- a/caps/nsIScriptSecurityManager.idl +++ b/caps/nsIScriptSecurityManager.idl @@ -26,7 +26,7 @@ class DomainPolicyClone; [ptr] native JSObjectPtr(JSObject); [ptr] native DomainPolicyClonePtr(mozilla::dom::DomainPolicyClone); -[scriptable, uuid(73f92674-f59d-4c9b-a9b5-f7a3ae8ffa98)] +[scriptable, uuid(6e8a4d1e-d9c6-4d86-bf53-d73f58f36148)] interface nsIScriptSecurityManager : nsISupports { /** @@ -177,8 +177,10 @@ interface nsIScriptSecurityManager : nsISupports * Returns a principal with that has the same origin as uri and is not part * of an appliction. * The returned principal will have appId = NO_APP_ID. + * + * @deprecated use createCodebasePrincipal instead. */ - nsIPrincipal getNoAppCodebasePrincipal(in nsIURI uri); + [deprecated] nsIPrincipal getNoAppCodebasePrincipal(in nsIURI uri); /** * Legacy method for getting a principal with no origin attributes. diff --git a/dom/cache/test/mochitest/test_chrome_constructor.html b/dom/cache/test/mochitest/test_chrome_constructor.html index c131fc5a37d..97b1a0a7ef6 100644 --- a/dom/cache/test/mochitest/test_chrome_constructor.html +++ b/dom/cache/test/mochitest/test_chrome_constructor.html @@ -20,7 +20,7 @@ // attach to a different origin's CacheStorage var url = 'http://example.com/'; var uri = Services.io.newURI(url, null, null); - var principal = Services.scriptSecurityManager.getNoAppCodebasePrincipal(uri); + var principal = Services.scriptSecurityManager.createCodebasePrincipal(uri, {}); var storage = new CacheStorage('content', principal); // verify we can use the other origin's CacheStorage as normal diff --git a/dom/indexedDB/test/head.js b/dom/indexedDB/test/head.js index 7b58ef7687f..eb4244fc1c5 100644 --- a/dom/indexedDB/test/head.js +++ b/dom/indexedDB/test/head.js @@ -116,9 +116,9 @@ function setPermission(url, permission) let uri = Components.classes["@mozilla.org/network/io-service;1"] .getService(Components.interfaces.nsIIOService) .newURI(url, null, null); - let principal = Components.classes["@mozilla.org/scriptsecuritymanager;1"] - .getService(Ci.nsIScriptSecurityManager) - .getNoAppCodebasePrincipal(uri); + let ssm = Components.classes["@mozilla.org/scriptsecuritymanager;1"] + .getService(Ci.nsIScriptSecurityManager); + let principal = ssm.createCodebasePrincipal(uri, {}); Components.classes["@mozilla.org/permissionmanager;1"] .getService(nsIPermissionManager) @@ -131,9 +131,9 @@ function removePermission(url, permission) let uri = Components.classes["@mozilla.org/network/io-service;1"] .getService(Components.interfaces.nsIIOService) .newURI(url, null, null); - let principal = Components.classes["@mozilla.org/scriptsecuritymanager;1"] - .getService(Ci.nsIScriptSecurityManager) - .getNoAppCodebasePrincipal(uri); + let ssm = Components.classes["@mozilla.org/scriptsecuritymanager;1"] + .getService(Ci.nsIScriptSecurityManager); + let principal = ssm.createCodebasePrincipal(uri, {}); Components.classes["@mozilla.org/permissionmanager;1"] .getService(Components.interfaces.nsIPermissionManager) @@ -145,9 +145,9 @@ function getPermission(url, permission) let uri = Components.classes["@mozilla.org/network/io-service;1"] .getService(Components.interfaces.nsIIOService) .newURI(url, null, null); - let principal = Components.classes["@mozilla.org/scriptsecuritymanager;1"] - .getService(Ci.nsIScriptSecurityManager) - .getNoAppCodebasePrincipal(uri); + let ssm = Components.classes["@mozilla.org/scriptsecuritymanager;1"] + .getService(Ci.nsIScriptSecurityManager); + let principal = ssm.createCodebasePrincipal(uri, {}); return Components.classes["@mozilla.org/permissionmanager;1"] .getService(Components.interfaces.nsIPermissionManager) diff --git a/dom/indexedDB/test/unit/test_defaultStorageUpgrade.js b/dom/indexedDB/test/unit/test_defaultStorageUpgrade.js index e6c67c1e692..c6042ca5c28 100644 --- a/dom/indexedDB/test/unit/test_defaultStorageUpgrade.js +++ b/dom/indexedDB/test/unit/test_defaultStorageUpgrade.js @@ -90,14 +90,10 @@ function testSteps() let request; if ("url" in params) { let uri = ios.newURI(params.url, null, null); - let principal; - if ("appId" in params) { - principal = - ssm.createCodebasePrincipal(uri, {appId: params.appId, - inBrowser: params.inMozBrowser}); - } else { - principal = ssm.getNoAppCodebasePrincipal(uri); - } + let principal = + ssm.createCodebasePrincipal(uri, + {appId: params.appId || ssm.NO_APPID, + inBrowser: params.inMozBrowser}); if ("dbVersion" in params) { request = indexedDB.openForPrincipal(principal, params.dbName, params.dbVersion); diff --git a/dom/indexedDB/test/unit/test_idle_maintenance.js b/dom/indexedDB/test/unit/test_idle_maintenance.js index 96ff9ec139c..dfba12a61fc 100644 --- a/dom/indexedDB/test/unit/test_idle_maintenance.js +++ b/dom/indexedDB/test/unit/test_idle_maintenance.js @@ -10,9 +10,9 @@ function testSteps() let uri = Cc["@mozilla.org/network/io-service;1"]. getService(Ci.nsIIOService). newURI("https://www.example.com", null, null); - let principal = Cc["@mozilla.org/scriptsecuritymanager;1"]. - getService(Ci.nsIScriptSecurityManager). - getNoAppCodebasePrincipal(uri); + let ssm = Cc["@mozilla.org/scriptsecuritymanager;1"] + .getService(Ci.nsIScriptSecurityManager); + let principal = ssm.createCodebasePrincipal(uri, {}); info("Setting permissions"); diff --git a/dom/indexedDB/test/unit/test_metadataRestore.js b/dom/indexedDB/test/unit/test_metadataRestore.js index 24285740eb6..e1a84a1507d 100644 --- a/dom/indexedDB/test/unit/test_metadataRestore.js +++ b/dom/indexedDB/test/unit/test_metadataRestore.js @@ -67,7 +67,7 @@ function testSteps() let request; if ("url" in params) { let uri = ios.newURI(params.url, null, null); - let principal = ssm.getNoAppCodebasePrincipal(uri); + let principal = ssm.createCodebasePrincipal(uri, {}); request = indexedDB.openForPrincipal(principal, params.dbName, params.dbOptions); } else { diff --git a/dom/indexedDB/test/unit/test_open_for_principal.js b/dom/indexedDB/test/unit/test_open_for_principal.js index 0c885194001..171f71b3986 100644 --- a/dom/indexedDB/test/unit/test_open_for_principal.js +++ b/dom/indexedDB/test/unit/test_open_for_principal.js @@ -48,9 +48,9 @@ function testSteps() let uri = Components.classes["@mozilla.org/network/io-service;1"] .getService(Components.interfaces.nsIIOService) .newURI("http://appdata.example.com", null, null); - let principal = Components.classes["@mozilla.org/scriptsecuritymanager;1"] - .getService(Components.interfaces.nsIScriptSecurityManager) - .getNoAppCodebasePrincipal(uri); + let ssm = Components.classes["@mozilla.org/scriptsecuritymanager;1"] + .getService(Components.interfaces.nsIScriptSecurityManager); + let principal = ssm.createCodebasePrincipal(uri, {}); request = indexedDB.openForPrincipal(principal, name, 1); request.onerror = errorHandler; diff --git a/dom/indexedDB/test/unit/test_temporary_storage.js b/dom/indexedDB/test/unit/test_temporary_storage.js index 95b76e8945c..5e29483deb7 100644 --- a/dom/indexedDB/test/unit/test_temporary_storage.js +++ b/dom/indexedDB/test/unit/test_temporary_storage.js @@ -34,9 +34,9 @@ function testSteps() let uri = Cc["@mozilla.org/network/io-service;1"] .getService(Ci.nsIIOService) .newURI(url, null, null); - return Cc["@mozilla.org/scriptsecuritymanager;1"] - .getService(Ci.nsIScriptSecurityManager) - .getNoAppCodebasePrincipal(uri); + let ssm = Cc["@mozilla.org/scriptsecuritymanager;1"] + .getService(Ci.nsIScriptSecurityManager); + return ssm.createCodebasePrincipal(uri, {}); } for (let temporary of [true, false]) { diff --git a/dom/tests/mochitest/chrome/test_MozDomFullscreen_event.xul b/dom/tests/mochitest/chrome/test_MozDomFullscreen_event.xul index 7bb5f2352ae..5d801dc3543 100644 --- a/dom/tests/mochitest/chrome/test_MozDomFullscreen_event.xul +++ b/dom/tests/mochitest/chrome/test_MozDomFullscreen_event.xul @@ -27,9 +27,9 @@ function make_uri(url) { // Ensure "fullscreen" permissions are not present on the test URI. var pm = Cc["@mozilla.org/permissionmanager;1"].getService(Ci.nsIPermissionManager); var uri = make_uri("http://mochi.test:8888"); -var principal = Components.classes["@mozilla.org/scriptsecuritymanager;1"] - .getService(Ci.nsIScriptSecurityManager) - .getNoAppCodebasePrincipal(uri); +var ssm = Components.classes["@mozilla.org/scriptsecuritymanager;1"] + .getService(Ci.nsIScriptSecurityManager); +var principal = ssm.createCodebasePrincipal(uri, {}); pm.removeFromPrincipal(principal, "fullscreen"); SpecialPowers.pushPrefEnv({"set": [ diff --git a/dom/tests/mochitest/localstorage/test_localStorageFromChrome.xhtml b/dom/tests/mochitest/localstorage/test_localStorageFromChrome.xhtml index 983ca176b5e..22665b00870 100644 --- a/dom/tests/mochitest/localstorage/test_localStorageFromChrome.xhtml +++ b/dom/tests/mochitest/localstorage/test_localStorageFromChrome.xhtml @@ -18,11 +18,11 @@ function startTest() .getService(Components.interfaces.nsIDOMStorageManager); var uri = ios.newURI(url, "", null); - var principal = ssm.getNoAppCodebasePrincipal(uri); + var principal = ssm.createCodebasePrincipal(uri, {}); var storage = dsm.createStorage(window, principal, ""); - + storage.setItem("chromekey", "chromevalue"); - + var aframe = document.getElementById("aframe"); aframe.onload = function() { diff --git a/extensions/cookie/nsPermission.cpp b/extensions/cookie/nsPermission.cpp index 8398b7584e8..61d0d62634f 100644 --- a/extensions/cookie/nsPermission.cpp +++ b/extensions/cookie/nsPermission.cpp @@ -7,7 +7,6 @@ #include "nsContentUtils.h" #include "nsIClassInfoImpl.h" #include "nsIEffectiveTLDService.h" -#include "nsIScriptSecurityManager.h" #include "mozilla/BasePrincipal.h" // nsPermission Implementation @@ -168,12 +167,9 @@ nsPermission::MatchesURI(nsIURI* aURI, bool aExactHost, bool* aMatches) { NS_ENSURE_ARG_POINTER(aURI); - nsIScriptSecurityManager* secMan = nsContentUtils::GetSecurityManager(); - NS_ENSURE_TRUE(secMan, NS_ERROR_FAILURE); - - nsCOMPtr principal; - nsresult rv = secMan->GetNoAppCodebasePrincipal(aURI, getter_AddRefs(principal)); - NS_ENSURE_SUCCESS(rv, rv); + mozilla::OriginAttributes attrs; + nsCOMPtr principal = mozilla::BasePrincipal::CreateCodebasePrincipal(aURI, attrs); + NS_ENSURE_TRUE(principal, NS_ERROR_FAILURE); return Matches(principal, aExactHost, aMatches); } diff --git a/extensions/cookie/nsPermissionManager.cpp b/extensions/cookie/nsPermissionManager.cpp index 351f2e5f744..d91489671ba 100644 --- a/extensions/cookie/nsPermissionManager.cpp +++ b/extensions/cookie/nsPermissionManager.cpp @@ -138,10 +138,12 @@ GetPrincipal(nsIURI* aURI, uint32_t aAppId, bool aIsInBrowserElement, nsIPrincip nsresult GetPrincipal(nsIURI* aURI, nsIPrincipal** aPrincipal) { - nsIScriptSecurityManager* secMan = nsContentUtils::GetSecurityManager(); - NS_ENSURE_TRUE(secMan, NS_ERROR_FAILURE); + mozilla::OriginAttributes attrs; + nsCOMPtr principal = mozilla::BasePrincipal::CreateCodebasePrincipal(aURI, attrs); + NS_ENSURE_TRUE(principal, NS_ERROR_FAILURE); - return secMan->GetNoAppCodebasePrincipal(aURI, aPrincipal); + principal.forget(aPrincipal); + return NS_OK; } nsCString diff --git a/extensions/cookie/test/unit/test_permmanager_defaults.js b/extensions/cookie/test/unit/test_permmanager_defaults.js index 39048217c43..18f2ea1ed8e 100644 --- a/extensions/cookie/test/unit/test_permmanager_defaults.js +++ b/extensions/cookie/test/unit/test_permmanager_defaults.js @@ -51,10 +51,11 @@ add_task(function* do_test() { getService(Ci.nsIPermissionManager); // test the default permission was applied. - let principal = Services.scriptSecurityManager.getNoAppCodebasePrincipal(TEST_ORIGIN); - let principalHttps = Services.scriptSecurityManager.getNoAppCodebasePrincipal(TEST_ORIGIN_HTTPS); - let principal2 = Services.scriptSecurityManager.getNoAppCodebasePrincipal(TEST_ORIGIN_2); - let principal3 = Services.scriptSecurityManager.getNoAppCodebasePrincipal(TEST_ORIGIN_3); + let principal = Services.scriptSecurityManager.createCodebasePrincipal(TEST_ORIGIN, {}); + let principalHttps = Services.scriptSecurityManager.createCodebasePrincipal(TEST_ORIGIN_HTTPS, {}); + let principal2 = Services.scriptSecurityManager.createCodebasePrincipal(TEST_ORIGIN_2, {}); + let principal3 = Services.scriptSecurityManager.createCodebasePrincipal(TEST_ORIGIN_3, {}); + let attrs = {appId: 1000, inBrowser: true}; let principal4 = Services.scriptSecurityManager.createCodebasePrincipal(TEST_ORIGIN, attrs); let principal5 = Services.scriptSecurityManager.createCodebasePrincipal(TEST_ORIGIN_3, attrs); @@ -223,7 +224,7 @@ function checkCapabilityViaDB(expected, origin = TEST_ORIGIN, type = TEST_PERMIS // value (ie, the "capability" in nsIPermission parlance) or null if it can't // be found. function findCapabilityViaDB(origin = TEST_ORIGIN, type = TEST_PERMISSION) { - let principal = Services.scriptSecurityManager.getNoAppCodebasePrincipal(origin); + let principal = Services.scriptSecurityManager.createCodebasePrincipal(origin, {}); let originStr = principal.origin; let file = Services.dirsvc.get("ProfD", Ci.nsIFile); diff --git a/extensions/cookie/test/unit/test_permmanager_expiration.js b/extensions/cookie/test/unit/test_permmanager_expiration.js index 0216320eae8..6ec8f677ef6 100644 --- a/extensions/cookie/test/unit/test_permmanager_expiration.js +++ b/extensions/cookie/test/unit/test_permmanager_expiration.js @@ -21,7 +21,7 @@ function do_run_test() { let pm = Services.perms; let permURI = NetUtil.newURI("http://example.com"); - let principal = Services.scriptSecurityManager.getNoAppCodebasePrincipal(permURI); + let principal = Services.scriptSecurityManager.createCodebasePrincipal(permURI, {}); let now = Number(Date.now()); diff --git a/extensions/cookie/test/unit/test_permmanager_getPermissionObject.js b/extensions/cookie/test/unit/test_permmanager_getPermissionObject.js index f2f13f38e3a..d01b51923dc 100644 --- a/extensions/cookie/test/unit/test_permmanager_getPermissionObject.js +++ b/extensions/cookie/test/unit/test_permmanager_getPermissionObject.js @@ -1,10 +1,11 @@ /* Any copyright is dedicated to the Public Domain. http://creativecommons.org/publicdomain/zero/1.0/ */ -function getPrincipalFromURI(uri) { - return Cc["@mozilla.org/scriptsecuritymanager;1"] - .getService(Ci.nsIScriptSecurityManager) - .getNoAppCodebasePrincipal(NetUtil.newURI(uri)); +function getPrincipalFromURI(aURI) { + let ssm = Cc["@mozilla.org/scriptsecuritymanager;1"] + .getService(Ci.nsIScriptSecurityManager); + let uri = NetUtil.newURI(aURI); + return ssm.createCodebasePrincipal(uri, {}); } function getSystemPrincipal() { diff --git a/extensions/cookie/test/unit/test_permmanager_idn.js b/extensions/cookie/test/unit/test_permmanager_idn.js index eeb1e52bb18..72fc06bbaa9 100644 --- a/extensions/cookie/test/unit/test_permmanager_idn.js +++ b/extensions/cookie/test/unit/test_permmanager_idn.js @@ -2,9 +2,10 @@ http://creativecommons.org/publicdomain/zero/1.0/ */ function getPrincipalFromDomain(aDomain) { - return Cc["@mozilla.org/scriptsecuritymanager;1"] - .getService(Ci.nsIScriptSecurityManager) - .getNoAppCodebasePrincipal(NetUtil.newURI("http://" + aDomain)); + let ssm = Cc["@mozilla.org/scriptsecuritymanager;1"] + .getService(Ci.nsIScriptSecurityManager); + let uri = NetUtil.newURI("http://" + aDomain); + return ssm.createCodebasePrincipal(uri, {}); } function run_test() { @@ -45,4 +46,4 @@ function run_test() { do_check_eq(pm.testPermissionFromPrincipal(witnessPrincipal, perm), pm.UNKNOWN_ACTION); witnessPrincipal = getPrincipalFromDomain("foo.bar.com"); do_check_eq(pm.testPermissionFromPrincipal(witnessPrincipal, perm), pm.UNKNOWN_ACTION); -} \ No newline at end of file +} diff --git a/extensions/cookie/test/unit/test_permmanager_load_invalid_entries.js b/extensions/cookie/test/unit/test_permmanager_load_invalid_entries.js index 1dd3682010b..36a8378dace 100644 --- a/extensions/cookie/test/unit/test_permmanager_load_invalid_entries.js +++ b/extensions/cookie/test/unit/test_permmanager_load_invalid_entries.js @@ -134,8 +134,9 @@ function run_test() { do_check_true(numMigrated > 0, "we found at least 1 record that was migrated"); // This permission should always be there. - let principal = Cc["@mozilla.org/scriptsecuritymanager;1"] - .getService(Ci.nsIScriptSecurityManager) - .getNoAppCodebasePrincipal(NetUtil.newURI("http://example.org")); + let ssm = Cc["@mozilla.org/scriptsecuritymanager;1"] + .getService(Ci.nsIScriptSecurityManager); + let uri = NetUtil.newURI("http://example.org"); + let principal = ssm.createCodebasePrincipal(uri, {}); do_check_eq(pm.testPermissionFromPrincipal(principal, 'test-load-invalid-entries'), Ci.nsIPermissionManager.ALLOW_ACTION); } diff --git a/extensions/cookie/test/unit/test_permmanager_local_files.js b/extensions/cookie/test/unit/test_permmanager_local_files.js index 67884cb642c..b9c803f5c27 100644 --- a/extensions/cookie/test/unit/test_permmanager_local_files.js +++ b/extensions/cookie/test/unit/test_permmanager_local_files.js @@ -5,7 +5,8 @@ function getPrincipalFromURIString(uriStr) { - return Services.scriptSecurityManager.getNoAppCodebasePrincipal(NetUtil.newURI(uriStr)); + let uri = NetUtil.newURI(uriStr); + return Services.scriptSecurityManager.createCodebasePrincipal(uri, {}); } function run_test() { diff --git a/extensions/cookie/test/unit/test_permmanager_matches.js b/extensions/cookie/test/unit/test_permmanager_matches.js index fa97cabdf1f..47ae194c1b7 100644 --- a/extensions/cookie/test/unit/test_permmanager_matches.js +++ b/extensions/cookie/test/unit/test_permmanager_matches.js @@ -38,12 +38,12 @@ function run_test() { let uri4 = NetUtil.newURI("https://hangouts.google.com/#!/hangout", null, null); let uri5 = NetUtil.newURI("http://google.com:8096/", null, null); - let uri0_n_n = secMan.getNoAppCodebasePrincipal(uri0); - let uri1_n_n = secMan.getNoAppCodebasePrincipal(uri1); - let uri2_n_n = secMan.getNoAppCodebasePrincipal(uri2); - let uri3_n_n = secMan.getNoAppCodebasePrincipal(uri3); - let uri4_n_n = secMan.getNoAppCodebasePrincipal(uri4); - let uri5_n_n = secMan.getNoAppCodebasePrincipal(uri5); + let uri0_n_n = secMan.createCodebasePrincipal(uri0, {}); + let uri1_n_n = secMan.createCodebasePrincipal(uri1, {}); + let uri2_n_n = secMan.createCodebasePrincipal(uri2, {}); + let uri3_n_n = secMan.createCodebasePrincipal(uri3, {}); + let uri4_n_n = secMan.createCodebasePrincipal(uri4, {}); + let uri5_n_n = secMan.createCodebasePrincipal(uri5, {}); let attrs = {appId: 1000}; let uri0_1000_n = secMan.createCodebasePrincipal(uri0, attrs); diff --git a/extensions/cookie/test/unit/test_permmanager_matchesuri.js b/extensions/cookie/test/unit/test_permmanager_matchesuri.js index 1b9e5fcfce1..88578166ca0 100644 --- a/extensions/cookie/test/unit/test_permmanager_matchesuri.js +++ b/extensions/cookie/test/unit/test_permmanager_matchesuri.js @@ -31,9 +31,8 @@ function mk_permission(uri, isAppPermission = false) { // Get the permission from the principal! let attrs = {appId: 1000}; - let principal = isAppPermission ? - secMan.createCodebasePrincipal(uri, attrs) : - secMan.getNoAppCodebasePrincipal(uri); + let principal = + secMan.createCodebasePrincipal(uri, isAppPermission ? attrs : {}); pm.addFromPrincipal(principal, "test/matchesuri", pm.ALLOW_ACTION); let permission = pm.getPermissionObject(principal, "test/matchesuri", true); diff --git a/extensions/cookie/test/unit/test_permmanager_notifications.js b/extensions/cookie/test/unit/test_permmanager_notifications.js index 20768d1b310..780e83ca6a6 100644 --- a/extensions/cookie/test/unit/test_permmanager_notifications.js +++ b/extensions/cookie/test/unit/test_permmanager_notifications.js @@ -23,9 +23,10 @@ function do_run_test() { let pm = Services.perms; let now = Number(Date.now()); let permType = "test/expiration-perm"; - let principal = Components.classes["@mozilla.org/scriptsecuritymanager;1"] - .getService(Ci.nsIScriptSecurityManager) - .getNoAppCodebasePrincipal(NetUtil.newURI("http://example.com")); + let ssm = Cc["@mozilla.org/scriptsecuritymanager;1"] + .getService(Ci.nsIScriptSecurityManager); + let uri = NetUtil.newURI("http://example.com"); + let principal = ssm.createCodebasePrincipal(uri, {}); let observer = new permission_observer(test_generator, now, permType); Services.obs.addObserver(observer, "perm-changed", false); diff --git a/extensions/cookie/test/unit/test_permmanager_removesince.js b/extensions/cookie/test/unit/test_permmanager_removesince.js index e7d4dadd546..35d649cfeb5 100644 --- a/extensions/cookie/test/unit/test_permmanager_removesince.js +++ b/extensions/cookie/test/unit/test_permmanager_removesince.js @@ -24,10 +24,10 @@ function do_run_test() { // to help with testing edge-cases, we will arrange for .removeAllSince to // remove *all* permissions from one principal and one permission from another. let permURI1 = NetUtil.newURI("http://example.com"); - let principal1 = Services.scriptSecurityManager.getNoAppCodebasePrincipal(permURI1); + let principal1 = Services.scriptSecurityManager.createCodebasePrincipal(permURI1, {}); let permURI2 = NetUtil.newURI("http://example.org"); - let principal2 = Services.scriptSecurityManager.getNoAppCodebasePrincipal(permURI2); + let principal2 = Services.scriptSecurityManager.createCodebasePrincipal(permURI2, {}); // add a permission now - this isn't going to be removed. pm.addFromPrincipal(principal1, "test/remove-since", 1); diff --git a/extensions/cookie/test/unit/test_permmanager_subdomains.js b/extensions/cookie/test/unit/test_permmanager_subdomains.js index 56cddcbc73e..4e78e4d4665 100644 --- a/extensions/cookie/test/unit/test_permmanager_subdomains.js +++ b/extensions/cookie/test/unit/test_permmanager_subdomains.js @@ -1,10 +1,11 @@ /* Any copyright is dedicated to the Public Domain. http://creativecommons.org/publicdomain/zero/1.0/ */ -function getPrincipalFromURI(uri) { - return Cc["@mozilla.org/scriptsecuritymanager;1"] - .getService(Ci.nsIScriptSecurityManager) - .getNoAppCodebasePrincipal(NetUtil.newURI(uri)); +function getPrincipalFromURI(aURI) { + let ssm = Cc["@mozilla.org/scriptsecuritymanager;1"] + .getService(Ci.nsIScriptSecurityManager); + let uri = NetUtil.newURI(aURI); + return ssm.createCodebasePrincipal(uri, {}); } function run_test() { @@ -53,4 +54,4 @@ function run_test() { do_check_eq(pm.testPermissionFromPrincipal(sub1Principal, "test/subdomains"), pm.UNKNOWN_ACTION); do_check_eq(pm.testPermissionFromPrincipal(sub2Principal, "test/subdomains"), pm.UNKNOWN_ACTION); do_check_eq(pm.testPermissionFromPrincipal(subsubPrincipal, "test/subdomains"), pm.UNKNOWN_ACTION); -} \ No newline at end of file +} diff --git a/extensions/cookie/test/unit_ipc/test_child.js b/extensions/cookie/test/unit_ipc/test_child.js index ebe2db5b8d2..ae81da05c2a 100644 --- a/extensions/cookie/test/unit_ipc/test_child.js +++ b/extensions/cookie/test/unit_ipc/test_child.js @@ -12,9 +12,9 @@ function isParentProcess() { function getPrincipalForURI(aURI) { var uri = gIoService.newURI(aURI, null, null); - return Components.classes["@mozilla.org/scriptsecuritymanager;1"] - .getService(Ci.nsIScriptSecurityManager) - .getNoAppCodebasePrincipal(uri); + var ssm = Cc["@mozilla.org/scriptsecuritymanager;1"] + .getService(Ci.nsIScriptSecurityManager); + return ssm.createCodebasePrincipal(uri, {}); } function run_test() { diff --git a/extensions/cookie/test/unit_ipc/test_parent.js b/extensions/cookie/test/unit_ipc/test_parent.js index fb217d76ae3..b1056146c0f 100644 --- a/extensions/cookie/test/unit_ipc/test_parent.js +++ b/extensions/cookie/test/unit_ipc/test_parent.js @@ -12,9 +12,9 @@ function isParentProcess() { function getPrincipalForURI(aURI) { var uri = gIoService.newURI(aURI, null, null); - return Cc["@mozilla.org/scriptsecuritymanager;1"] - .getService(Ci.nsIScriptSecurityManager) - .getNoAppCodebasePrincipal(uri); + var ssm = Cc["@mozilla.org/scriptsecuritymanager;1"] + .getService(Ci.nsIScriptSecurityManager); + return ssm.createCodebasePrincipal(uri, {}); } function run_test() { diff --git a/gfx/thebes/gfxSVGGlyphs.cpp b/gfx/thebes/gfxSVGGlyphs.cpp index ab4c360e171..4e76420dd5e 100644 --- a/gfx/thebes/gfxSVGGlyphs.cpp +++ b/gfx/thebes/gfxSVGGlyphs.cpp @@ -19,10 +19,10 @@ #include "nsStringStream.h" #include "nsStreamUtils.h" #include "nsIPrincipal.h" +#include "mozilla/BasePrincipal.h" #include "mozilla/dom/Element.h" #include "mozilla/LoadInfo.h" #include "nsSVGUtils.h" -#include "nsIScriptSecurityManager.h" #include "nsHostObjectProtocolHandler.h" #include "nsContentUtils.h" #include "gfxFont.h" @@ -348,9 +348,10 @@ gfxSVGGlyphsDocument::ParseDocument(const uint8_t *aBuffer, uint32_t aBufLen) rv = NS_NewURI(getter_AddRefs(uri), mSVGGlyphsDocumentURI); NS_ENSURE_SUCCESS(rv, rv); - nsCOMPtr principal; - nsContentUtils::GetSecurityManager()-> - GetNoAppCodebasePrincipal(uri, getter_AddRefs(principal)); + OriginAttributes attrs; + nsCOMPtr principal = + BasePrincipal::CreateCodebasePrincipal(uri, attrs); + NS_ENSURE_TRUE(principal, NS_ERROR_FAILURE); nsCOMPtr domDoc; rv = NS_NewDOMDocument(getter_AddRefs(domDoc), diff --git a/js/xpconnect/src/Sandbox.cpp b/js/xpconnect/src/Sandbox.cpp index 6f7932563b1..1a08862176c 100644 --- a/js/xpconnect/src/Sandbox.cpp +++ b/js/xpconnect/src/Sandbox.cpp @@ -16,7 +16,6 @@ #include "nsGlobalWindow.h" #include "nsIScriptContext.h" #include "nsIScriptObjectPrincipal.h" -#include "nsIScriptSecurityManager.h" #include "nsIURI.h" #include "nsJSUtils.h" #include "nsNetUtil.h" @@ -1193,15 +1192,15 @@ ParsePrincipal(JSContext* cx, HandleString codebase, nsIPrincipal** principal) return false; } - nsCOMPtr secman = - do_GetService(kScriptSecurityManagerContractID); - NS_ENSURE_TRUE(secman, false); - // We could allow passing in the app-id and browser-element info to the // sandbox constructor. But creating a sandbox based on a string is a // deprecated API so no need to add features to it. - rv = secman->GetNoAppCodebasePrincipal(uri, principal); - if (NS_FAILED(rv) || !*principal) { + OriginAttributes attrs; + nsCOMPtr prin = + BasePrincipal::CreateCodebasePrincipal(uri, attrs); + prin.forget(principal); + + if (!*principal) { JS_ReportError(cx, "Creating Principal from URI failed"); return false; } diff --git a/netwerk/test/unit/test_auth_dialog_permission.js b/netwerk/test/unit/test_auth_dialog_permission.js index 5bfe9853722..c7d2a2a7a6e 100644 --- a/netwerk/test/unit/test_auth_dialog_permission.js +++ b/netwerk/test/unit/test_auth_dialog_permission.js @@ -111,11 +111,10 @@ function make_uri(url) { } function makeChan(loadingUrl, url, contentPolicy) { - var loadingUri = make_uri(loadingUrl); - var principal = Components.classes["@mozilla.org/scriptsecuritymanager;1"] - .getService(Ci.nsIScriptSecurityManager) - .getNoAppCodebasePrincipal(loadingUri); - + var ssm = Cc["@mozilla.org/scriptsecuritymanager;1"] + .getService(Ci.nsIScriptSecurityManager); + var uri = make_uri(loadingUrl); + var principal = ssm.createCodebasePrincipal(uri, {}); var ios = Components.classes["@mozilla.org/network/io-service;1"] .getService(Components.interfaces.nsIIOService); var chan = ios.newChannel2(url, diff --git a/netwerk/test/unit/test_fallback_no-cache-entry_canceled.js b/netwerk/test/unit/test_fallback_no-cache-entry_canceled.js index 5ce21bd48d7..a7553e925f1 100644 --- a/netwerk/test/unit/test_fallback_no-cache-entry_canceled.js +++ b/netwerk/test/unit/test_fallback_no-cache-entry_canceled.js @@ -72,10 +72,10 @@ function run_test() var pm = Cc["@mozilla.org/permissionmanager;1"] .getService(Ci.nsIPermissionManager); + var ssm = Cc["@mozilla.org/scriptsecuritymanager;1"] + .getService(Ci.nsIScriptSecurityManager); var uri = make_uri("http://localhost:" + httpServer.identity.primaryPort); - var principal = Components.classes["@mozilla.org/scriptsecuritymanager;1"] - .getService(Ci.nsIScriptSecurityManager) - .getNoAppCodebasePrincipal(uri); + var principal = ssm.createCodebasePrincipal(uri, {}); if (pm.testPermissionFromPrincipal(principal, "offline-app") != 0) { dump("Previous test failed to clear offline-app permission! Expect failures.\n"); diff --git a/netwerk/test/unit/test_fallback_no-cache-entry_passing.js b/netwerk/test/unit/test_fallback_no-cache-entry_passing.js index 4ce1ee37105..f6d551f6b9b 100644 --- a/netwerk/test/unit/test_fallback_no-cache-entry_passing.js +++ b/netwerk/test/unit/test_fallback_no-cache-entry_passing.js @@ -72,10 +72,10 @@ function run_test() var pm = Cc["@mozilla.org/permissionmanager;1"] .getService(Ci.nsIPermissionManager); + var ssm = Cc["@mozilla.org/scriptsecuritymanager;1"] + .getService(Ci.nsIScriptSecurityManager); var uri = make_uri("http://localhost:" + httpServer.identity.primaryPort); - var principal = Components.classes["@mozilla.org/scriptsecuritymanager;1"] - .getService(Ci.nsIScriptSecurityManager) - .getNoAppCodebasePrincipal(uri); + var principal = ssm.createCodebasePrincipal(uri, {}); if (pm.testPermissionFromPrincipal(principal, "offline-app") != 0) { dump("Previous test failed to clear offline-app permission! Expect failures.\n"); diff --git a/netwerk/test/unit/test_fallback_redirect-to-different-origin_canceled.js b/netwerk/test/unit/test_fallback_redirect-to-different-origin_canceled.js index bba4240b2d1..ba94fb51971 100644 --- a/netwerk/test/unit/test_fallback_redirect-to-different-origin_canceled.js +++ b/netwerk/test/unit/test_fallback_redirect-to-different-origin_canceled.js @@ -80,10 +80,10 @@ function run_test() var pm = Cc["@mozilla.org/permissionmanager;1"] .getService(Ci.nsIPermissionManager); + var ssm = Cc["@mozilla.org/scriptsecuritymanager;1"] + .getService(Ci.nsIScriptSecurityManager); var uri = make_uri("http://localhost:" + httpServer.identity.primaryPort); - var principal = Cc["@mozilla.org/scriptsecuritymanager;1"] - .getService(Ci.nsIScriptSecurityManager) - .getNoAppCodebasePrincipal(uri); + var principal = ssm.createCodebasePrincipal(uri, {}); if (pm.testPermissionFromPrincipal(principal, "offline-app") != 0) { dump("Previous test failed to clear offline-app permission! Expect failures.\n"); diff --git a/netwerk/test/unit/test_fallback_redirect-to-different-origin_passing.js b/netwerk/test/unit/test_fallback_redirect-to-different-origin_passing.js index 9c12b9a71b3..7c848bcb44a 100644 --- a/netwerk/test/unit/test_fallback_redirect-to-different-origin_passing.js +++ b/netwerk/test/unit/test_fallback_redirect-to-different-origin_passing.js @@ -80,10 +80,10 @@ function run_test() var pm = Cc["@mozilla.org/permissionmanager;1"] .getService(Ci.nsIPermissionManager); + var ssm = Cc["@mozilla.org/scriptsecuritymanager;1"] + .getService(Ci.nsIScriptSecurityManager); var uri = make_uri("http://localhost:" + httpServer.identity.primaryPort); - var principal = Cc["@mozilla.org/scriptsecuritymanager;1"] - .getService(Ci.nsIScriptSecurityManager) - .getNoAppCodebasePrincipal(uri); + var principal = ssm.createCodebasePrincipal(uri, {}); if (pm.testPermissionFromPrincipal(principal, "offline-app") != 0) { dump("Previous test failed to clear offline-app permission! Expect failures.\n"); diff --git a/netwerk/test/unit/test_fallback_request-error_canceled.js b/netwerk/test/unit/test_fallback_request-error_canceled.js index 4308fe8a0dc..cd39adc822b 100644 --- a/netwerk/test/unit/test_fallback_request-error_canceled.js +++ b/netwerk/test/unit/test_fallback_request-error_canceled.js @@ -79,10 +79,10 @@ function run_test() var pm = Cc["@mozilla.org/permissionmanager;1"] .getService(Ci.nsIPermissionManager); + var ssm = Cc["@mozilla.org/scriptsecuritymanager;1"] + .getService(Ci.nsIScriptSecurityManager); var uri = make_uri("http://localhost:" + httpServer.identity.primaryPort); - var principal = Cc["@mozilla.org/scriptsecuritymanager;1"] - .getService(Ci.nsIScriptSecurityManager) - .getNoAppCodebasePrincipal(uri); + var principal = ssm.createCodebasePrincipal(uri, {}); if (pm.testPermissionFromPrincipal(principal, "offline-app") != 0) { dump("Previous test failed to clear offline-app permission! Expect failures.\n"); diff --git a/netwerk/test/unit/test_fallback_request-error_passing.js b/netwerk/test/unit/test_fallback_request-error_passing.js index 11349557f5e..cde494b157d 100644 --- a/netwerk/test/unit/test_fallback_request-error_passing.js +++ b/netwerk/test/unit/test_fallback_request-error_passing.js @@ -79,10 +79,10 @@ function run_test() var pm = Cc["@mozilla.org/permissionmanager;1"] .getService(Ci.nsIPermissionManager); + var ssm = Cc["@mozilla.org/scriptsecuritymanager;1"] + .getService(Ci.nsIScriptSecurityManager); var uri = make_uri("http://localhost:" + httpServer.identity.primaryPort); - var principal = Cc["@mozilla.org/scriptsecuritymanager;1"] - .getService(Ci.nsIScriptSecurityManager) - .getNoAppCodebasePrincipal(uri); + var principal = ssm.createCodebasePrincipal(uri, {}); if (pm.testPermissionFromPrincipal(principal, "offline-app") != 0) { dump("Previous test failed to clear offline-app permission! Expect failures.\n"); diff --git a/netwerk/test/unit/test_fallback_response-error_canceled.js b/netwerk/test/unit/test_fallback_response-error_canceled.js index d0138abee6c..a83b8209ab8 100644 --- a/netwerk/test/unit/test_fallback_response-error_canceled.js +++ b/netwerk/test/unit/test_fallback_response-error_canceled.js @@ -79,10 +79,10 @@ function run_test() var pm = Cc["@mozilla.org/permissionmanager;1"] .getService(Ci.nsIPermissionManager); + var ssm = Cc["@mozilla.org/scriptsecuritymanager;1"] + .getService(Ci.nsIScriptSecurityManager); var uri = make_uri("http://localhost:" + httpServer.identity.primaryPort); - var principal = Cc["@mozilla.org/scriptsecuritymanager;1"] - .getService(Ci.nsIScriptSecurityManager) - .getNoAppCodebasePrincipal(uri); + var principal = ssm.createCodebasePrincipal(uri, {}); if (pm.testPermissionFromPrincipal(principal, "offline-app") != 0) { dump("Previous test failed to clear offline-app permission! Expect failures.\n"); diff --git a/netwerk/test/unit/test_fallback_response-error_passing.js b/netwerk/test/unit/test_fallback_response-error_passing.js index 5f5d4bfbe88..2469b196699 100644 --- a/netwerk/test/unit/test_fallback_response-error_passing.js +++ b/netwerk/test/unit/test_fallback_response-error_passing.js @@ -79,10 +79,10 @@ function run_test() var pm = Cc["@mozilla.org/permissionmanager;1"] .getService(Ci.nsIPermissionManager); + var ssm = Cc["@mozilla.org/scriptsecuritymanager;1"] + .getService(Ci.nsIScriptSecurityManager); var uri = make_uri("http://localhost:" + httpServer.identity.primaryPort); - var principal = Cc["@mozilla.org/scriptsecuritymanager;1"] - .getService(Ci.nsIScriptSecurityManager) - .getNoAppCodebasePrincipal(uri); + var principal = ssm.createCodebasePrincipal(uri, {}); if (pm.testPermissionFromPrincipal(principal, "offline-app") != 0) { dump("Previous test failed to clear offline-app permission! Expect failures.\n"); diff --git a/netwerk/test/unit/test_offlinecache_custom-directory.js b/netwerk/test/unit/test_offlinecache_custom-directory.js index 4e00ba8c5be..2472860b7d3 100644 --- a/netwerk/test/unit/test_offlinecache_custom-directory.js +++ b/netwerk/test/unit/test_offlinecache_custom-directory.js @@ -103,10 +103,10 @@ function run_test() var pm = Cc["@mozilla.org/permissionmanager;1"] .getService(Ci.nsIPermissionManager); + var ssm = Cc["@mozilla.org/scriptsecuritymanager;1"] + .getService(Ci.nsIScriptSecurityManager); var uri = make_uri("http://localhost:4444"); - var principal = Cc["@mozilla.org/scriptsecuritymanager;1"] - .getService(Ci.nsIScriptSecurityManager) - .getNoAppCodebasePrincipal(uri); + var principal = ssm.createCodebasePrincipal(uri, {}); if (pm.testPermissionFromPrincipal(principal, "offline-app") != 0) { dump("Previous test failed to clear offline-app permission! Expect failures.\n"); diff --git a/netwerk/test/unit/test_permmgr.js b/netwerk/test/unit/test_permmgr.js index 5a6ddd8b5a1..bb4a2349c7a 100644 --- a/netwerk/test/unit/test_permmgr.js +++ b/netwerk/test/unit/test_permmgr.js @@ -46,7 +46,7 @@ function run_test() { // put a few hosts in for (var i = 0; i < hosts.length; ++i) { let uri = ioService.newURI(hosts[i][0], null, null); - let principal = secMan.getNoAppCodebasePrincipal(uri); + let principal = secMan.createCodebasePrincipal(uri, {}); pm.addFromPrincipal(principal, hosts[i][1], hosts[i][2]); } @@ -54,7 +54,7 @@ function run_test() { // test the result for (var i = 0; i < results.length; ++i) { let uri = ioService.newURI(results[i][0], null, null); - let principal = secMan.getNoAppCodebasePrincipal(uri); + let principal = secMan.createCodebasePrincipal(uri, {}); do_check_eq(pm.testPermissionFromPrincipal(principal, results[i][1]), results[i][2]); do_check_eq(pm.testExactPermissionFromPrincipal(principal, results[i][1]), results[i][3]); diff --git a/services/sync/Weave.js b/services/sync/Weave.js index cb11a54e239..423dd5d7fad 100644 --- a/services/sync/Weave.js +++ b/services/sync/Weave.js @@ -188,7 +188,8 @@ AboutWeaveLog.prototype = { // view. That way links to files can be opened. let ssm = Cc["@mozilla.org/scriptsecuritymanager;1"] .getService(Ci.nsIScriptSecurityManager); - let principal = ssm.getNoAppCodebasePrincipal(uri); + let principal = ssm.createCodebasePrincipal(uri, {}); + channel.owner = principal; return channel; } diff --git a/testing/mochitest/tests/Harness_sanity/test_bug816847.html b/testing/mochitest/tests/Harness_sanity/test_bug816847.html index a7ff5e308c7..85732e2e955 100644 --- a/testing/mochitest/tests/Harness_sanity/test_bug816847.html +++ b/testing/mochitest/tests/Harness_sanity/test_bug816847.html @@ -34,14 +34,14 @@ const unknown = Ci.nsIPermissionManager.UNKNOWN_ACTION; const perms = ['network-events', 'geolocation', 'camera', 'alarms'] function createPrincipal(aURI, aIsApp, aIsInBrowserElement) { - if(aIsApp) { + if (aIsApp) { var app = appsSvc.getAppByManifestURL(aURI); return app.principal; } var uri = Services.io.newURI(aURI, null, null); return Services.scriptSecurityManager - .getNoAppCodebasePrincipal(uri); + .createCodebasePrincipal(uri, {}); } // test addPermission and removePermission diff --git a/toolkit/components/downloads/ApplicationReputation.cpp b/toolkit/components/downloads/ApplicationReputation.cpp index 67aba51a6ea..f678ffd9895 100644 --- a/toolkit/components/downloads/ApplicationReputation.cpp +++ b/toolkit/components/downloads/ApplicationReputation.cpp @@ -15,7 +15,6 @@ #include "nsIHttpChannel.h" #include "nsIIOService.h" #include "nsIPrefService.h" -#include "nsIScriptSecurityManager.h" #include "nsISimpleEnumerator.h" #include "nsIStreamListener.h" #include "nsIStringStream.h" @@ -28,6 +27,7 @@ #include "nsIX509CertDB.h" #include "nsIX509CertList.h" +#include "mozilla/BasePrincipal.h" #include "mozilla/Preferences.h" #include "mozilla/Services.h" #include "mozilla/Telemetry.h" @@ -50,6 +50,8 @@ #include "nsILoadInfo.h" #include "nsContentUtils.h" +using mozilla::BasePrincipal; +using mozilla::OriginAttributes; using mozilla::Preferences; using mozilla::TimeStamp; using mozilla::Telemetry::Accumulate; @@ -293,13 +295,12 @@ PendingDBLookup::LookupSpecInternal(const nsACString& aSpec) rv = ios->NewURI(aSpec, nullptr, nullptr, getter_AddRefs(uri)); NS_ENSURE_SUCCESS(rv, rv); - nsCOMPtr principal; - nsCOMPtr secMan = - do_GetService(NS_SCRIPTSECURITYMANAGER_CONTRACTID, &rv); - NS_ENSURE_SUCCESS(rv, rv); - - rv = secMan->GetNoAppCodebasePrincipal(uri, getter_AddRefs(principal)); - NS_ENSURE_SUCCESS(rv, rv); + OriginAttributes attrs; + nsCOMPtr principal = + BasePrincipal::CreateCodebasePrincipal(uri, attrs); + if (!principal) { + return NS_ERROR_FAILURE; + } // Check local lists to see if the URI has already been whitelisted or // blacklisted. diff --git a/toolkit/components/downloads/test/unit/test_app_rep.js b/toolkit/components/downloads/test/unit/test_app_rep.js index 0ed46b72740..4d68afe7128 100644 --- a/toolkit/components/downloads/test/unit/test_app_rep.js +++ b/toolkit/components/downloads/test/unit/test_app_rep.js @@ -317,11 +317,11 @@ add_test(function test_redirect_on_blocklist() { let secman = Services.scriptSecurityManager; let badRedirects = Cc["@mozilla.org/array;1"] .createInstance(Ci.nsIMutableArray); - badRedirects.appendElement(secman.getNoAppCodebasePrincipal(exampleURI), + badRedirects.appendElement(secman.createCodebasePrincipal(exampleURI, {}), false); - badRedirects.appendElement(secman.getNoAppCodebasePrincipal(blocklistedURI), + badRedirects.appendElement(secman.createCodebasePrincipal(blocklistedURI, {}), false); - badRedirects.appendElement(secman.getNoAppCodebasePrincipal(whitelistedURI), + badRedirects.appendElement(secman.createCodebasePrincipal(whitelistedURI, {}), false); gAppRep.queryReputation({ sourceURI: whitelistedURI, diff --git a/toolkit/components/places/BookmarkJSONUtils.jsm b/toolkit/components/places/BookmarkJSONUtils.jsm index a2ac406d467..80350215046 100644 --- a/toolkit/components/places/BookmarkJSONUtils.jsm +++ b/toolkit/components/places/BookmarkJSONUtils.jsm @@ -209,7 +209,7 @@ BookmarkImporter.prototype = { let uri = NetUtil.newURI(spec); let channel = NetUtil.newChannel({ uri, - loadingPrincipal: Services.scriptSecurityManager.getNoAppCodebasePrincipal(uri), + loadingPrincipal: Services.scriptSecurityManager.createCodebasePrincipal(uri, {}), contentPolicyType: Ci.nsIContentPolicy.TYPE_INTERNAL_XMLHTTPREQUEST }); let streamLoader = Cc["@mozilla.org/network/stream-loader;1"] diff --git a/toolkit/components/places/nsLivemarkService.js b/toolkit/components/places/nsLivemarkService.js index b039f02920e..58ed8d59431 100644 --- a/toolkit/components/places/nsLivemarkService.js +++ b/toolkit/components/places/nsLivemarkService.js @@ -528,7 +528,7 @@ Livemark.prototype = { createInstance(Ci.nsILoadGroup); let channel = NetUtil.newChannel({ uri: this.feedURI.spec, - loadingPrincipal: Services.scriptSecurityManager.getNoAppCodebasePrincipal(this.feedURI), + loadingPrincipal: Services.scriptSecurityManager.createCodebasePrincipal(this.feedURI, {}), contentPolicyType: Ci.nsIContentPolicy.TYPE_INTERNAL_XMLHTTPREQUEST }).QueryInterface(Ci.nsIHttpChannel); channel.loadGroup = loadgroup; diff --git a/toolkit/components/social/SocialService.jsm b/toolkit/components/social/SocialService.jsm index 434421c29ec..e1e3a35c422 100644 --- a/toolkit/components/social/SocialService.jsm +++ b/toolkit/components/social/SocialService.jsm @@ -153,7 +153,7 @@ XPCOMUtils.defineLazyGetter(SocialServiceInternal, "providers", function () { function getOriginActivationType(origin) { // if this is an about uri, treat it as a directory let URI = Services.io.newURI(origin, null, null); - let principal = Services.scriptSecurityManager.getNoAppCodebasePrincipal(URI); + let principal = Services.scriptSecurityManager.createCodebasePrincipal(URI, {}); if (Services.scriptSecurityManager.isSystemPrincipal(principal) || origin == "moz-safe-about:home") { return "internal"; } @@ -513,7 +513,7 @@ this.SocialService = { } // force/fixup origin let URI = Services.io.newURI(installOrigin, null, null); - principal = Services.scriptSecurityManager.getNoAppCodebasePrincipal(URI); + principal = Services.scriptSecurityManager.createCodebasePrincipal(URI, {}); data.origin = principal.origin; // iconURL and name are required @@ -714,7 +714,7 @@ function SocialProvider(input) { this.postActivationURL = input.postActivationURL; this.origin = input.origin; let originUri = Services.io.newURI(input.origin, null, null); - this.principal = Services.scriptSecurityManager.getNoAppCodebasePrincipal(originUri); + this.principal = Services.scriptSecurityManager.createCodebasePrincipal(originUri, {}); this.ambientNotificationIcons = {}; this.errorState = null; this.frecency = 0; diff --git a/toolkit/components/url-classifier/tests/unit/head_urlclassifier.js b/toolkit/components/url-classifier/tests/unit/head_urlclassifier.js index 956f315f85a..6dcb95aac56 100644 --- a/toolkit/components/url-classifier/tests/unit/head_urlclassifier.js +++ b/toolkit/components/url-classifier/tests/unit/head_urlclassifier.js @@ -221,7 +221,7 @@ checkUrls: function(urls, expected, cb) var doLookup = function() { if (urls.length > 0) { var fragment = urls.shift(); - var principal = secMan.getNoAppCodebasePrincipal(iosvc.newURI("http://" + fragment, null, null)); + var principal = secMan.createCodebasePrincipal(iosvc.newURI("http://" + fragment, null, null), {}); dbservice.lookup(principal, allTables, function(arg) { do_check_eq(expected, arg); diff --git a/toolkit/components/url-classifier/tests/unit/test_dbservice.js b/toolkit/components/url-classifier/tests/unit/test_dbservice.js index c421c994f42..3c59205b8fa 100644 --- a/toolkit/components/url-classifier/tests/unit/test_dbservice.js +++ b/toolkit/components/url-classifier/tests/unit/test_dbservice.js @@ -97,7 +97,7 @@ function checkNoHost() // Looking up a no-host uri such as a data: uri should throw an exception. var exception; try { - var principal = secMan.getNoAppCodebasePrincipal(iosvc.newURI("data:text/html,test", null, null)); + var principal = secMan.createCodebasePrincipal(iosvc.newURI("data:text/html,test", null, null), {}); dbservice.lookup(principal, allTables); exception = false; @@ -198,26 +198,27 @@ function checkState() { numExpecting = 0; + for (var key in phishExpected) { - var principal = secMan.getNoAppCodebasePrincipal(iosvc.newURI("http://" + key, null, null)); + var principal = secMan.createCodebasePrincipal(iosvc.newURI("http://" + key, null, null), {}); dbservice.lookup(principal, allTables, phishExists, true); numExpecting++; } for (var key in phishUnexpected) { - var principal = secMan.getNoAppCodebasePrincipal(iosvc.newURI("http://" + key, null, null)); + var principal = secMan.createCodebasePrincipal(iosvc.newURI("http://" + key, null, null), {}); dbservice.lookup(principal, allTables, phishDoesntExist, true); numExpecting++; } for (var key in malwareExpected) { - var principal = secMan.getNoAppCodebasePrincipal(iosvc.newURI("http://" + key, null, null)); + var principal = secMan.createCodebasePrincipal(iosvc.newURI("http://" + key, null, null), {}); dbservice.lookup(principal, allTables, malwareExists, true); numExpecting++; } for (var key in unwantedExpected) { - var principal = secMan.getNoAppCodebasePrincipal(iosvc.newURI("http://" + key, null, null)); + var principal = secMan.createCodebasePrincipal(iosvc.newURI("http://" + key, null, null), {}); dbservice.lookup(principal, allTables, unwantedExists, true); numExpecting++; } diff --git a/toolkit/components/url-classifier/tests/unit/test_digest256.js b/toolkit/components/url-classifier/tests/unit/test_digest256.js index 74f8bc8d0d3..e460b2f3d32 100644 --- a/toolkit/components/url-classifier/tests/unit/test_digest256.js +++ b/toolkit/components/url-classifier/tests/unit/test_digest256.js @@ -124,7 +124,7 @@ add_test(function test_update() { add_test(function test_url_not_whitelisted() { let uri = createURI("http://example.com"); - let principal = gSecMan.getNoAppCodebasePrincipal(uri); + let principal = gSecMan.createCodebasePrincipal(uri, {}); gDbService.lookup(principal, "goog-downloadwhite-digest256", function handleEvent(aEvent) { // This URI is not on any lists. @@ -137,7 +137,7 @@ add_test(function test_url_whitelisted() { // Hash of "whitelisted.com/" (canonicalized URL) is: // 93CA5F48E15E9861CD37C2D95DB43D23CC6E6DE5C3F8FA6E8BE66F97CC518907 let uri = createURI("http://whitelisted.com"); - let principal = gSecMan.getNoAppCodebasePrincipal(uri); + let principal = gSecMan.createCodebasePrincipal(uri, {}); gDbService.lookup(principal, "goog-downloadwhite-digest256", function handleEvent(aEvent) { do_check_eq("goog-downloadwhite-digest256", aEvent); diff --git a/toolkit/forgetaboutsite/test/unit/test_removeDataFromDomain.js b/toolkit/forgetaboutsite/test/unit/test_removeDataFromDomain.js index a6793091c70..81cc9780fba 100644 --- a/toolkit/forgetaboutsite/test/unit/test_removeDataFromDomain.js +++ b/toolkit/forgetaboutsite/test/unit/test_removeDataFromDomain.js @@ -185,9 +185,9 @@ function add_permission(aURI) check_permission_exists(aURI, false); let pm = Cc["@mozilla.org/permissionmanager;1"]. getService(Ci.nsIPermissionManager); - let principal = Cc["@mozilla.org/scriptsecuritymanager;1"] - .getService(Ci.nsIScriptSecurityManager) - .getNoAppCodebasePrincipal(aURI); + let ssm = Cc["@mozilla.org/scriptsecuritymanager;1"] + .getService(Ci.nsIScriptSecurityManager); + let principal = ssm.createCodebasePrincipal(aURI, {}); pm.addFromPrincipal(principal, PERMISSION_TYPE, PERMISSION_VALUE); check_permission_exists(aURI, true); @@ -205,9 +205,9 @@ function check_permission_exists(aURI, aExists) { let pm = Cc["@mozilla.org/permissionmanager;1"]. getService(Ci.nsIPermissionManager); - let principal = Cc["@mozilla.org/scriptsecuritymanager;1"] - .getService(Ci.nsIScriptSecurityManager) - .getNoAppCodebasePrincipal(aURI); + let ssm = Cc["@mozilla.org/scriptsecuritymanager;1"] + .getService(Ci.nsIScriptSecurityManager); + let principal = ssm.createCodebasePrincipal(aURI, {}); let perm = pm.testExactPermissionFromPrincipal(principal, PERMISSION_TYPE); let checker = aExists ? do_check_eq : do_check_neq; @@ -554,9 +554,10 @@ function test_storage_cleared() { function getStorageForURI(aURI) { - let principal = Cc["@mozilla.org/scriptsecuritymanager;1"]. - getService(Ci.nsIScriptSecurityManager). - getNoAppCodebasePrincipal(aURI); + let ssm = Cc["@mozilla.org/scriptsecuritymanager;1"] + .getService(Ci.nsIScriptSecurityManager); + let principal = ssm.createCodebasePrincipal(aURI, {}); + let dsm = Cc["@mozilla.org/dom/localStorage-manager;1"]. getService(Ci.nsIDOMStorageManager); return dsm.createStorage(null, principal, ""); diff --git a/toolkit/modules/NewTabUtils.jsm b/toolkit/modules/NewTabUtils.jsm index 4d89dfd9b43..3120b9b23a2 100644 --- a/toolkit/modules/NewTabUtils.jsm +++ b/toolkit/modules/NewTabUtils.jsm @@ -25,7 +25,7 @@ XPCOMUtils.defineLazyModuleGetter(this, "BinarySearch", XPCOMUtils.defineLazyGetter(this, "gPrincipal", function () { let uri = Services.io.newURI("about:newtab", null, null); - return Services.scriptSecurityManager.getNoAppCodebasePrincipal(uri); + return Services.scriptSecurityManager.createCodebasePrincipal(uri, {}); }); XPCOMUtils.defineLazyGetter(this, "gCryptoHash", function () { diff --git a/toolkit/modules/PermissionsUtils.jsm b/toolkit/modules/PermissionsUtils.jsm index ec04826959c..07eaaa27bc0 100644 --- a/toolkit/modules/PermissionsUtils.jsm +++ b/toolkit/modules/PermissionsUtils.jsm @@ -39,8 +39,8 @@ function importPrefBranch(aPrefBranch, aPermission, aAction) { let httpsURI = Services.io.newURI("https://" + origin, null, null); principals = [ - Services.scriptSecurityManager.getNoAppCodebasePrincipal(httpURI), - Services.scriptSecurityManager.getNoAppCodebasePrincipal(httpsURI) + Services.scriptSecurityManager.createCodebasePrincipal(httpURI, {}), + Services.scriptSecurityManager.createCodebasePrincipal(httpsURI, {}) ]; } catch (e2) {} } diff --git a/toolkit/webapps/NativeApp.jsm b/toolkit/webapps/NativeApp.jsm index 8de17947808..111719e4fda 100644 --- a/toolkit/webapps/NativeApp.jsm +++ b/toolkit/webapps/NativeApp.jsm @@ -457,10 +457,9 @@ function downloadIcon(aIconURI) { // installing the app, hence app.origin is not available yet and // therefore we can not call getAppCodebasePrincipal. let principal = - aIconURI.schemeIs("chrome") ? Services.scriptSecurityManager - .getSystemPrincipal() - : Services.scriptSecurityManager - .getNoAppCodebasePrincipal(aIconURI); + aIconURI.schemeIs("chrome") ? + Services.scriptSecurityManager.getSystemPrincipal() : + Services.scriptSecurityManager.createCodebasePrincipal(aIconURI, {}); let channel = NetUtil.newChannel({ uri: aIconURI, diff --git a/uriloader/prefetch/nsOfflineCacheUpdateService.cpp b/uriloader/prefetch/nsOfflineCacheUpdateService.cpp index be0e4937d8b..aae490c1208 100644 --- a/uriloader/prefetch/nsOfflineCacheUpdateService.cpp +++ b/uriloader/prefetch/nsOfflineCacheUpdateService.cpp @@ -29,7 +29,6 @@ #include "nsICryptoHash.h" #include "nsIPermissionManager.h" #include "nsIPrincipal.h" -#include "nsIScriptSecurityManager.h" #include "nsNetCID.h" #include "nsServiceManagerUtils.h" #include "nsStreamUtils.h" @@ -718,9 +717,9 @@ nsOfflineCacheUpdateService::OfflineAppAllowedForURI(nsIURI *aURI, nsIPrefBranch *aPrefBranch, bool *aAllowed) { - nsCOMPtr principal; - nsContentUtils::GetSecurityManager()-> - GetNoAppCodebasePrincipal(aURI, getter_AddRefs(principal)); + OriginAttributes attrs; + nsCOMPtr principal = + BasePrincipal::CreateCodebasePrincipal(aURI, attrs); return OfflineAppPermForPrincipal(principal, aPrefBranch, false, aAllowed); } @@ -729,9 +728,9 @@ nsOfflineCacheUpdateService::OfflineAppPinnedForURI(nsIURI *aDocumentURI, nsIPrefBranch *aPrefBranch, bool *aPinned) { - nsCOMPtr principal; - nsContentUtils::GetSecurityManager()-> - GetNoAppCodebasePrincipal(aDocumentURI, getter_AddRefs(principal)); + OriginAttributes attrs; + nsCOMPtr principal = + BasePrincipal::CreateCodebasePrincipal(aDocumentURI, attrs); return OfflineAppPermForPrincipal(principal, aPrefBranch, true, aPinned); }