Merge mozilla-central into mozilla-inbound

This commit is contained in:
Ehsan Akhgari 2013-01-08 14:59:20 -05:00
commit f33d8a82ee
12 changed files with 133 additions and 16 deletions

View File

@ -107,7 +107,7 @@ public class DoCommand {
String ffxProvider = "org.mozilla.ffxcp";
String fenProvider = "org.mozilla.fencp";
private final String prgVersion = "SUTAgentAndroid Version 1.15";
private final String prgVersion = "SUTAgentAndroid Version 1.16";
public enum Command
{
@ -3414,7 +3414,7 @@ private void CancelNotification()
else
prgIntent.setAction(Intent.ACTION_MAIN);
if (sArgs[0].contains("fennec"))
if (sArgs[0].contains("fennec") || sArgs[0].contains("firefox"))
{
sArgList = "";
sUrl = "";

View File

@ -144,7 +144,7 @@ NS_CP_ContentTypeName(uint32_t contentType)
*
* Note: requestOrigin is scoped outside the PR_BEGIN_MACRO/PR_END_MACRO on
* purpose */
#define CHECK_PRINCIPAL \
#define CHECK_PRINCIPAL_AND_DATA(action) \
nsCOMPtr<nsIURI> requestOrigin; \
PR_BEGIN_MACRO \
if (originPrincipal) { \
@ -153,12 +153,32 @@ NS_CP_ContentTypeName(uint32_t contentType)
secMan = do_GetService(NS_SCRIPTSECURITYMANAGER_CONTRACTID); \
} \
if (secMan) { \
bool isSystem; \
bool isSystem; \
nsresult rv = secMan->IsSystemPrincipal(originPrincipal, \
&isSystem); \
NS_ENSURE_SUCCESS(rv, rv); \
if (isSystem) { \
*decision = nsIContentPolicy::ACCEPT; \
nsCOMPtr<nsINode> n = do_QueryInterface(context); \
if (!n) { \
nsCOMPtr<nsPIDOMWindow> win = do_QueryInterface(context); \
n = win ? win->GetExtantDoc() : nullptr; \
} \
if (n) { \
nsIDocument* d = n->OwnerDoc(); \
if (d->IsLoadedAsData() || d->IsBeingUsedAsImage() || \
d->IsResourceDoc()) { \
nsCOMPtr<nsIContentPolicy> dataPolicy = \
do_GetService( \
"@mozilla.org/data-document-content-policy;1"); \
if (dataPolicy) { \
dataPolicy-> action (contentType, contentLocation, \
requestOrigin, context, \
mimeType, extra, \
originPrincipal, decision); \
} \
} \
} \
return NS_OK; \
} \
} \
@ -187,7 +207,7 @@ NS_CheckContentLoadPolicy(uint32_t contentType,
nsIContentPolicy *policyService = nullptr,
nsIScriptSecurityManager* aSecMan = nullptr)
{
CHECK_PRINCIPAL;
CHECK_PRINCIPAL_AND_DATA(ShouldLoad);
if (policyService) {
CHECK_CONTENT_POLICY_WITH_SERVICE(ShouldLoad, policyService);
}
@ -214,7 +234,7 @@ NS_CheckContentProcessPolicy(uint32_t contentType,
nsIContentPolicy *policyService = nullptr,
nsIScriptSecurityManager* aSecMan = nullptr)
{
CHECK_PRINCIPAL;
CHECK_PRINCIPAL_AND_DATA(ShouldProcess);
if (policyService) {
CHECK_CONTENT_POLICY_WITH_SERVICE(ShouldProcess, policyService);
}

View File

@ -30,6 +30,9 @@ HasFlags(nsIURI* aURI, uint32_t aURIFlags)
return NS_SUCCEEDED(rv) && hasFlags;
}
// If you change DataDocumentContentPolicy, make sure to check that
// CHECK_PRINCIPAL_AND_DATA in nsContentPolicyUtils is still valid.
// nsContentPolicyUtils may not pass all the parameters to ShouldLoad.
NS_IMETHODIMP
nsDataDocumentContentPolicy::ShouldLoad(uint32_t aContentType,
nsIURI *aContentLocation,
@ -123,6 +126,10 @@ nsDataDocumentContentPolicy::ShouldLoad(uint32_t aContentType,
*aDecision = nsIContentPolicy::REJECT_TYPE;
}
// If you add more restrictions here, make sure to check that
// CHECK_PRINCIPAL_AND_DATA in nsContentPolicyUtils is still valid.
// nsContentPolicyUtils may not pass all the parameters to ShouldLoad
return NS_OK;
}

View File

@ -8672,6 +8672,8 @@ nsDocShell::InternalLoad(nsIURI * aURI,
return NS_ERROR_FAILURE;
}
NS_ENSURE_STATE(!HasUnloadedParent());
rv = CheckLoadingPermissions();
if (NS_FAILED(rv)) {
return rv;
@ -12461,3 +12463,23 @@ nsDocShell::GetAsyncPanZoomEnabled(bool* aOut)
*aOut = false;
return NS_OK;
}
bool
nsDocShell::HasUnloadedParent()
{
nsCOMPtr<nsIDocShellTreeItem> currentTreeItem = this;
while (currentTreeItem) {
nsCOMPtr<nsIDocShellTreeItem> parentTreeItem;
currentTreeItem->GetParent(getter_AddRefs(parentTreeItem));
nsCOMPtr<nsIDocShell> parent = do_QueryInterface(parentTreeItem);
if (parent) {
bool inUnload = false;
parent->GetIsInUnload(&inUnload);
if (inUnload) {
return true;
}
}
currentTreeItem.swap(parentTreeItem);
}
return false;
}

View File

@ -675,6 +675,8 @@ protected:
FrameType GetInheritedFrameType();
bool HasUnloadedParent();
// hash of session storages, keyed by domain
nsInterfaceHashtable<nsCStringHashKey, nsIDOMStorage> mStorages;

View File

@ -389,6 +389,14 @@ CTypesActivityCallback(JSContext* aCx,
worker->EndCTypesCall();
break;
case js::CTYPES_CALLBACK_BEGIN:
worker->BeginCTypesCallback();
break;
case js::CTYPES_CALLBACK_END:
worker->EndCTypesCallback();
break;
default:
MOZ_NOT_REACHED("Unknown type flag!");
}
@ -434,7 +442,7 @@ CreateJSContextForWorker(WorkerPrivate* aWorkerPrivate)
return nullptr;
}
JS_SetContextPrivate(workerCx, aWorkerPrivate);
JS_SetRuntimePrivate(runtime, aWorkerPrivate);
JS_SetErrorReporter(workerCx, ErrorReporter);

View File

@ -4200,7 +4200,7 @@ WorkerPrivate*
GetWorkerPrivateFromContext(JSContext* aCx)
{
NS_ASSERTION(!NS_IsMainThread(), "Wrong thread!");
return static_cast<WorkerPrivate*>(JS_GetContextPrivate(aCx));
return static_cast<WorkerPrivate*>(JS_GetRuntimePrivate(JS_GetRuntime(aCx)));
}
JSStructuredCloneCallbacks*

View File

@ -771,6 +771,22 @@ public:
void
EndCTypesCall();
void
BeginCTypesCallback()
{
// If a callback is beginning then we need to do the exact same thing as
// when a ctypes call ends.
EndCTypesCall();
}
void
EndCTypesCallback()
{
// If a callback is ending then we need to do the exact same thing as
// when a ctypes call begins.
BeginCTypesCall();
}
private:
WorkerPrivate(JSContext* aCx, JSObject* aObject, WorkerPrivate* aParent,
JSContext* aParentJSContext, const nsAString& aScriptURL,

View File

@ -5790,9 +5790,7 @@ FunctionType::Call(JSContext* cx,
}
// Let the runtime callback know that we are about to call into C.
js::CTypesActivityCallback activityCallback = cx->runtime->ctypesActivityCallback;
if (activityCallback)
activityCallback(cx, js::CTYPES_CALL_BEGIN);
js::AutoCTypesActivityCallback autoCallback(cx, js::CTYPES_CALL_BEGIN, js::CTYPES_CALL_END);
uintptr_t fn = *reinterpret_cast<uintptr_t*>(CData::GetData(obj));
@ -5821,8 +5819,8 @@ FunctionType::Call(JSContext* cx,
errno = savedErrno;
if (activityCallback)
activityCallback(cx, js::CTYPES_CALL_END);
// We're no longer calling into C.
autoCallback.DoEndCallback();
// Store the error value for later consultation with |ctypes.getStatus|
JSObject *objCTypes = CType::GetGlobalCTypes(cx, typeObj);
@ -6105,6 +6103,12 @@ CClosure::ClosureStub(ffi_cif* cif, void* result, void** args, void* userData)
// Retrieve the essentials from our closure object.
ClosureInfo* cinfo = static_cast<ClosureInfo*>(userData);
JSContext* cx = cinfo->cx;
// Let the runtime callback know that we are about to call into JS again. The end callback will
// fire automatically when we exit this function.
js::AutoCTypesActivityCallback autoCallback(cx, js::CTYPES_CALLBACK_BEGIN,
js::CTYPES_CALLBACK_END);
RootedObject typeObj(cx, cinfo->typeObj);
RootedObject thisObj(cx, cinfo->thisObj);
RootedObject jsfnObj(cx, cinfo->jsfnObj);

View File

@ -990,3 +990,15 @@ js::SetCTypesActivityCallback(JSRuntime *rt, CTypesActivityCallback cb)
{
rt->ctypesActivityCallback = cb;
}
js::AutoCTypesActivityCallback::AutoCTypesActivityCallback(JSContext *cx,
js::CTypesActivityType beginType,
js::CTypesActivityType endType
MOZ_GUARD_OBJECT_NOTIFIER_PARAM_IN_IMPL)
: cx(cx), callback(cx->runtime->ctypesActivityCallback), beginType(beginType), endType(endType)
{
MOZ_GUARD_OBJECT_NOTIFIER_INIT;
if (callback)
callback(cx, beginType);
}

View File

@ -1569,7 +1569,9 @@ IsTypedArrayThisCheck(JS::IsAcceptableThis test);
enum CTypesActivityType {
CTYPES_CALL_BEGIN,
CTYPES_CALL_END
CTYPES_CALL_END,
CTYPES_CALLBACK_BEGIN,
CTYPES_CALLBACK_END
};
typedef void
@ -1582,6 +1584,29 @@ typedef void
JS_FRIEND_API(void)
SetCTypesActivityCallback(JSRuntime *rt, CTypesActivityCallback cb);
class JS_FRIEND_API(AutoCTypesActivityCallback) {
private:
JSContext *cx;
CTypesActivityCallback callback;
CTypesActivityType beginType;
CTypesActivityType endType;
MOZ_DECL_USE_GUARD_OBJECT_NOTIFIER
public:
AutoCTypesActivityCallback(JSContext *cx, CTypesActivityType beginType,
CTypesActivityType endType
MOZ_GUARD_OBJECT_NOTIFIER_PARAM);
~AutoCTypesActivityCallback() {
DoEndCallback();
}
void DoEndCallback() {
if (callback) {
callback(cx, endType);
callback = NULL;
}
}
};
} /* namespace js */
#endif /* jsfriendapi_h___ */

View File

@ -431,11 +431,12 @@ CanSkipWrappedJS(nsXPCWrappedJS *wrappedJS)
// If traversing wrappedJS wouldn't release it, nor
// cause any other objects to be added to the graph, no
// need to add it to the graph at all.
bool isRootWrappedJS = wrappedJS->GetRootWrapper() == wrappedJS;
if (nsCCUncollectableMarker::sGeneration &&
(!obj || !xpc_IsGrayGCThing(obj)) &&
!wrappedJS->IsSubjectToFinalization() &&
wrappedJS->GetRootWrapper() == wrappedJS) {
if (!wrappedJS->IsAggregatedToNative()) {
(isRootWrappedJS || CanSkipWrappedJS(wrappedJS->GetRootWrapper()))) {
if (!wrappedJS->IsAggregatedToNative() || !isRootWrappedJS) {
return true;
} else {
nsISupports* agg = wrappedJS->GetAggregatedNativeObject();