Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(486)

Unified Diff: third_party/WebKit/Source/core/workers/WorkerThreadTest.cpp

Issue 2069413003: Revert of Worker: Protect a running debugger task from forcible worker termination (2) (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@avoid_debugger_task
Patch Set: Created 4 years, 6 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « third_party/WebKit/Source/core/workers/WorkerThread.cpp ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: third_party/WebKit/Source/core/workers/WorkerThreadTest.cpp
diff --git a/third_party/WebKit/Source/core/workers/WorkerThreadTest.cpp b/third_party/WebKit/Source/core/workers/WorkerThreadTest.cpp
index 3552cf927b834b91d47569669584e1f36398c09c..526bd66496bf0727509a9f669c3f913cc0e9261a 100644
--- a/third_party/WebKit/Source/core/workers/WorkerThreadTest.cpp
+++ b/third_party/WebKit/Source/core/workers/WorkerThreadTest.cpp
@@ -44,9 +44,14 @@
m_workerThread->startWithSourceCode(m_securityOrigin.get(), "while(true) {}");
}
+ void waitForShutdown()
+ {
+ m_workerThread->m_shutdownEvent->wait();
+ }
+
void setForceTerminationDelayInMs(long long forceTerminationDelayInMs)
{
- m_workerThread->m_forceTerminationDelayInMs = forceTerminationDelayInMs;
+ m_workerThread->setForceTerminationDelayInMsForTesting(forceTerminationDelayInMs);
}
bool isForceTerminationTaskScheduled()
@@ -99,7 +104,7 @@
// gracefully shut down.
m_workerThread->terminate();
EXPECT_TRUE(isForceTerminationTaskScheduled());
- m_workerThread->waitForShutdownForTesting();
+ waitForShutdown();
EXPECT_EQ(WorkerThread::ExitCode::GracefullyTerminated, m_workerThread->getExitCode());
}
@@ -123,7 +128,7 @@
// (2) If the thread has already been initialized on the worker thread,
// terminate() should gracefully shut down the thread.
m_workerThread->terminate();
- m_workerThread->waitForShutdownForTesting();
+ waitForShutdown();
WorkerThread::ExitCode exitCode = m_workerThread->getExitCode();
EXPECT_EQ(WorkerThread::ExitCode::GracefullyTerminated, exitCode);
}
@@ -171,7 +176,7 @@
// Wait until the force termination task runs.
testing::runDelayedTasks(kForceTerminationDelayInMs);
- m_workerThread->waitForShutdownForTesting();
+ waitForShutdown();
EXPECT_EQ(WorkerThread::ExitCode::AsyncForciblyTerminated, m_workerThread->getExitCode());
}
@@ -196,7 +201,7 @@
// Wait until the force termination task runs.
testing::runDelayedTasks(kForceTerminationDelayInMs);
- m_workerThread->waitForShutdownForTesting();
+ waitForShutdown();
EXPECT_EQ(WorkerThread::ExitCode::AsyncForciblyTerminated, m_workerThread->getExitCode());
}
@@ -220,39 +225,6 @@
EXPECT_EQ(WorkerThread::ExitCode::SyncForciblyTerminated, m_workerThread->getExitCode());
}
-TEST_F(WorkerThreadTest, StartAndTerminateOnScriptLoaded_TerminateWhileDebuggerTaskIsRunning)
-{
- expectReportingCallsForWorkerForciblyTerminated();
- startWithSourceCodeNotToFinish();
- m_workerThread->waitUntilScriptLoaded();
-
- // Simulate that a debugger task is running.
- m_workerThread->m_runningDebuggerTask = true;
-
- // terminate() should not schedule a force termination task because there is
- // a running debugger task.
- m_workerThread->terminate();
- EXPECT_FALSE(isForceTerminationTaskScheduled());
- EXPECT_EQ(WorkerThread::ExitCode::NotTerminated, m_workerThread->getExitCode());
-
- // Multiple terminate() calls should not take effect.
- m_workerThread->terminate();
- m_workerThread->terminate();
- EXPECT_FALSE(isForceTerminationTaskScheduled());
- EXPECT_EQ(WorkerThread::ExitCode::NotTerminated, m_workerThread->getExitCode());
-
- // Focible termination request should also respect the running debugger
- // task.
- m_workerThread->terminateInternal(WorkerThread::TerminationMode::Forcible);
- EXPECT_FALSE(isForceTerminationTaskScheduled());
- EXPECT_EQ(WorkerThread::ExitCode::NotTerminated, m_workerThread->getExitCode());
-
- // Clean up in order to satisfy DCHECKs in dtors.
- m_workerThread->m_runningDebuggerTask = false;
- m_workerThread->forciblyTerminateExecution();
- m_workerThread->waitForShutdownForTesting();
-}
-
// TODO(nhiroki): Add tests for terminateAndWaitForAllWorkers.
} // namespace blink
« no previous file with comments | « third_party/WebKit/Source/core/workers/WorkerThread.cpp ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698