Backed out 3 changesets (bug 1779000) for causing build bustages on ActorsParentCommon.cpp. CLOSED TREE

Backed out changeset f33bbb0568fa (bug 1779000)
Backed out changeset 31ba65d120ff (bug 1779000)
Backed out changeset f3a44c2ade2c (bug 1779000)
This commit is contained in:
criss 2022-07-15 06:52:44 +03:00
Родитель 7d7b7cb561
Коммит 512ac8c6d0
13 изменённых файлов: 267 добавлений и 31 удалений

Просмотреть файл

@ -15001,7 +15001,7 @@ mozilla::ipc::IPCResult MutableFile::RecvGetFileId(int64_t* aFileId) {
AssertIsOnBackgroundThread();
MOZ_ASSERT(mFileInfo);
if (NS_WARN_IF(!StaticPrefs::dom_indexedDB_testing())) {
if (NS_WARN_IF(!IndexedDatabaseManager::InTestingMode())) {
return IPC_FAIL(this, "IndexedDB must be in testing mode!");
}
@ -21310,8 +21310,8 @@ mozilla::ipc::IPCResult Utils::RecvGetFileReferences(
return IPC_FAIL(this, "No QuotaManager active!");
}
if (NS_WARN_IF(!StaticPrefs::dom_indexedDB_testing())) {
return IPC_FAIL(this, "IndexedDB is not in testing mode!");
if (NS_WARN_IF(!IndexedDatabaseManager::InTestingMode())) {
return IPC_FAIL(this, "IndexedDatabaseManager is not InTestingMode!");
}
if (NS_WARN_IF(!IsValidPersistenceType(aPersistenceType))) {

Просмотреть файл

@ -403,7 +403,7 @@ GetStructuredCloneReadInfoFromExternalBlob(
QM_TRY(OkIf(index < files.Length()), Err(NS_ERROR_UNEXPECTED),
[](const auto&) { MOZ_ASSERT(false, "Bad index value!"); });
if (StaticPrefs::dom_indexedDB_preprocessing()) {
if (IndexedDatabaseManager::PreprocessingEnabled()) {
return StructuredCloneReadInfoParent{
JSStructuredCloneData{JS::StructuredCloneScope::DifferentProcess},
std::move(files), true};

Просмотреть файл

@ -483,7 +483,7 @@ RefPtr<IDBTransaction> IDBDatabase::Transaction(
if ((aMode == IDBTransactionMode::Readwriteflush ||
aMode == IDBTransactionMode::Cleanup) &&
!StaticPrefs::dom_indexedDB_experimental()) {
!IndexedDatabaseManager::ExperimentalFeaturesEnabled()) {
// Pretend that this mode doesn't exist. We don't have a way to annotate
// certain enum values as depending on preferences so we just duplicate the
// normal exception generation here.
@ -1025,6 +1025,16 @@ void IDBDatabase::LastRelease() {
}
}
nsresult IDBDatabase::PostHandleEvent(EventChainPostVisitor& aVisitor) {
nsresult rv =
IndexedDatabaseManager::CommonPostHandleEvent(aVisitor, *mFactory);
if (NS_WARN_IF(NS_FAILED(rv))) {
return rv;
}
return NS_OK;
}
JSObject* IDBDatabase::WrapObject(JSContext* aCx,
JS::Handle<JSObject*> aGivenProto) {
return IDBDatabase_Binding::Wrap(aCx, this, aGivenProto);

Просмотреть файл

@ -220,6 +220,8 @@ class IDBDatabase final : public DOMEventTargetHelper {
virtual void LastRelease() override;
virtual nsresult PostHandleEvent(EventChainPostVisitor& aVisitor) override;
// nsWrapperCache
virtual JSObject* WrapObject(JSContext* aCx,
JS::Handle<JSObject*> aGivenProto) override;

Просмотреть файл

@ -335,7 +335,7 @@ RefPtr<IDBOpenDBRequest> IDBOpenDBRequest::Create(
aFactory->AssertIsOnOwningThread();
MOZ_ASSERT(aGlobal);
bool fileHandleDisabled = !StaticPrefs::dom_fileHandle_enabled();
bool fileHandleDisabled = !IndexedDatabaseManager::IsFileHandleEnabled();
RefPtr<IDBOpenDBRequest> request =
new IDBOpenDBRequest(std::move(aFactory), aGlobal, fileHandleDisabled);
@ -439,6 +439,16 @@ NS_INTERFACE_MAP_END_INHERITING(IDBRequest)
NS_IMPL_ADDREF_INHERITED(IDBOpenDBRequest, IDBRequest)
NS_IMPL_RELEASE_INHERITED(IDBOpenDBRequest, IDBRequest)
nsresult IDBOpenDBRequest::PostHandleEvent(EventChainPostVisitor& aVisitor) {
nsresult rv =
IndexedDatabaseManager::CommonPostHandleEvent(aVisitor, *mFactory);
if (NS_WARN_IF(NS_FAILED(rv))) {
return rv;
}
return NS_OK;
}
JSObject* IDBOpenDBRequest::WrapObject(JSContext* aCx,
JS::Handle<JSObject*> aGivenProto) {
AssertIsOnOwningThread();

Просмотреть файл

@ -271,6 +271,8 @@ class IDBOpenDBRequest final : public IDBRequest {
void NoteComplete();
// EventTarget
virtual nsresult PostHandleEvent(EventChainPostVisitor& aVisitor) override;
IMPL_EVENT_HANDLER(blocked);
IMPL_EVENT_HANDLER(upgradeneeded);

Просмотреть файл

@ -123,9 +123,15 @@ const int32_t kDefaultMaxPreloadExtraRecords = 64;
#define IDB_PREF_BRANCH_ROOT "dom.indexedDB."
const char kTestingPref[] = IDB_PREF_BRANCH_ROOT "testing";
const char kPrefExperimental[] = IDB_PREF_BRANCH_ROOT "experimental";
const char kPrefFileHandle[] = "dom.fileHandle.enabled";
const char kDataThresholdPref[] = IDB_PREF_BRANCH_ROOT "dataThreshold";
const char kPrefMaxSerilizedMsgSize[] =
IDB_PREF_BRANCH_ROOT "maxSerializedMsgSize";
const char kPrefErrorEventToSelfError[] =
IDB_PREF_BRANCH_ROOT "errorEventToSelfError";
const char kPreprocessingPref[] = IDB_PREF_BRANCH_ROOT "preprocessing";
const char kPrefMaxPreloadExtraRecords[] =
IDB_PREF_BRANCH_ROOT "maxPreloadExtraRecords";
@ -144,10 +150,22 @@ StaticRefPtr<IndexedDatabaseManager> gDBManager;
Atomic<bool> gInitialized(false);
Atomic<bool> gClosed(false);
Atomic<bool> gTestingMode(false);
Atomic<bool> gExperimentalFeaturesEnabled(false);
Atomic<bool> gFileHandleEnabled(false);
Atomic<bool> gPrefErrorEventToSelfError(false);
Atomic<int32_t> gDataThresholdBytes(0);
Atomic<int32_t> gMaxSerializedMsgSize(0);
Atomic<bool> gPreprocessingEnabled(false);
Atomic<int32_t> gMaxPreloadExtraRecords(0);
void AtomicBoolPrefChangedCallback(const char* aPrefName, void* aBool) {
MOZ_ASSERT(NS_IsMainThread());
MOZ_ASSERT(aBool);
*static_cast<Atomic<bool>*>(aBool) = Preferences::GetBool(aPrefName);
}
void DataThresholdPrefChangedCallback(const char* aPrefName, void* aClosure) {
MOZ_ASSERT(NS_IsMainThread());
MOZ_ASSERT(!strcmp(aPrefName, kDataThresholdPref));
@ -258,6 +276,17 @@ IndexedDatabaseManager* IndexedDatabaseManager::Get() {
nsresult IndexedDatabaseManager::Init() {
NS_ASSERTION(NS_IsMainThread(), "Wrong thread!");
Preferences::RegisterCallbackAndCall(AtomicBoolPrefChangedCallback,
kTestingPref, &gTestingMode);
Preferences::RegisterCallbackAndCall(AtomicBoolPrefChangedCallback,
kPrefExperimental,
&gExperimentalFeaturesEnabled);
Preferences::RegisterCallbackAndCall(AtomicBoolPrefChangedCallback,
kPrefFileHandle, &gFileHandleEnabled);
Preferences::RegisterCallbackAndCall(AtomicBoolPrefChangedCallback,
kPrefErrorEventToSelfError,
&gPrefErrorEventToSelfError);
// By default IndexedDB uses SQLite with PRAGMA synchronous = NORMAL. This
// guarantees (unlike synchronous = OFF) atomicity and consistency, but not
// necessarily durability in situations such as power loss. This preference
@ -281,6 +310,10 @@ nsresult IndexedDatabaseManager::Init() {
Preferences::RegisterCallbackAndCall(MaxSerializedMsgSizePrefChangeCallback,
kPrefMaxSerilizedMsgSize);
Preferences::RegisterCallbackAndCall(AtomicBoolPrefChangedCallback,
kPreprocessingPref,
&gPreprocessingEnabled);
Preferences::RegisterCallbackAndCall(MaxPreloadExtraRecordsPrefChangeCallback,
kPrefMaxPreloadExtraRecords);
@ -313,6 +346,17 @@ void IndexedDatabaseManager::Destroy() {
NS_ERROR("Shutdown more than once?!");
}
Preferences::UnregisterCallback(AtomicBoolPrefChangedCallback, kTestingPref,
&gTestingMode);
Preferences::UnregisterCallback(AtomicBoolPrefChangedCallback,
kPrefExperimental,
&gExperimentalFeaturesEnabled);
Preferences::UnregisterCallback(AtomicBoolPrefChangedCallback,
kPrefFileHandle, &gFileHandleEnabled);
Preferences::UnregisterCallback(AtomicBoolPrefChangedCallback,
kPrefErrorEventToSelfError,
&gPrefErrorEventToSelfError);
Preferences::UnregisterCallback(LoggingModePrefChangedCallback,
kPrefLoggingDetails);
@ -328,9 +372,115 @@ void IndexedDatabaseManager::Destroy() {
Preferences::UnregisterCallback(MaxSerializedMsgSizePrefChangeCallback,
kPrefMaxSerilizedMsgSize);
Preferences::UnregisterCallback(AtomicBoolPrefChangedCallback,
kPreprocessingPref, &gPreprocessingEnabled);
delete this;
}
// static
nsresult IndexedDatabaseManager::CommonPostHandleEvent(
EventChainPostVisitor& aVisitor, const IDBFactory& aFactory) {
MOZ_ASSERT(aVisitor.mDOMEvent);
if (!gPrefErrorEventToSelfError) {
return NS_OK;
}
if (aVisitor.mEventStatus == nsEventStatus_eConsumeNoDefault) {
return NS_OK;
}
if (!aVisitor.mDOMEvent->IsTrusted()) {
return NS_OK;
}
nsAutoString type;
aVisitor.mDOMEvent->GetType(type);
MOZ_ASSERT(nsDependentString(kErrorEventType).EqualsLiteral("error"));
if (!type.EqualsLiteral("error")) {
return NS_OK;
}
nsCOMPtr<EventTarget> eventTarget = aVisitor.mDOMEvent->GetTarget();
MOZ_ASSERT(eventTarget);
// Only mess with events that were originally targeted to an IDBRequest.
RefPtr<IDBRequest> request;
if (NS_FAILED(eventTarget->QueryInterface(
NS_GET_IID(mozilla::dom::detail::PrivateIDBRequest),
getter_AddRefs(request))) ||
!request) {
return NS_OK;
}
RefPtr<DOMException> error = request->GetErrorAfterResult();
nsString errorName;
if (error) {
error->GetName(errorName);
}
RootedDictionary<ErrorEventInit> init(RootingCx());
request->GetCallerLocation(init.mFilename, &init.mLineno, &init.mColno);
init.mMessage = errorName;
init.mCancelable = true;
init.mBubbles = true;
nsEventStatus status = nsEventStatus_eIgnore;
if (NS_IsMainThread()) {
nsCOMPtr<nsIDOMWindow> window =
do_QueryInterface(eventTarget->GetOwnerGlobal());
if (window) {
nsCOMPtr<nsIScriptGlobalObject> sgo = do_QueryInterface(window);
MOZ_ASSERT(sgo);
if (NS_WARN_IF(!sgo->HandleScriptError(init, &status))) {
status = nsEventStatus_eIgnore;
}
} else {
// We don't fire error events at any global for non-window JS on the main
// thread.
}
} else {
// Not on the main thread, must be in a worker.
WorkerPrivate* workerPrivate = GetCurrentThreadWorkerPrivate();
MOZ_ASSERT(workerPrivate);
RefPtr<WorkerGlobalScope> globalScope = workerPrivate->GlobalScope();
MOZ_ASSERT(globalScope);
RefPtr<ErrorEvent> errorEvent = ErrorEvent::Constructor(
globalScope, nsDependentString(kErrorEventType), init);
MOZ_ASSERT(errorEvent);
errorEvent->SetTrusted(true);
RefPtr<EventTarget> target = static_cast<EventTarget*>(globalScope.get());
if (NS_WARN_IF(NS_FAILED(EventDispatcher::DispatchDOMEvent(
target,
/* aWidgetEvent */ nullptr, errorEvent,
/* aPresContext */ nullptr, &status)))) {
status = nsEventStatus_eIgnore;
}
}
if (status == nsEventStatus_eConsumeNoDefault) {
return NS_OK;
}
// Log the error to the error console.
ScriptErrorHelper::Dump(errorName, init.mFilename, init.mLineno, init.mColno,
nsIScriptError::errorFlag, aFactory.IsChrome(),
aFactory.InnerWindowID());
return NS_OK;
}
// static
bool IndexedDatabaseManager::ResolveSandboxBinding(JSContext* aCx) {
MOZ_ASSERT(NS_IsMainThread());
@ -421,6 +571,14 @@ mozilla::LogModule* IndexedDatabaseManager::GetLoggingModule() {
#endif // DEBUG
// static
bool IndexedDatabaseManager::InTestingMode() {
MOZ_ASSERT(gDBManager,
"InTestingMode() called before indexedDB has been initialized!");
return gTestingMode;
}
// static
bool IndexedDatabaseManager::FullSynchronous() {
MOZ_ASSERT(gDBManager,
@ -429,6 +587,53 @@ bool IndexedDatabaseManager::FullSynchronous() {
return sFullSynchronousMode;
}
// static
bool IndexedDatabaseManager::ExperimentalFeaturesEnabled() {
if (NS_IsMainThread()) {
if (NS_WARN_IF(!GetOrCreate())) {
return false;
}
} else {
MOZ_ASSERT(Get(),
"ExperimentalFeaturesEnabled() called off the main thread "
"before indexedDB has been initialized!");
}
return gExperimentalFeaturesEnabled;
}
// static
bool IndexedDatabaseManager::ExperimentalFeaturesEnabled(JSContext* aCx,
JSObject* aGlobal) {
// If, in the child process, properties of the global object are enumerated
// before the chrome registry (and thus the value of |intl.accept_languages|)
// is ready, calling IndexedDatabaseManager::Init will permanently break
// that preference. We can retrieve gExperimentalFeaturesEnabled without
// actually going through IndexedDatabaseManager.
// See Bug 1198093 comment 14 for detailed explanation.
MOZ_DIAGNOSTIC_ASSERT(JS_IsGlobalObject(aGlobal));
if (!strcmp(JS::GetClass(aGlobal)->name, "BackstagePass")) {
MOZ_ASSERT(NS_IsMainThread());
static bool featureRetrieved = false;
if (!featureRetrieved) {
gExperimentalFeaturesEnabled = Preferences::GetBool(kPrefExperimental);
featureRetrieved = true;
}
return gExperimentalFeaturesEnabled;
}
return ExperimentalFeaturesEnabled();
}
// static
bool IndexedDatabaseManager::IsFileHandleEnabled() {
MOZ_ASSERT(gDBManager,
"IsFileHandleEnabled() called before indexedDB has been "
"initialized!");
return gFileHandleEnabled;
}
// static
uint32_t IndexedDatabaseManager::DataThreshold() {
MOZ_ASSERT(gDBManager,
@ -447,6 +652,15 @@ uint32_t IndexedDatabaseManager::MaxSerializedMsgSize() {
return gMaxSerializedMsgSize;
}
// static
bool IndexedDatabaseManager::PreprocessingEnabled() {
MOZ_ASSERT(gDBManager,
"PreprocessingEnabled() called before indexedDB has been "
"initialized!");
return gPreprocessingEnabled;
}
// static
int32_t IndexedDatabaseManager::MaxPreloadExtraRecords() {
MOZ_ASSERT(gDBManager,
@ -535,7 +749,7 @@ nsresult IndexedDatabaseManager::BlockAndGetFileReferences(
int32_t* aDBRefCnt, bool* aResult) {
MOZ_ASSERT(NS_IsMainThread());
if (NS_WARN_IF(!StaticPrefs::dom_indexedDB_testing())) {
if (NS_WARN_IF(!InTestingMode())) {
return NS_ERROR_UNEXPECTED;
}
@ -573,7 +787,7 @@ nsresult IndexedDatabaseManager::BlockAndGetFileReferences(
nsresult IndexedDatabaseManager::FlushPendingFileDeletions() {
MOZ_ASSERT(NS_IsMainThread());
if (NS_WARN_IF(!StaticPrefs::dom_indexedDB_testing())) {
if (NS_WARN_IF(!InTestingMode())) {
return NS_ERROR_UNEXPECTED;
}

Просмотреть файл

@ -65,6 +65,8 @@ class IndexedDatabaseManager final {
}
#endif
static bool InTestingMode();
static bool FullSynchronous();
static LoggingMode GetLoggingMode()
@ -85,10 +87,18 @@ class IndexedDatabaseManager final {
}
#endif
static bool ExperimentalFeaturesEnabled();
static bool ExperimentalFeaturesEnabled(JSContext* aCx, JSObject* aGlobal);
static bool IsFileHandleEnabled();
static uint32_t DataThreshold();
static uint32_t MaxSerializedMsgSize();
static bool PreprocessingEnabled();
// The maximum number of extra entries to preload in an Cursor::OpenOp or
// Cursor::ContinueOp.
static int32_t MaxPreloadExtraRecords();
@ -123,6 +133,10 @@ class IndexedDatabaseManager final {
static const nsCString& GetLocale();
// TODO: Convert this to MOZ_CAN_RUN_SCRIPT (bug 1415230)
MOZ_CAN_RUN_SCRIPT_BOUNDARY static nsresult CommonPostHandleEvent(
EventChainPostVisitor& aVisitor, const IDBFactory& aFactory);
static bool ResolveSandboxBinding(JSContext* aCx);
static bool DefineIndexedDB(JSContext* aCx, JS::Handle<JSObject*> aGlobal);

Просмотреть файл

@ -32,10 +32,10 @@ interface IDBIndex {
// <null>: Not locale-aware, uses normal JS sorting.
// <string>: Sorted based on the rules of the specified locale.
// Note: never returns "auto", only the current locale.
[Pref="dom.indexedDB.experimental"]
[Func="mozilla::dom::IndexedDatabaseManager::ExperimentalFeaturesEnabled"]
readonly attribute DOMString? locale;
[Pref="dom.indexedDB.experimental"]
[Func="mozilla::dom::IndexedDatabaseManager::ExperimentalFeaturesEnabled"]
readonly attribute boolean isAutoLocale;
[NewObject, Throws] IDBRequest get(any query);

Просмотреть файл

@ -34,7 +34,7 @@ interface IDBKeyRange {
};
[Exposed=(Window,Worker),
Pref="dom.indexedDB.experimental"]
Func="mozilla::dom::IndexedDatabaseManager::ExperimentalFeaturesEnabled"]
interface IDBLocaleAwareKeyRange : IDBKeyRange {
[NewObject, Throws]
static IDBLocaleAwareKeyRange bound (any lower, any upper, optional boolean lowerOpen = false, optional boolean upperOpen = false);

Просмотреть файл

@ -12,7 +12,7 @@ enum IDBTransactionMode {
"readonly",
"readwrite",
// The "readwriteflush" mode is only available when the
// |dom.indexedDB.experimental| pref returns
// |IndexedDatabaseManager::ExperimentalFeaturesEnabled()| function returns
// true. This mode is not yet part of the standard.
"readwriteflush",
"cleanup",

Просмотреть файл

@ -2371,7 +2371,7 @@
# Whether or not File Handle is enabled.
- name: dom.fileHandle.enabled
type: RelaxedAtomicBool
type: bool
value: false
mirror: always
@ -2542,24 +2542,6 @@
value: @IS_NIGHTLY_BUILD@
mirror: always
# Whether or not indexedDB test mode is enabled.
- name: dom.indexedDB.testing
type: RelaxedAtomicBool
value: false
mirror: always
# Whether or not indexedDB experimental features are enabled.
- name: dom.indexedDB.experimental
type: RelaxedAtomicBool
value: false
mirror: always
# Whether or not indexedDB preprocessing is enabled.
- name: dom.indexedDB.preprocessing
type: RelaxedAtomicBool
value: false
mirror: always
- name: dom.input_events.beforeinput.enabled
type: bool
value: true

Просмотреть файл

@ -130,6 +130,8 @@ pref("browser.cache.offline.capacity", 512000);
// Don't show "Open with" option on download dialog if true.
pref("browser.download.forbid_open_with", false);
// Whether or not indexedDB experimental features are enabled.
pref("dom.indexedDB.experimental", false);
// Enable indexedDB logging.
pref("dom.indexedDB.logging.enabled", true);
// Detailed output in log messages.