Chromium Code Reviews| 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..e75c2c11f36c5cae473ef2f8d1e75c1125cfcdab 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 |
|
Sidney San Martín
2017/01/11 21:27:03
rsesek@: Maybe there's a simpler way to do this? (
Robert Sesek
2017/01/11 22:03:31
Just a variant of what you're doing here, which is
Sidney San Martín
2017/01/11 22:15:33
That is better. Done.
|
| + |
| +// Test that we can't trigger the crash from https://crbug.com/653093 |
| +IN_PROC_BROWSER_TEST_F(SSLClientCertificateSelectorCocoaTest, |
| + WorkaroundCrashySierra) { |
| + BOOL selectorWasDeallocated = false; |
|
Sidney San Martín
2017/01/11 21:29:41
I just caught myself not using underscores here :)
|
| + |
| + @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:&selectorWasDeallocated]; |
| + |
| + [selector.overlayWindow endSheet:selector.overlayWindow.attachedSheet]; |
| + content::RunAllPendingInMessageLoop(); |
| + } |
| + |
| + EXPECT_TRUE(selectorWasDeallocated); |
| + |
| + // Without the workaround, this will crash on Sierra. |
| + [[NSNotificationCenter defaultCenter] |
| + postNotificationName:NSPreferredScrollerStyleDidChangeNotification |
| + object:nil |
| + userInfo:@{ |
| + @"NSScrollerStyle" : @(NSScrollerStyleLegacy) |
| + }]; |
| + [[NSNotificationCenter defaultCenter] |
| + postNotificationName:NSPreferredScrollerStyleDidChangeNotification |
| + object:nil |
| + userInfo:@{ |
| + @"NSScrollerStyle" : @(NSScrollerStyleOverlay) |
| + }]; |
| +} |