Backed out changeset 18eeafedd180 (bug 952192) XPC Shell Bustage on a CLOSED TREE

This commit is contained in:
Carsten "Tomcat" Book 2014-01-09 12:53:22 +01:00
parent 3677c93ff5
commit c87090db07
6 changed files with 26 additions and 17 deletions

View File

@ -11,7 +11,7 @@ interface nsIChannel;
interface nsIDocShell;
interface nsIDomainPolicy;
[scriptable, uuid(712aa338-50a1-497b-be6f-dc3d97867c01)]
[scriptable, uuid(2911ae60-1b5f-47e6-941e-1bb7b53a167d)]
interface nsIScriptSecurityManager : nsIXPCSecurityManager
{
///////////////// Security Checks //////////////////
@ -160,10 +160,12 @@ interface nsIScriptSecurityManager : nsIXPCSecurityManager
*/
[deprecated] nsIPrincipal getCodebasePrincipal(in nsIURI uri);
///////////////////////
/**
* Return the principal of the specified object in the specified context.
*/
[implicit_jscontext] nsIPrincipal getObjectPrincipal(in jsval aObject);
[noscript] nsIPrincipal getObjectPrincipal(in JSContextPtr cx,
in JSObjectPtr obj);
/**
* Returns true if the principal of the currently running script is the

View File

@ -1487,14 +1487,14 @@ nsScriptSecurityManager::GetSubjectPrincipal(JSContext *cx,
}
NS_IMETHODIMP
nsScriptSecurityManager::GetObjectPrincipal(const JS::Value &aObjectVal,
JSContext *aCx,
nsScriptSecurityManager::GetObjectPrincipal(JSContext *aCx, JSObject *aObj,
nsIPrincipal **result)
{
NS_ENSURE_TRUE(aObjectVal.isObject(), NS_ERROR_FAILURE);
JS::RootedObject obj(aCx, &aObjectVal.toObject());
nsCOMPtr<nsIPrincipal> principal = doGetObjectPrincipal(obj);
principal.forget(result);
JS::Rooted<JSObject*> obj(aCx, aObj);
*result = doGetObjectPrincipal(obj);
if (!*result)
return NS_ERROR_FAILURE;
NS_ADDREF(*result);
return NS_OK;
}

View File

@ -258,8 +258,15 @@ mozJSSubScriptLoader::DoLoadSubScriptWithOptions(const nsAString& url,
if (!targetObj)
return NS_ERROR_FAILURE;
if (targetObj != result_obj)
principal = GetObjectPrincipal(targetObj);
if (targetObj != result_obj) {
nsCOMPtr<nsIScriptSecurityManager> secman =
do_GetService(NS_SCRIPTSECURITYMANAGER_CONTRACTID);
if (!secman)
return NS_ERROR_FAILURE;
rv = secman->GetObjectPrincipal(cx, targetObj, getter_AddRefs(principal));
NS_ENSURE_SUCCESS(rv, rv);
}
JSAutoCompartment ac(cx, targetObj);

View File

@ -652,9 +652,14 @@ nsXPCWrappedJSClass::DelegatedQueryInterface(nsXPCWrappedJS* self,
return NS_NOINTERFACE;
RootedObject selfObj(ccx, self->GetJSObject());
nsCOMPtr<nsIPrincipal> objPrin = GetObjectPrincipal(selfObj);
nsCOMPtr<nsIPrincipal> objPrin;
nsresult rv = secMan->GetObjectPrincipal(ccx, selfObj,
getter_AddRefs(objPrin));
if (NS_FAILED(rv))
return rv;
bool isSystem;
nsresult rv = secMan->IsSystemPrincipal(objPrin, &isSystem);
rv = secMan->IsSystemPrincipal(objPrin, &isSystem);
if ((NS_FAILED(rv) || !isSystem) && !IS_WN_REFLECTOR(selfObj)) {
// A content object.
nsRefPtr<SameOriginCheckedComponent> checked =

View File

@ -1,4 +0,0 @@
function run_test() {
var secMan = Cc["@mozilla.org/scriptsecuritymanager;1"].getService(Ci.nsIScriptSecurityManager);
do_check_true(secMan.isSystemPrincipal(secMan.getObjectPrincipal({})));
}

View File

@ -73,7 +73,6 @@ fail-if = os == "android"
[test_sandbox_atob.js]
[test_isProxy.js]
[test_watchdog_enable.js]
[test_getObjectPrincipal.js]
head = head_watchdog.js
[test_watchdog_disable.js]
head = head_watchdog.js