Backed out changeset 1778ca2ab291 (bug 1744425) for bc failures on browser_xpcom_graph_wait.js. CLOSED TREE

This commit is contained in:
Cosmin Sabou
2021-12-08 07:20:54 +02:00
parent 13c1674214
commit c26566def8
23 changed files with 88 additions and 31 deletions

View File

@@ -368,7 +368,7 @@ already_AddRefed<BrowsingContext> BrowsingContext::CreateDetached(
nsILoadInfo::OPENER_POLICY_SAME_ORIGIN_ALLOW_POPUPS);
}
fields.mHistoryID = nsID::GenerateUUID();
nsContentUtils::GenerateUUIDInPlace(fields.mHistoryID);
fields.mExplicitActive = [&] {
if (parentBC) {
// Non-root browsing-contexts inherit their status from its parent.

View File

@@ -89,7 +89,8 @@ nsID ChildSHistory::AddPendingHistoryChange() {
nsID ChildSHistory::AddPendingHistoryChange(int32_t aIndexDelta,
int32_t aLengthDelta) {
nsID changeID = nsID::GenerateUUID();
nsID changeID = {};
nsContentUtils::GenerateUUIDInPlace(changeID);
PendingSHistoryChange change = {changeID, aIndexDelta, aLengthDelta};
mPendingSHistoryChanges.AppendElement(change);
return changeID;

View File

@@ -203,7 +203,7 @@ DocGroup::DocGroup(BrowsingContextGroup* aBrowsingContextGroup,
const nsACString& aKey)
: mKey(aKey),
mBrowsingContextGroup(aBrowsingContextGroup),
mAgentClusterId(nsID::GenerateUUID()) {
mAgentClusterId(nsContentUtils::GenerateUUID()) {
// This method does not add itself to
// mBrowsingContextGroup->mDocGroups as the caller does it for us.
MOZ_ASSERT(NS_IsMainThread());

View File

@@ -268,6 +268,7 @@
#include "nsIContentSecurityPolicy.h"
#include "nsIContentSink.h"
#include "nsIContentViewer.h"
#include "nsID.h"
#include "nsIDOMWindowUtils.h"
#include "nsIDocShell.h"
#include "nsIDocShellTreeItem.h"
@@ -325,6 +326,7 @@
#if defined(MOZ_THUNDERBIRD) || defined(MOZ_SUITE)
# include "nsIURIWithSpecialOrigin.h"
#endif
#include "nsIUUIDGenerator.h"
#include "nsIUserIdleService.h"
#include "nsIWeakReferenceUtils.h"
#include "nsIWebNavigation.h"
@@ -413,6 +415,7 @@ nsIScriptSecurityManager* nsContentUtils::sSecurityManager;
nsIPrincipal* nsContentUtils::sSystemPrincipal;
nsIPrincipal* nsContentUtils::sNullSubjectPrincipal;
nsIIOService* nsContentUtils::sIOService;
nsIUUIDGenerator* nsContentUtils::sUUIDGenerator;
nsIConsoleService* nsContentUtils::sConsoleService;
nsTHashMap<nsRefPtrHashKey<nsAtom>, EventNameMapping>*
nsContentUtils::sAtomEventTable = nullptr;
@@ -792,6 +795,13 @@ nsresult nsContentUtils::Init() {
Unused << nsRFPService::GetOrCreate();
nsCOMPtr<nsIUUIDGenerator> uuidGenerator =
do_GetService("@mozilla.org/uuid-generator;1", &rv);
if (NS_WARN_IF(NS_FAILED(rv))) {
return rv;
}
uuidGenerator.forget(&sUUIDGenerator);
if (XRE_IsParentProcess()) {
AsyncPrecreateStringBundles();
}
@@ -1860,7 +1870,7 @@ void nsContentUtils::Shutdown() {
NS_IF_RELEASE(sSystemPrincipal);
NS_IF_RELEASE(sNullSubjectPrincipal);
NS_IF_RELEASE(sIOService);
NS_IF_RELEASE(sUUIDGenerator);
sBidiKeyboard = nullptr;
delete sAtomEventTable;
@@ -7312,6 +7322,27 @@ bool nsContentUtils::IsJavascriptMIMEType(const nsAString& aMIMEType) {
return false;
}
nsresult nsContentUtils::GenerateUUIDInPlace(nsID& aUUID) {
MOZ_ASSERT(sUUIDGenerator);
nsresult rv = sUUIDGenerator->GenerateUUIDInPlace(&aUUID);
if (NS_WARN_IF(NS_FAILED(rv))) {
return rv;
}
return NS_OK;
}
nsID nsContentUtils::GenerateUUID() {
MOZ_DIAGNOSTIC_ASSERT(sUUIDGenerator);
nsID uuid;
nsresult rv = sUUIDGenerator->GenerateUUIDInPlace(&uuid);
MOZ_RELEASE_ASSERT(NS_SUCCEEDED(rv));
return uuid;
}
bool nsContentUtils::PrefetchPreloadEnabled(nsIDocShell* aDocShell) {
//
// SECURITY CHECK: disable prefetching and preloading from mailnews!

View File

@@ -44,6 +44,7 @@
#include "nsCOMPtr.h"
#include "nsHashtablesFwd.h"
#include "nsIContentPolicy.h"
#include "nsID.h"
#include "nsINode.h"
#include "nsIScriptError.h"
#include "nsIThread.h"
@@ -109,6 +110,7 @@ class nsIStringBundleService;
class nsISupports;
class nsITransferable;
class nsIURI;
class nsIUUIDGenerator;
class nsIWidget;
class nsIXPConnect;
class nsNodeInfoManager;
@@ -1225,6 +1227,16 @@ class nsContentUtils {
*/
static void SandboxFlagsToString(uint32_t aFlags, nsAString& aString);
/**
* Helper function that generates a UUID.
*/
static nsresult GenerateUUIDInPlace(nsID& aUUID);
/**
* Infallable (with an assertion) helper function that generates a UUID.
*/
static nsID GenerateUUID();
static bool PrefetchPreloadEnabled(nsIDocShell* aDocShell);
static void ExtractErrorValues(JSContext* aCx, JS::Handle<JS::Value> aValue,
@@ -3331,6 +3343,7 @@ class nsContentUtils {
static nsIPrincipal* sNullSubjectPrincipal;
static nsIIOService* sIOService;
static nsIUUIDGenerator* sUUIDGenerator;
static nsIConsoleService* sConsoleService;

View File

@@ -23,6 +23,7 @@
#include "mozilla/ipc/BackgroundUtils.h"
#include "mozilla/ipc/PBackgroundChild.h"
#include "mozilla/StorageAccess.h"
#include "nsContentUtils.h"
#include "nsICookieJarSettings.h"
#include "mozilla/dom/Document.h"
@@ -149,7 +150,7 @@ already_AddRefed<BroadcastChannel> BroadcastChannel::Constructor(
}
nsID portUUID = {};
aRv = nsID::GenerateUUIDInPlace(portUUID);
aRv = nsContentUtils::GenerateUUIDInPlace(portUUID);
if (aRv.Failed()) {
return nullptr;
}

View File

@@ -15,6 +15,7 @@
#include "mozilla/ipc/PBackgroundChild.h"
#include "mozilla/ClearOnShutdown.h" // PastShutdownPhase
#include "mozilla/StaticPrefs_dom.h"
#include "nsContentUtils.h"
#include "prthread.h"
namespace mozilla::dom {
@@ -105,7 +106,7 @@ UniquePtr<ClientSource> ClientManager::CreateSourceInternal(
NS_ASSERT_OWNINGTHREAD(ClientManager);
nsID id;
nsresult rv = nsID::GenerateUUIDInPlace(id);
nsresult rv = nsContentUtils::GenerateUUIDInPlace(id);
MOZ_DIAGNOSTIC_ASSERT(NS_SUCCEEDED(rv));
if (NS_WARN_IF(NS_FAILED(rv))) {
// If we can't even get a UUID, at least make sure not to use a garbage
@@ -338,7 +339,7 @@ Maybe<ClientInfo> ClientManager::CreateInfo(ClientType aType,
}
nsID id;
rv = nsID::GenerateUUIDInPlace(id);
rv = nsContentUtils::GenerateUUIDInPlace(id);
MOZ_DIAGNOSTIC_ASSERT(NS_SUCCEEDED(rv));
if (NS_WARN_IF(NS_FAILED(rv))) {
return Nothing();

View File

@@ -46,7 +46,7 @@ ParentToParentStream ToParentToParentStream(
MOZ_ASSERT(XRE_IsParentProcess());
ParentToParentStream stream;
stream.uuid() = nsID::GenerateUUID();
MOZ_ALWAYS_SUCCEEDS(nsContentUtils::GenerateUUIDInPlace(stream.uuid()));
GetRemoteLazyInputStreamStorage()->AddStream(aStream.get(), stream.uuid(),
aStreamSize, 0);
return stream;

View File

@@ -7,6 +7,7 @@
#include "RemoteLazyInputStreamParent.h"
#include "mozilla/ipc/IPCStreamUtils.h"
#include "mozilla/InputStreamLengthHelper.h"
#include "nsContentUtils.h"
#include "RemoteLazyInputStreamStorage.h"
namespace mozilla {
@@ -21,7 +22,7 @@ RemoteLazyInputStreamParent::CreateCommon(nsIInputStream* aInputStream,
MOZ_ASSERT(aRv);
nsID id;
*aRv = nsID::GenerateUUIDInPlace(id);
*aRv = nsContentUtils::GenerateUUIDInPlace(id);
if (NS_WARN_IF(NS_FAILED(*aRv))) {
return nullptr;
}

View File

@@ -14,6 +14,7 @@
#include "mozilla/dom/IPCBlobUtils.h"
#include "mozilla/ipc/IPCStreamUtils.h"
#include "FileSystemUtils.h"
#include "nsContentUtils.h"
#include "nsNetCID.h"
#include "nsProxyRelease.h"
@@ -447,7 +448,7 @@ void GetFilesHelperChild::Work(ErrorResult& aRv) {
return;
}
aRv = nsID::GenerateUUIDInPlace(mUUID);
aRv = nsContentUtils::GenerateUUIDInPlace(mUUID);
if (NS_WARN_IF(aRv.Failed())) {
return;
}

View File

@@ -7,6 +7,7 @@
#include "FileSystem.h"
#include "FileSystemRootDirectoryEntry.h"
#include "mozilla/dom/FileSystemBinding.h"
#include "nsContentUtils.h"
#include "nsIDUtils.h"
namespace mozilla::dom {
@@ -28,7 +29,7 @@ already_AddRefed<FileSystem> FileSystem::Create(nsIGlobalObject* aGlobalObject)
MOZ_ASSERT(aGlobalObject);
nsID id;
nsresult rv = nsID::GenerateUUIDInPlace(id);
nsresult rv = nsContentUtils::GenerateUUIDInPlace(id);
if (NS_WARN_IF(NS_FAILED(rv))) {
return nullptr;
}

View File

@@ -12,6 +12,7 @@
#include "mozilla/RefPtr.h"
#include "mozilla/dom/ipc/StructuredCloneData.h"
#include "nsBaseHashtable.h"
#include "nsContentUtils.h"
#include "nsDebug.h"
namespace mozilla::dom {
@@ -57,7 +58,7 @@ const nsID RefMessageBodyService::Register(
MOZ_ASSERT(body);
nsID uuid = {};
aRv = nsID::GenerateUUIDInPlace(uuid);
aRv = nsContentUtils::GenerateUUIDInPlace(uuid);
if (NS_WARN_IF(aRv.Failed())) {
return nsID();
}

View File

@@ -14,6 +14,7 @@
#include "MediaTrackConstraints.h"
#include "mozilla/Assertions.h"
#include "mozilla/ErrorNames.h"
#include "nsContentUtils.h"
#include "nsIDUtils.h"
#include "transport/runnable_utils.h"
#include "Tracing.h"
@@ -1112,7 +1113,7 @@ nsCString MediaEngineWebRTCAudioCaptureSource::GetUUID() const {
nsCString asciiString;
ErrorResult rv;
rv = nsID::GenerateUUIDInPlace(uuid);
rv = nsContentUtils::GenerateUUIDInPlace(uuid);
if (rv.Failed()) {
return ""_ns;
}

View File

@@ -10,6 +10,7 @@
#include "mozilla/dom/MessagePort.h"
#include "mozilla/dom/Navigator.h"
#include "mozilla/dom/WorkerRunnable.h"
#include "nsContentUtils.h"
#include "mozilla/dom/Document.h"
#include "nsIGlobalObject.h"
#include "nsServiceManagerUtils.h"
@@ -49,13 +50,13 @@ already_AddRefed<MessageChannel> MessageChannel::Constructor(
MOZ_ASSERT(aGlobal);
nsID portUUID1;
aRv = nsID::GenerateUUIDInPlace(portUUID1);
aRv = nsContentUtils::GenerateUUIDInPlace(portUUID1);
if (aRv.Failed()) {
return nullptr;
}
nsID portUUID2;
aRv = nsID::GenerateUUIDInPlace(portUUID2);
aRv = nsContentUtils::GenerateUUIDInPlace(portUUID2);
if (aRv.Failed()) {
return nullptr;
}

View File

@@ -654,7 +654,7 @@ already_AddRefed<PaymentRequest> PaymentRequest::CreatePaymentRequest(
nsPIDOMWindowInner* aWindow, ErrorResult& aRv) {
// Generate a unique id for identification
nsID uuid;
if (NS_WARN_IF(NS_FAILED(nsID::GenerateUUIDInPlace(uuid)))) {
if (NS_WARN_IF(NS_FAILED(nsContentUtils::GenerateUUIDInPlace(uuid)))) {
aRv.ThrowAbortError(
"Failed to create an internal UUID for the PaymentRequest");
return nullptr;

View File

@@ -11,6 +11,7 @@
#include "mozilla/dom/FetchTypes.h"
#include "mozilla/dom/ServiceWorkerOpArgs.h"
#include "nsCOMPtr.h"
#include "nsContentUtils.h"
#include "nsIInputStream.h"
#include "mozilla/Assertions.h"
@@ -49,7 +50,7 @@ nsresult MaybeDeserializeAndWrapForMainThread(
aSink = Some(ParentToParentStream());
auto& uuid = aSink->uuid();
MOZ_TRY(nsID::GenerateUUIDInPlace(uuid));
MOZ_TRY(nsContentUtils::GenerateUUIDInPlace(uuid));
auto storageOrErr = RemoteLazyInputStreamStorage::Get();

View File

@@ -819,8 +819,8 @@ nsresult MaybeStoreStreamForBackgroundThread(nsIInterceptedChannel* aChannel,
Maybe<BodyStreamVariant>& body = aIPCRequest.body();
body.emplace(ParentToParentStream());
MOZ_TRY(
nsID::GenerateUUIDInPlace(body->get_ParentToParentStream().uuid()));
MOZ_TRY(nsContentUtils::GenerateUUIDInPlace(
body->get_ParentToParentStream().uuid()));
auto storageOrErr = RemoteLazyInputStreamStorage::Get();
if (NS_WARN_IF(storageOrErr.isErr())) {

View File

@@ -13,6 +13,7 @@
#include "mozilla/dom/ServiceWorkerInfo.h"
#include "mozilla/dom/ServiceWorkerRegistrationBinding.h"
#include "mozilla/dom/ServiceWorkerRegistrationDescriptor.h"
#include "nsContentUtils.h"
#include "nsProxyRelease.h"
#include "nsTObserverArray.h"
@@ -38,7 +39,7 @@ class ServiceWorkerRegistrationInfo final
};
nsTArray<UniquePtr<VersionEntry>> mVersionList;
const nsID mAgentClusterId = nsID::GenerateUUID();
const nsID mAgentClusterId = nsContentUtils::GenerateUUID();
uint32_t mControlledClientsCounter;
uint32_t mDelayMultiplier;

View File

@@ -922,7 +922,7 @@ class CancelingRunnable final : public Runnable {
} /* anonymous namespace */
nsString ComputeWorkerPrivateId() {
nsID uuid = nsID::GenerateUUID();
nsID uuid = nsContentUtils::GenerateUUID();
return NSID_TrimBracketsUTF16(uuid);
}
@@ -2420,7 +2420,7 @@ WorkerPrivate::ComputeAgentClusterIdAndCoop(WorkerPrivate* aParent,
RefPtr<DocGroup> docGroup = doc->GetDocGroup();
nsID agentClusterId =
docGroup ? docGroup->AgentClusterId() : nsID::GenerateUUID();
docGroup ? docGroup->AgentClusterId() : nsContentUtils::GenerateUUID();
BrowsingContext* bc = aLoadInfo->mWindow->GetBrowsingContext();
MOZ_DIAGNOSTIC_ASSERT(bc);
@@ -2429,7 +2429,7 @@ WorkerPrivate::ComputeAgentClusterIdAndCoop(WorkerPrivate* aParent,
// If the window object was failed to be set into the WorkerLoadInfo, we
// make the worker into another agent cluster group instead of failures.
return {nsID::GenerateUUID(), agentClusterCoop};
return {nsContentUtils::GenerateUUID(), agentClusterCoop};
}
// static

View File

@@ -28,6 +28,7 @@
#include "mozilla/ipc/URIUtils.h"
#include "mozilla/net/CookieJarSettings.h"
#include "mozilla/StorageAccess.h"
#include "nsContentUtils.h"
#include "nsGlobalWindowInner.h"
#include "nsPIDOMWindow.h"
@@ -194,7 +195,7 @@ already_AddRefed<SharedWorker> SharedWorker::Constructor(
ipcClientInfo.emplace(clientInfo.value().ToIPC());
}
nsID agentClusterId = nsID::GenerateUUID();
nsID agentClusterId = nsContentUtils::GenerateUUID();
net::CookieJarSettingsArgs cjsData;
MOZ_ASSERT(loadInfo.mCookieJarSettings);

View File

@@ -102,7 +102,7 @@ LoadInfo::LoadInfo(
: aLoadingPrincipal),
mTriggeringPrincipal(aTriggeringPrincipal ? aTriggeringPrincipal
: mLoadingPrincipal.get()),
mSandboxedNullPrincipalID(nsID::GenerateUUID()),
mSandboxedNullPrincipalID(nsContentUtils::GenerateUUID()),
mClientInfo(aLoadingClientInfo),
mController(aController),
mLoadingContext(do_GetWeakReference(aLoadingContext)),
@@ -315,7 +315,7 @@ LoadInfo::LoadInfo(nsPIDOMWindowOuter* aOuterWindow,
nsISupports* aContextForTopLevelLoad,
nsSecurityFlags aSecurityFlags, uint32_t aSandboxFlags)
: mTriggeringPrincipal(aTriggeringPrincipal),
mSandboxedNullPrincipalID(nsID::GenerateUUID()),
mSandboxedNullPrincipalID(nsContentUtils::GenerateUUID()),
mContextForTopLevelLoad(do_GetWeakReference(aContextForTopLevelLoad)),
mSecurityFlags(aSecurityFlags),
mSandboxFlags(aSandboxFlags),
@@ -374,7 +374,7 @@ LoadInfo::LoadInfo(dom::CanonicalBrowsingContext* aBrowsingContext,
const OriginAttributes& aOriginAttributes,
nsSecurityFlags aSecurityFlags, uint32_t aSandboxFlags)
: mTriggeringPrincipal(aTriggeringPrincipal),
mSandboxedNullPrincipalID(nsID::GenerateUUID()),
mSandboxedNullPrincipalID(nsContentUtils::GenerateUUID()),
mSecurityFlags(aSecurityFlags),
mSandboxFlags(aSandboxFlags),
@@ -416,7 +416,7 @@ LoadInfo::LoadInfo(dom::WindowGlobalParent* aParentWGP,
nsContentPolicyType aContentPolicyType,
nsSecurityFlags aSecurityFlags, uint32_t aSandboxFlags)
: mTriggeringPrincipal(aTriggeringPrincipal),
mSandboxedNullPrincipalID(nsID::GenerateUUID()),
mSandboxedNullPrincipalID(nsContentUtils::GenerateUUID()),
mSecurityFlags(aSecurityFlags),
mSandboxFlags(aSandboxFlags),
mInternalContentPolicyType(aContentPolicyType) {
@@ -883,7 +883,7 @@ const nsID& LoadInfo::GetSandboxedNullPrincipalID() {
}
void LoadInfo::ResetSandboxedNullPrincipalID() {
mSandboxedNullPrincipalID = nsID::GenerateUUID();
mSandboxedNullPrincipalID = nsContentUtils::GenerateUUID();
}
nsIPrincipal* LoadInfo::GetTopLevelPrincipal() { return mTopLevelPrincipal; }

View File

@@ -408,7 +408,7 @@ void nsHtml5StreamParser::SetViewSourceTitle(nsIURI* aURL) {
mURIToSendToDevtools = aURL;
nsID uuid;
nsresult rv = nsID::GenerateUUIDInPlace(uuid);
nsresult rv = nsContentUtils::GenerateUUIDInPlace(uuid);
if (!NS_FAILED(rv)) {
char buffer[NSID_LENGTH];
uuid.ToProvidedString(buffer);

View File

@@ -4,6 +4,7 @@
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
#include "nsContentUtils.h"
#include "nsThreadUtils.h"
#include "mozilla/AbstractThread.h"
#include "mozilla/Logging.h"
@@ -217,7 +218,7 @@ RefPtr<RequestMetricsPromise>
PerformanceMetricsCollector::RequestMetricsInternal() {
// each request has its own UUID
nsID uuid;
nsresult rv = nsID::GenerateUUIDInPlace(uuid);
nsresult rv = nsContentUtils::GenerateUUIDInPlace(uuid);
if (NS_WARN_IF(NS_FAILED(rv))) {
return RequestMetricsPromise::CreateAndReject(rv, __func__);
}