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

Unified Diff: chrome/browser/mac/exception_processor_unittest.mm

Issue 2649253003: [Mac] Sinkhole __NSFireDelayedPerform and _CFXNotificationPost in the exception preprocessor. (Closed)
Patch Set: DVLOG Created 3 years, 11 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 | « chrome/browser/mac/exception_processor.mm ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: chrome/browser/mac/exception_processor_unittest.mm
diff --git a/chrome/browser/mac/exception_processor_unittest.mm b/chrome/browser/mac/exception_processor_unittest.mm
index 0e8460be058769ea5003adcc09c4ff5dc24040f1..78f570b54ff779aefd7cc08b5fed27f5ff5eca51 100644
--- a/chrome/browser/mac/exception_processor_unittest.mm
+++ b/chrome/browser/mac/exception_processor_unittest.mm
@@ -154,6 +154,65 @@ TEST(ExceptionProcessorTest, ThrowAndCatchExceptionInRunLoop) {
".*TEST PASS.*");
}
+void ThrowExceptionFromSelector() {
+ base::mac::DisableOSCrashDumps();
+ chrome::InstallObjcExceptionPreprocessor();
+
+ NSException* exception = [NSException exceptionWithName:@"ThrowFromSelector"
+ reason:@""
+ userInfo:nil];
+
+ [exception performSelector:@selector(raise) withObject:nil afterDelay:0.1];
+
+ [[NSRunLoop currentRunLoop] runUntilDate:
+ [NSDate dateWithTimeIntervalSinceNow:10]];
+
+ fprintf(stderr, "TEST FAILED\n");
+ exit(1);
+}
+
+TEST(ExceptionProcessorTest, ThrowExceptionFromSelector) {
+ ::testing::FLAGS_gtest_death_test_style = "threadsafe";
+ EXPECT_DEATH(ThrowExceptionFromSelector(),
+ ".*FATAL:exception_processor\\.mm.*"
+ "Terminating from Objective-C exception:.*");
+}
+
+void ThrowInNotificationObserver() {
+ base::mac::DisableOSCrashDumps();
+ chrome::InstallObjcExceptionPreprocessor();
+
+ NSNotification* notification =
+ [NSNotification notificationWithName:@"TestExceptionInObserver"
+ object:nil];
+
+ NSNotificationCenter* center = [NSNotificationCenter defaultCenter];
+ [center addObserverForName:[notification name]
+ object:nil
+ queue:nil
+ usingBlock:^(NSNotification*) {
+ [NSException raise:@"ThrowInNotificationObserver"
+ format:@""];
+ }];
+
+ [center performSelector:@selector(postNotification:)
+ withObject:notification
+ afterDelay:0];
+
+ [[NSRunLoop currentRunLoop] runUntilDate:
+ [NSDate dateWithTimeIntervalSinceNow:10]];
+
+ fprintf(stderr, "TEST FAILED\n");
+ exit(1);
+}
+
+TEST(ExceptionProcessorTest, ThrowInNotificationObserver) {
+ ::testing::FLAGS_gtest_death_test_style = "threadsafe";
+ EXPECT_DEATH(ThrowInNotificationObserver(),
+ ".*FATAL:exception_processor\\.mm.*"
+ "Terminating from Objective-C exception:.*");
+}
+
void ThrowExceptionInRunLoopWithoutProcessor() {
base::mac::DisableOSCrashDumps();
chrome::UninstallObjcExceptionPreprocessor();
« no previous file with comments | « chrome/browser/mac/exception_processor.mm ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698