Index: chrome/browser/ui/cocoa/ssl_client_certificate_selector_cocoa_browsertest.mm |
diff --git a/chrome/browser/ui/cocoa/ssl_client_certificate_selector_cocoa_browsertest.mm b/chrome/browser/ui/cocoa/ssl_client_certificate_selector_cocoa_browsertest.mm |
index bd1890344066e8cdf56eadf18b30f15e85872a80..da2cd0139e8c8802ab2d9a7208d87f8d3cfb1678 100644 |
--- a/chrome/browser/ui/cocoa/ssl_client_certificate_selector_cocoa_browsertest.mm |
+++ b/chrome/browser/ui/cocoa/ssl_client_certificate_selector_cocoa_browsertest.mm |
@@ -22,6 +22,8 @@ |
#import "testing/gtest_mac.h" |
#include "ui/base/cocoa/window_size_constants.h" |
+#import <objc/runtime.h> |
+ |
using web_modal::WebContentsModalDialogManager; |
namespace { |
@@ -119,3 +121,65 @@ IN_PROC_BROWSER_TEST_F(SSLClientCertificateSelectorCocoaTest, HideShow) { |
EXPECT_EQ(1.0, [sheetWindow alphaValue]); |
EXPECT_FALSE([[selector overlayWindow] ignoresMouseEvents]); |
} |
+ |
+@interface TestDeallocWatcher : NSObject |
+@end |
+ |
+@implementation TestDeallocWatcher { |
+ BOOL* wasDeallocated_; |
+} |
+ |
++ (void)watchTarget:(NSObject*)target andSetFlag:(BOOL*)wasDeallocated { |
+ TestDeallocWatcher* watcher = [[TestDeallocWatcher alloc] init]; |
+ watcher->wasDeallocated_ = wasDeallocated; |
+ objc_setAssociatedObject(target, _cmd, watcher, |
+ OBJC_ASSOCIATION_RETAIN_NONATOMIC); |
+ [watcher release]; |
+} |
+ |
+- (void)dealloc { |
+ *wasDeallocated_ = true; |
+ [super dealloc]; |
+} |
+ |
+@end |
+ |
+// Test that we can't trigger the crash from https://crbug.com/653093 |
+IN_PROC_BROWSER_TEST_F(SSLClientCertificateSelectorCocoaTest, |
+ WorkaroundCrashySierra) { |
+ BOOL selector_was_deallocated = false; |
+ |
+ @autoreleasepool { |
+ content::WebContents* web_contents = |
+ browser()->tab_strip_model()->GetActiveWebContents(); |
+ SSLClientCertificateSelectorCocoa* selector = |
+ [[SSLClientCertificateSelectorCocoa alloc] |
+ initWithBrowserContext:web_contents->GetBrowserContext() |
+ certRequestInfo:auth_requestor_->cert_request_info_.get() |
+ delegate:nil]; |
+ [selector displayForWebContents:web_contents]; |
+ content::RunAllPendingInMessageLoop(); |
+ |
+ [TestDeallocWatcher watchTarget:selector |
+ andSetFlag:&selector_was_deallocated]; |
+ |
+ [selector.overlayWindow endSheet:selector.overlayWindow.attachedSheet]; |
+ content::RunAllPendingInMessageLoop(); |
+ } |
+ |
+ EXPECT_TRUE(selector_was_deallocated); |
+ |
+ // Without the workaround, this will crash on Sierra. |
Robert Sesek
2017/01/11 22:03:31
If you back out the fix, does it indeed crash here
Sidney San Martín
2017/01/11 22:15:33
It does… but not consistently, since the crash hap
Robert Sesek
2017/01/11 22:33:56
As long as it fails sometimes that I think is suff
|
+ [[NSNotificationCenter defaultCenter] |
+ postNotificationName:NSPreferredScrollerStyleDidChangeNotification |
+ object:nil |
+ userInfo:@{ |
+ @"NSScrollerStyle" : @(NSScrollerStyleLegacy) |
+ }]; |
+ [[NSNotificationCenter defaultCenter] |
+ postNotificationName:NSPreferredScrollerStyleDidChangeNotification |
+ object:nil |
+ userInfo:@{ |
+ @"NSScrollerStyle" : @(NSScrollerStyleOverlay) |
+ }]; |
+} |