diff --git a/dom/ipc/PWindowGlobal.ipdl b/dom/ipc/PWindowGlobal.ipdl index d396c451d792..3ce59fbc5750 100644 --- a/dom/ipc/PWindowGlobal.ipdl +++ b/dom/ipc/PWindowGlobal.ipdl @@ -76,9 +76,9 @@ child: uint32_t aFlags) returns (PaintFragment retval); /** - * Returns the serialized security info associated with this window. + * Returns the security info associated with this window. */ - async GetSecurityInfo() returns(nsCString? serializedSecInfo); + async GetSecurityInfo() returns(nsITransportSecurityInfo securityInfo); async DispatchSecurityPolicyViolation(nsString aViolationEventJSON); diff --git a/dom/ipc/WindowGlobalChild.cpp b/dom/ipc/WindowGlobalChild.cpp index cfd03acd6ec8..895ebe4a215b 100644 --- a/dom/ipc/WindowGlobalChild.cpp +++ b/dom/ipc/WindowGlobalChild.cpp @@ -444,31 +444,31 @@ mozilla::ipc::IPCResult WindowGlobalChild::RecvDrawSnapshot( mozilla::ipc::IPCResult WindowGlobalChild::RecvGetSecurityInfo( GetSecurityInfoResolver&& aResolve) { - Maybe result; + nsCOMPtr securityInfo; + auto callResolve = + MakeScopeExit([aResolve, &securityInfo]() { aResolve(securityInfo); }); - if (nsCOMPtr doc = mWindowGlobal->GetDoc()) { - nsCOMPtr secInfo; - nsresult rv = NS_OK; - - // First check if there's a failed channel, in case of a certificate - // error. - if (nsIChannel* failedChannel = doc->GetFailedChannel()) { - rv = failedChannel->GetSecurityInfo(getter_AddRefs(secInfo)); - } else { - // When there's no failed channel we should have a regular - // security info on the document. In some cases there's no - // security info at all, i.e. on HTTP sites. - secInfo = doc->GetSecurityInfo(); - } - - if (NS_SUCCEEDED(rv) && secInfo) { - nsCOMPtr secInfoSer = do_QueryInterface(secInfo); - result.emplace(); - NS_SerializeToString(secInfoSer, result.ref()); - } + nsCOMPtr doc = mWindowGlobal->GetDoc(); + if (!doc) { + return IPC_OK(); } - aResolve(result); + nsCOMPtr securityInfoSupports; + // First check if there's a failed channel, in case of a certificate + // error. + if (nsIChannel* failedChannel = doc->GetFailedChannel()) { + nsresult rv = + failedChannel->GetSecurityInfo(getter_AddRefs(securityInfoSupports)); + if (NS_WARN_IF(NS_FAILED(rv))) { + return IPC_OK(); + } + } else { + // When there's no failed channel we should have a regular + // security info on the document. In some cases there's no + // security info at all, i.e. on HTTP sites. + securityInfoSupports = doc->GetSecurityInfo(); + } + securityInfo = do_QueryInterface(securityInfoSupports); return IPC_OK(); } diff --git a/dom/ipc/WindowGlobalParent.cpp b/dom/ipc/WindowGlobalParent.cpp index 5ed5e49939ce..817b307305e0 100644 --- a/dom/ipc/WindowGlobalParent.cpp +++ b/dom/ipc/WindowGlobalParent.cpp @@ -987,19 +987,9 @@ already_AddRefed WindowGlobalParent::GetSecurityInfo( } SendGetSecurityInfo( - [promise](Maybe&& aResult) { - if (aResult) { - nsCOMPtr infoObj; - nsresult rv = - NS_DeserializeObject(aResult.value(), getter_AddRefs(infoObj)); - if (NS_WARN_IF(NS_FAILED(rv))) { - promise->MaybeReject(NS_ERROR_FAILURE); - } - nsCOMPtr info = do_QueryInterface(infoObj); - if (!info) { - promise->MaybeReject(NS_ERROR_FAILURE); - } - promise->MaybeResolve(info); + [promise](const nsCOMPtr& aSecurityInfo) { + if (aSecurityInfo) { + promise->MaybeResolve(aSecurityInfo); } else { promise->MaybeResolveWithUndefined(); }