зеркало из https://github.com/mozilla/gecko-dev.git
Bug 1731564: Use motivated SpinEventLoopUntil inside toolkit/*. r=Gijs
Depends on D127233 Differential Revision: https://phabricator.services.mozilla.com/D127234
This commit is contained in:
Родитель
3d9442dbd4
Коммит
1f8b07cd6b
|
@ -102,6 +102,7 @@ TEST(TestURLQueryStringStripper, TestEmptyStripList)
|
|||
observer->StartWaitingObserver();
|
||||
Preferences::SetCString(kPrefQueryStrippingList, "");
|
||||
MOZ_ALWAYS_TRUE(mozilla::SpinEventLoopUntil(
|
||||
"TEST(TestURLQueryStringStripper, TestEmptyStripList)"_ns,
|
||||
[&]() -> bool { return !observer->IsStillWaiting(); }));
|
||||
|
||||
DoTest("https://example.com/"_ns, ""_ns, false);
|
||||
|
@ -122,6 +123,7 @@ TEST(TestURLQueryStringStripper, TestStripping)
|
|||
observer->StartWaitingObserver();
|
||||
Preferences::SetCString(kPrefQueryStrippingList, "fooBar foobaz");
|
||||
MOZ_ALWAYS_TRUE(mozilla::SpinEventLoopUntil(
|
||||
"TEST(TestURLQueryStringStripper, TestStripping)"_ns,
|
||||
[&]() -> bool { return !observer->IsStillWaiting(); }));
|
||||
|
||||
// Test the stripping.
|
||||
|
@ -146,6 +148,7 @@ TEST(TestURLQueryStringStripper, TestStripping)
|
|||
observer->StartWaitingObserver();
|
||||
Preferences::SetCString(kPrefQueryStrippingList, "Barfoo bazfoo");
|
||||
MOZ_ALWAYS_TRUE(mozilla::SpinEventLoopUntil(
|
||||
"TEST(TestURLQueryStringStripper, TestStripping)"_ns,
|
||||
[&]() -> bool { return !observer->IsStillWaiting(); }));
|
||||
|
||||
DoTest("https://example.com/?fooBar=123"_ns, ""_ns, false);
|
||||
|
|
|
@ -2604,10 +2604,11 @@ Database::Observe(nsISupports* aSubject, const char* aTopic,
|
|||
|
||||
// Spin the events loop until the clients are done.
|
||||
// Note, this is just for tests, specifically test_clearHistory_shutdown.js
|
||||
SpinEventLoopUntil([&]() {
|
||||
return mClientsShutdown->State() ==
|
||||
PlacesShutdownBlocker::States::RECEIVED_DONE;
|
||||
});
|
||||
SpinEventLoopUntil("places:Database::Observe(SIMULATE_PLACES_SHUTDOWN)"_ns,
|
||||
[&]() {
|
||||
return mClientsShutdown->State() ==
|
||||
PlacesShutdownBlocker::States::RECEIVED_DONE;
|
||||
});
|
||||
|
||||
{
|
||||
nsCOMPtr<nsIAsyncShutdownClient> shutdownPhase =
|
||||
|
|
|
@ -72,19 +72,20 @@ class WaitForTopicSpinner final : public nsIObserver {
|
|||
|
||||
void Spin() {
|
||||
bool timedOut = false;
|
||||
mozilla::SpinEventLoopUntil([&]() -> bool {
|
||||
if (mTopicReceived) {
|
||||
return true;
|
||||
}
|
||||
mozilla::SpinEventLoopUntil(
|
||||
"places:WaitForTopicSpinner::Spin"_ns, [&]() -> bool {
|
||||
if (mTopicReceived) {
|
||||
return true;
|
||||
}
|
||||
|
||||
if ((PR_IntervalNow() - mStartTime) >
|
||||
(WAITFORTOPIC_TIMEOUT_SECONDS * PR_USEC_PER_SEC)) {
|
||||
timedOut = true;
|
||||
return true;
|
||||
}
|
||||
if ((PR_IntervalNow() - mStartTime) >
|
||||
(WAITFORTOPIC_TIMEOUT_SECONDS * PR_USEC_PER_SEC)) {
|
||||
timedOut = true;
|
||||
return true;
|
||||
}
|
||||
|
||||
return false;
|
||||
});
|
||||
return false;
|
||||
});
|
||||
|
||||
if (timedOut) {
|
||||
// Timed out waiting for the topic.
|
||||
|
|
|
@ -81,7 +81,8 @@ TEST(IHistory, Test)
|
|||
run_next_test();
|
||||
|
||||
// Spin the event loop until we've run out of tests to run.
|
||||
mozilla::SpinEventLoopUntil([&]() { return !gPendingTests; });
|
||||
mozilla::SpinEventLoopUntil("places:TEST(IHistory, Test)"_ns,
|
||||
[&]() { return !gPendingTests; });
|
||||
|
||||
// And let any other events finish before we quit.
|
||||
(void)NS_ProcessPendingEvents(nullptr);
|
||||
|
|
|
@ -60,7 +60,8 @@ class VisitURIObserver final : public nsIObserver {
|
|||
}
|
||||
|
||||
void WaitForNotification() {
|
||||
SpinEventLoopUntil([&]() { return mVisits >= mExpectedVisits; });
|
||||
SpinEventLoopUntil("places:VisitURIObserver::WaitForNotification"_ns,
|
||||
[&]() { return mVisits >= mExpectedVisits; });
|
||||
}
|
||||
|
||||
NS_IMETHOD Observe(nsISupports* aSubject, const char* aTopic,
|
||||
|
@ -165,7 +166,8 @@ void test_unvisited_does_not_notify_part2() {
|
|||
using namespace test_unvisited_does_not_notify;
|
||||
|
||||
if (StaticPrefs::layout_css_notify_of_unvisited()) {
|
||||
SpinEventLoopUntil([&]() { return testLink->GotNotified(); });
|
||||
SpinEventLoopUntil("places:test_unvisited_does_not_notify_part2"_ns,
|
||||
[&]() { return testLink->GotNotified(); });
|
||||
}
|
||||
|
||||
// We would have had a failure at this point had the content node been told it
|
||||
|
@ -237,7 +239,8 @@ void test_new_visit_notifies_waiting_Link() {
|
|||
history->RegisterVisitedCallback(testURI, link);
|
||||
|
||||
if (StaticPrefs::layout_css_notify_of_unvisited()) {
|
||||
SpinEventLoopUntil([&]() { return link->GotNotified(); });
|
||||
SpinEventLoopUntil("places:test_new_visit_notifies_waiting_Link"_ns,
|
||||
[&]() { return link->GotNotified(); });
|
||||
}
|
||||
|
||||
link->AwaitNewNotification(expect_visit);
|
||||
|
|
|
@ -107,7 +107,8 @@ nsPrintingProxy::ShowPrintDialog(mozIDOMWindowProxy* parent,
|
|||
|
||||
mozilla::Unused << SendShowPrintDialog(dialog, pBrowser, inSettings);
|
||||
|
||||
SpinEventLoopUntil([&, dialog]() { return dialog->returned(); });
|
||||
SpinEventLoopUntil("printingui:nsPrintingProxy::ShowPrintDialog"_ns,
|
||||
[&, dialog]() { return dialog->returned(); });
|
||||
|
||||
rv = dialog->result();
|
||||
NS_ENSURE_SUCCESS(rv, rv);
|
||||
|
|
|
@ -77,7 +77,8 @@ nsresult SyncApplyUpdates(TableUpdateArray& aUpdates) {
|
|||
// the main thread. As a result we have to keep processing
|
||||
// pending event until |done| becomes true. If there's no
|
||||
// more pending event, what we only can do is wait.
|
||||
MOZ_ALWAYS_TRUE(SpinEventLoopUntil([&]() { return done; }));
|
||||
MOZ_ALWAYS_TRUE(SpinEventLoopUntil("url-classifier:SyncApplyUpdates"_ns,
|
||||
[&]() { return done; }));
|
||||
|
||||
return ret;
|
||||
}
|
||||
|
|
|
@ -127,7 +127,8 @@ static nsresult ProfileResetCreateBackup(nsIToolkitProfile* aOldProfile) {
|
|||
// The result callback will shut down the worker thread.
|
||||
|
||||
// Wait for the cleanup thread to complete.
|
||||
SpinEventLoopUntil([&]() { return gProfileResetCleanupCompleted; });
|
||||
SpinEventLoopUntil("xre:ProfileResetCreateBackup"_ns,
|
||||
[&]() { return gProfileResetCleanupCompleted; });
|
||||
} else {
|
||||
gProfileResetCleanupCompleted = true;
|
||||
NS_WARNING("Cleanup thread creation failed");
|
||||
|
|
|
@ -90,47 +90,51 @@ class UntrustedModulesCollector {
|
|||
mData.clear();
|
||||
int pendingQueries = 0;
|
||||
|
||||
EXPECT_TRUE(SpinEventLoopUntil([this, &pendingQueries, &aChecker, &rv]() {
|
||||
// Some of expected loaded modules are still missing
|
||||
// after kMaximumPendingQueries queries were submitted.
|
||||
// Giving up here to avoid an infinite loop.
|
||||
if (pendingQueries >= kMaximumPendingQueries) {
|
||||
rv = NS_ERROR_ABORT;
|
||||
return true;
|
||||
}
|
||||
EXPECT_TRUE(SpinEventLoopUntil(
|
||||
"xre:UntrustedModulesCollector"_ns,
|
||||
[this, &pendingQueries, &aChecker, &rv]() {
|
||||
// Some of expected loaded modules are still missing
|
||||
// after kMaximumPendingQueries queries were submitted.
|
||||
// Giving up here to avoid an infinite loop.
|
||||
if (pendingQueries >= kMaximumPendingQueries) {
|
||||
rv = NS_ERROR_ABORT;
|
||||
return true;
|
||||
}
|
||||
|
||||
++pendingQueries;
|
||||
++pendingQueries;
|
||||
|
||||
RefPtr<DllServices> dllSvc(DllServices::Get());
|
||||
dllSvc->GetUntrustedModulesData()->Then(
|
||||
GetMainThreadSerialEventTarget(), __func__,
|
||||
[this, &pendingQueries,
|
||||
&aChecker](Maybe<UntrustedModulesData>&& aResult) {
|
||||
EXPECT_GT(pendingQueries, 0);
|
||||
--pendingQueries;
|
||||
RefPtr<DllServices> dllSvc(DllServices::Get());
|
||||
dllSvc->GetUntrustedModulesData()->Then(
|
||||
GetMainThreadSerialEventTarget(), __func__,
|
||||
[this, &pendingQueries,
|
||||
&aChecker](Maybe<UntrustedModulesData>&& aResult) {
|
||||
EXPECT_GT(pendingQueries, 0);
|
||||
--pendingQueries;
|
||||
|
||||
if (aResult.isSome()) {
|
||||
wprintf(L"Received data. (pendingQueries=%d)\n", pendingQueries);
|
||||
for (const auto& evt : aResult.ref().mEvents) {
|
||||
aChecker.Decrement(evt.mRequestedDllName);
|
||||
}
|
||||
EXPECT_TRUE(mData.emplaceBack(std::move(aResult.ref())));
|
||||
}
|
||||
},
|
||||
[&pendingQueries, &rv](nsresult aReason) {
|
||||
EXPECT_GT(pendingQueries, 0);
|
||||
--pendingQueries;
|
||||
if (aResult.isSome()) {
|
||||
wprintf(L"Received data. (pendingQueries=%d)\n",
|
||||
pendingQueries);
|
||||
for (const auto& evt : aResult.ref().mEvents) {
|
||||
aChecker.Decrement(evt.mRequestedDllName);
|
||||
}
|
||||
EXPECT_TRUE(mData.emplaceBack(std::move(aResult.ref())));
|
||||
}
|
||||
},
|
||||
[&pendingQueries, &rv](nsresult aReason) {
|
||||
EXPECT_GT(pendingQueries, 0);
|
||||
--pendingQueries;
|
||||
|
||||
wprintf(L"GetUntrustedModulesData() failed - %08x\n", aReason);
|
||||
EXPECT_TRUE(false);
|
||||
rv = aReason;
|
||||
});
|
||||
wprintf(L"GetUntrustedModulesData() failed - %08x\n", aReason);
|
||||
EXPECT_TRUE(false);
|
||||
rv = aReason;
|
||||
});
|
||||
|
||||
// Keep calling GetUntrustedModulesData() until we meet the condition.
|
||||
return aChecker.IsDone();
|
||||
}));
|
||||
// Keep calling GetUntrustedModulesData() until we meet the condition.
|
||||
return aChecker.IsDone();
|
||||
}));
|
||||
|
||||
EXPECT_TRUE(SpinEventLoopUntil(
|
||||
"xre:UntrustedModulesCollector(pendingQueries)"_ns,
|
||||
[&pendingQueries]() { return pendingQueries <= 0; }));
|
||||
|
||||
return rv;
|
||||
|
|
Загрузка…
Ссылка в новой задаче