Skip to content
This repository has been archived by the owner on Aug 4, 2022. It is now read-only.

Commit

Permalink
Backed out 3 changesets (bug 1165272) for b2g sanity blocker.
Browse files Browse the repository at this point in the history
  • Loading branch information
bholley committed Aug 25, 2015
1 parent 4b0ef0b commit 76df031
Show file tree
Hide file tree
Showing 99 changed files with 429 additions and 433 deletions.
6 changes: 3 additions & 3 deletions addon-sdk/source/lib/sdk/indexed-db.js
Original file line number Diff line number Diff line change
Expand Up @@ -32,9 +32,9 @@ let principaluri = Cc["@mozilla.org/network/io-service;1"].
getService(Ci.nsIIOService).
newURI(PSEUDOURI, null, null);

let ssm = Cc["@mozilla.org/scriptsecuritymanager;1"]
.getService(Ci.nsIScriptSecurityManager);
let principal = ssm.createCodebasePrincipal(principaluri, {});
let principal = Cc["@mozilla.org/scriptsecuritymanager;1"].
getService(Ci.nsIScriptSecurityManager).
getCodebasePrincipal(principaluri);

function toArray(args) {
return Array.prototype.slice.call(args);
Expand Down
7 changes: 4 additions & 3 deletions b2g/components/AboutServiceWorkers.jsm
Original file line number Diff line number Diff line change
Expand Up @@ -154,10 +154,11 @@ this.AboutServiceWorkers = {
return;
}

let principal = Services.scriptSecurityManager.createCodebasePrincipal(
// TODO: Bug 1196652. use originNoSuffix
let principal = Services.scriptSecurityManager.getAppCodebasePrincipal(
Services.io.newURI(message.principal.origin, null, null),
message.principal.originAttributes);
message.principal.originAttributes.appId,
message.principal.originAttributes.inBrowser
);

if (!message.scope) {
self.sendError(message.id, "MissingScope");
Expand Down
6 changes: 3 additions & 3 deletions b2g/components/ContentPermissionPrompt.js
Original file line number Diff line number Diff line change
Expand Up @@ -205,9 +205,9 @@ ContentPermissionPrompt.prototype = {
// URL.
let notDenyAppPrincipal = function(type) {
let url = Services.io.newURI(app.origin, null, null);
let principal =
secMan.createCodebasePrincipal(url,
{appId: request.principal.appId});
let principal = secMan.getAppCodebasePrincipal(url,
request.principal.appId,
/*mozbrowser*/false);
let result = Services.perms.testExactPermissionFromPrincipal(principal,
type.access);

Expand Down
3 changes: 1 addition & 2 deletions browser/base/content/aboutSocialError.xhtml
Original file line number Diff line number Diff line change
Expand Up @@ -55,8 +55,7 @@
// the error message.
if (!config.origin) {
let URI = Services.io.newURI(url, null, null);
config.origin =
Services.scriptSecurityManager.createCodebasePrincipal(URI, {}).origin;
config.origin = Services.scriptSecurityManager.getNoAppCodebasePrincipal(URI).origin;
}

switch (mode) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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);
let principal = Services.scriptSecurityManager.createCodebasePrincipal(uri, {});
var principal = Services.scriptSecurityManager.getNoAppCodebasePrincipal(uri);
Services.perms.removeFromPrincipal(principal, "offline-app");
Services.prefs.clearUserPref("offline-apps.quota.warn");
Services.prefs.clearUserPref("offline-apps.allow_by_default");
Expand Down
4 changes: 2 additions & 2 deletions browser/base/content/test/general/browser_sanitizeDialog.js
Original file line number Diff line number Diff line change
Expand Up @@ -564,7 +564,7 @@ var gAllTests = [

var sm = Cc["@mozilla.org/scriptsecuritymanager;1"]
.getService(Ci.nsIScriptSecurityManager);
var principal = sm.createCodebasePrincipal(URI, {});
var principal = sm.getNoAppCodebasePrincipal(URI);

// Give www.example.com privileges to store offline data
var pm = Cc["@mozilla.org/permissionmanager;1"]
Expand Down Expand Up @@ -634,7 +634,7 @@ var gAllTests = [

var sm = Cc["@mozilla.org/scriptsecuritymanager;1"]
.getService(Ci.nsIScriptSecurityManager);
var principal = sm.createCodebasePrincipal(URI, {});
var principal = sm.getNoAppCodebasePrincipal(URI);

// Open the dialog
let wh = new WindowHelper();
Expand Down
10 changes: 6 additions & 4 deletions browser/base/content/test/general/test_offlineNotification.html
Original file line number Diff line number Diff line change
Expand Up @@ -43,10 +43,12 @@
var uri1 = ioService.newURI(frames.testFrame.location, null, null);
var uri2 = ioService.newURI(frames.testFrame3.location, null, null);

var ssm = Cc["@mozilla.org/scriptsecuritymanager;1"]
.getService(SpecialPowers.Ci.nsIScriptSecurityManager);
var principal1 = ssm.createCodebasePrincipal(uri1, {});
var principal2 = ssm.createCodebasePrincipal(uri2, {});
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);

pm.removeFromPrincipal(principal1, "offline-app");
pm.removeFromPrincipal(principal2, "offline-app");
Expand Down
6 changes: 3 additions & 3 deletions browser/base/content/test/general/test_offline_gzip.html
Original file line number Diff line number Diff line change
Expand Up @@ -39,9 +39,9 @@

var uri = Cc["@mozilla.org/network/io-service;1"].getService(SpecialPowers.Ci.nsIIOService)
.newURI(window.frames[0].location, null, null);
var ssm = Cc["@mozilla.org/scriptsecuritymanager;1"]
.getService(SpecialPowers.Ci.nsIScriptSecurityManager);
var principal = ssm.createCodebasePrincipal(uri, {});
var principal = Cc["@mozilla.org/scriptsecuritymanager;1"]
.getService(SpecialPowers.Ci.nsIScriptSecurityManager)
.getNoAppCodebasePrincipal(uri);

pm.removeFromPrincipal(principal, "offline-app");

Expand Down
2 changes: 1 addition & 1 deletion browser/base/content/test/newtab/head.js
Original file line number Diff line number Diff line change
Expand Up @@ -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.createCodebasePrincipal(uri, {});
let principal = Services.scriptSecurityManager.getNoAppCodebasePrincipal(uri);

let isMac = ("nsILocalFileMac" in Ci);
let isLinux = ("@mozilla.org/gnome-gconf-service;1" in Cc);
Expand Down
2 changes: 1 addition & 1 deletion browser/components/feeds/FeedConverter.js
Original file line number Diff line number Diff line change
Expand Up @@ -254,7 +254,7 @@ FeedConverter.prototype = {
chromeChannel = ios.newChannelFromURIWithLoadInfo(aboutFeedsURI, loadInfo);
chromeChannel.originalURI = result.uri;
chromeChannel.owner =
Services.scriptSecurityManager.createCodebasePrincipal(aboutFeedsURI, {});
Services.scriptSecurityManager.getNoAppCodebasePrincipal(aboutFeedsURI);
} else {
chromeChannel = ios.newChannelFromURIWithLoadInfo(result.uri, loadInfo);
}
Expand Down
6 changes: 3 additions & 3 deletions browser/components/preferences/aboutPermissions.js
Original file line number Diff line number Diff line change
Expand Up @@ -497,7 +497,7 @@ let AboutPermissions = {
while (row = aResults.getNextRow()) {
let spec = row.getResultByName("url");
let uri = NetUtil.newURI(spec);
let principal = gSecMan.createCodebasePrincipal(uri, {});
let principal = gSecMan.getNoAppCodebasePrincipal(uri);

AboutPermissions.addPrincipal(principal);
}
Expand Down Expand Up @@ -548,7 +548,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.createCodebasePrincipal(uri, {});
let principal = gSecMan.getNoAppCodebasePrincipal(uri);
this.addPrincipal(principal);
} catch (e) {
// newURI will throw for add-ons logins stored in chrome:// URIs
Expand All @@ -564,7 +564,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.createCodebasePrincipal(uri, {});
let principal = gSecMan.getNoAppCodebasePrincipal(uri);
this.addPrincipal(principal);
} catch (e) {
// newURI will throw for add-ons logins stored in chrome:// URIs
Expand Down
4 changes: 2 additions & 2 deletions browser/components/preferences/permissions.js
Original file line number Diff line number Diff line change
Expand Up @@ -95,12 +95,12 @@ var gPermissionManager = {
let uri;
try {
uri = Services.io.newURI(input_url, null, null);
principal = Services.scriptSecurityManager.createCodebasePrincipal(uri, {});
principal = Services.scriptSecurityManager.getNoAppCodebasePrincipal(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.createCodebasePrincipal(uri, {});
principal = Services.scriptSecurityManager.getNoAppCodebasePrincipal(uri);
// If we have ended up with an unknown scheme, the following will throw.
principal.origin;
}
Expand Down
6 changes: 2 additions & 4 deletions browser/components/preferences/tests/browser_permissions.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,10 +8,8 @@ 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.createCodebasePrincipal(TEST_URI_1, {});
const TEST_PRINCIPAL_2 =
Services.scriptSecurityManager.createCodebasePrincipal(TEST_URI_2, {});
const TEST_PRINCIPAL_1 = Services.scriptSecurityManager.getNoAppCodebasePrincipal(TEST_URI_1);
const TEST_PRINCIPAL_2 = Services.scriptSecurityManager.getNoAppCodebasePrincipal(TEST_URI_2);

// values from DefaultPermissions object
const PERM_UNKNOWN = 0;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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);
let ssm = Components.classes["@mozilla.org/scriptsecuritymanager;1"]
.getService(Ci.nsIScriptSecurityManager);
const XUL_PRINCIPAL = ssm.createCodebasePrincipal(XUL_URI, {});
const XUL_PRINCIPAL = Components.classes["@mozilla.org/scriptsecuritymanager;1"]
.getService(Ci.nsIScriptSecurityManager)
.getNoAppCodebasePrincipal(XUL_URI);

add_task(function*() {
info("Checking stylesheets on HTML document");
Expand Down
17 changes: 5 additions & 12 deletions browser/extensions/pdfjs/content/PdfStreamConverter.jsm
Original file line number Diff line number Diff line change
Expand Up @@ -995,21 +995,14 @@ PdfStreamConverter.prototype = {

// We can use resource principal when data is fetched by the chrome
// e.g. useful for NoScript
var ssm = Cc['@mozilla.org/scriptsecuritymanager;1']
.getService(Ci.nsIScriptSecurityManager);
var securityManager = 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).
// 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);
}
var resourcePrincipal = 'getNoAppCodebasePrincipal' in securityManager ?
securityManager.getNoAppCodebasePrincipal(uri) :
securityManager.getCodebasePrincipal(uri);
aRequest.owner = resourcePrincipal;
channel.asyncOpen(proxy, aContext);
},
Expand Down
6 changes: 3 additions & 3 deletions browser/extensions/shumway/chrome/SpecialStorage.jsm
Original file line number Diff line number Diff line change
Expand Up @@ -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 ssm = Components.classes["@mozilla.org/scriptsecuritymanager;1"]
.getService(Components.interfaces.nsIScriptSecurityManager);
var principal = ssm.createCodebasePrincipal(uri, {});
var principal = Components.classes["@mozilla.org/scriptsecuritymanager;1"]
.getService(Components.interfaces.nsIScriptSecurityManager)
.getNoAppCodebasePrincipal(uri);
var dsm = Components.classes["@mozilla.org/dom/localStorage-manager;1"]
.getService(Components.interfaces.nsIDOMStorageManager);
var storage = dsm.createStorage(null, principal, privateBrowsing);
Expand Down
3 changes: 1 addition & 2 deletions browser/modules/Feeds.jsm
Original file line number Diff line number Diff line change
Expand Up @@ -66,8 +66,7 @@ this.Feeds = {
if (aIsFeed) {
// re-create the principal as it may be a CPOW.
let principalURI = BrowserUtils.makeURIFromCPOW(aPrincipal.URI);
let principalToCheck =
Services.scriptSecurityManager.createCodebasePrincipal(principalURI, {});
let principalToCheck = Services.scriptSecurityManager.getNoAppCodebasePrincipal(principalURI);
try {
BrowserUtils.urlSecurityCheck(aLink.href, principalToCheck,
Ci.nsIScriptSecurityManager.DISALLOW_INHERIT_PRINCIPAL);
Expand Down
14 changes: 5 additions & 9 deletions caps/nsIScriptSecurityManager.idl
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ class DomainPolicyClone;
[ptr] native JSObjectPtr(JSObject);
[ptr] native DomainPolicyClonePtr(mozilla::dom::DomainPolicyClone);

[scriptable, uuid(6e8a4d1e-d9c6-4d86-bf53-d73f58f36148)]
[scriptable, uuid(9a8f0b70-6b9f-4e19-8885-7cfe24f4a42d)]
interface nsIScriptSecurityManager : nsISupports
{
/**
Expand Down Expand Up @@ -150,12 +150,10 @@ interface nsIScriptSecurityManager : nsISupports
* @param appId is the app id of the principal. It can't be UNKNOWN_APP_ID.
* @param inMozBrowser is true if the principal has to be considered as
* inside a mozbrowser frame.
*
* @deprecated use createCodebasePrincipal instead.
*/
[deprecated] nsIPrincipal getAppCodebasePrincipal(in nsIURI uri,
in unsigned long appId,
in boolean inMozBrowser);
nsIPrincipal getAppCodebasePrincipal(in nsIURI uri,
in unsigned long appId,
in boolean inMozBrowser);

/**
* Returns a principal that has the appId and inMozBrowser of the load
Expand All @@ -177,10 +175,8 @@ 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.
*/
[deprecated] nsIPrincipal getNoAppCodebasePrincipal(in nsIURI uri);
nsIPrincipal getNoAppCodebasePrincipal(in nsIURI uri);

/**
* Legacy method for getting a principal with no origin attributes.
Expand Down
18 changes: 9 additions & 9 deletions docshell/base/nsDocShell.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,6 @@
#include "mozilla/ArrayUtils.h"
#include "mozilla/Attributes.h"
#include "mozilla/AutoRestore.h"
#include "mozilla/BasePrincipal.h"
#include "mozilla/Casting.h"
#include "mozilla/dom/ContentChild.h"
#include "mozilla/dom/Element.h"
Expand Down Expand Up @@ -9361,21 +9360,22 @@ nsDocShell::CreatePrincipalFromReferrer(nsIURI* aReferrer,
nsIPrincipal** aResult)
{
nsresult rv;
nsCOMPtr<nsIScriptSecurityManager> secMan =
do_GetService(NS_SCRIPTSECURITYMANAGER_CONTRACTID, &rv);
NS_ENSURE_SUCCESS(rv, rv);

uint32_t appId;
rv = GetAppId(&appId);
NS_ENSURE_SUCCESS(rv, rv);
bool isInBrowserElement;
rv = GetIsInBrowserElement(&isInBrowserElement);
NS_ENSURE_SUCCESS(rv, rv);

// TODO: Bug 1165466 - Pass mOriginAttributes directly.
OriginAttributes attrs(appId, isInBrowserElement);
nsCOMPtr<nsIPrincipal> prin =
BasePrincipal::CreateCodebasePrincipal(aReferrer, attrs);
prin.forget(aResult);

return *aResult ? NS_OK : NS_ERROR_FAILURE;
rv = secMan->GetAppCodebasePrincipal(aReferrer,
appId,
isInBrowserElement,
aResult);
NS_ENSURE_SUCCESS(rv, rv);
return NS_OK;
}

NS_IMETHODIMP
Expand Down
6 changes: 4 additions & 2 deletions dom/apps/AppsUtils.jsm
Original file line number Diff line number Diff line change
Expand Up @@ -73,9 +73,11 @@ mozIApplication.prototype = {
this._principal = null;

try {
this._principal = Services.scriptSecurityManager.createCodebasePrincipal(
this._principal = Services.scriptSecurityManager.getAppCodebasePrincipal(
Services.io.newURI(this.origin, null, null),
{appId: this.localId});
this.localId,
false /* mozbrowser */
);
} catch(e) {
dump("Could not create app principal " + e + "\n");
}
Expand Down
4 changes: 2 additions & 2 deletions dom/apps/OfflineCacheInstaller.jsm
Original file line number Diff line number Diff line change
Expand Up @@ -228,8 +228,8 @@ function installCache(app) {
if (!cacheManifest.exists())
return;

let principal =
Services.scriptSecurityManager.createCodebasePrincipal(app.origin, {appId: aApp.localId});
let principal = Services.scriptSecurityManager.getAppCodebasePrincipal(
app.origin, app.localId, false);

// If the build has been correctly configured, this should not happen!
// If we install the cache anyway, it won't be updateable. If we don't install
Expand Down
2 changes: 1 addition & 1 deletion dom/apps/ScriptPreloader.jsm
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ this.ScriptPreloader = {
let toLoad = aManifest.precompile.length;
let principal =
Services.scriptSecurityManager
.createCodebasePrincipal(origin, {appId: aApp.localId});
.getAppCodebasePrincipal(origin, aApp.localId, false);

aManifest.precompile.forEach((aPath) => {
let uri = Services.io.newURI(aPath, null, origin);
Expand Down
8 changes: 4 additions & 4 deletions dom/apps/Webapps.jsm
Original file line number Diff line number Diff line change
Expand Up @@ -820,7 +820,8 @@ this.DOMApplicationRegistry = {
let uri = Services.io.newURI(aOrigin, null, null);
let secMan = Cc["@mozilla.org/scriptsecuritymanager;1"]
.getService(Ci.nsIScriptSecurityManager);
let principal = secMan.createCodebasePrincipal(uri, {appId: aId});
let principal = secMan.getAppCodebasePrincipal(uri, aId,
/*mozbrowser*/ false);
if (!dataStoreService.checkPermission(principal)) {
return;
}
Expand Down Expand Up @@ -3368,9 +3369,8 @@ this.DOMApplicationRegistry = {
let requestChannel;

let appURI = NetUtil.newURI(aNewApp.origin, null, null);
let principal =
Services.scriptSecurityManager.createCodebasePrincipal(appURI,
{appId: aNewApp.localId});
let principal = Services.scriptSecurityManager.getAppCodebasePrincipal(
appURI, aNewApp.localId, false);

if (aIsLocalFileInstall) {
requestChannel = NetUtil.newChannel({
Expand Down
Loading

0 comments on commit 76df031

Please sign in to comment.