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

Side by Side Diff: chrome/browser/ui/cocoa/ssl_client_certificate_selector_cocoa_browsertest.mm

Issue 2624273003: Add a test for our workaround of an AppKit crash in SFChooseIdentityPanel. (Closed)
Patch Set: Simplify how we check that the certificate selector was deallocated. 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 unified diff | Download patch
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #import "chrome/browser/ui/cocoa/ssl_client_certificate_selector_cocoa.h" 5 #import "chrome/browser/ui/cocoa/ssl_client_certificate_selector_cocoa.h"
6 6
7 #import <SecurityInterface/SFChooseIdentityPanel.h> 7 #import <SecurityInterface/SFChooseIdentityPanel.h>
8 8
9 #include "base/bind.h" 9 #include "base/bind.h"
10 #import "base/mac/mac_util.h" 10 #import "base/mac/mac_util.h"
(...skipping 101 matching lines...) Expand 10 before | Expand all | Expand 10 after
112 AddBlankTabAndShow(browser()); 112 AddBlankTabAndShow(browser());
113 EXPECT_EQ(0.0, [sheetWindow alphaValue]); 113 EXPECT_EQ(0.0, [sheetWindow alphaValue]);
114 EXPECT_TRUE([[selector overlayWindow] ignoresMouseEvents]); 114 EXPECT_TRUE([[selector overlayWindow] ignoresMouseEvents]);
115 115
116 // Switch back and verify that the sheet is shown. Interaction with the tab 116 // Switch back and verify that the sheet is shown. Interaction with the tab
117 // underneath should be blocked while the sheet is showing. 117 // underneath should be blocked while the sheet is showing.
118 chrome::SelectNumberedTab(browser(), 0); 118 chrome::SelectNumberedTab(browser(), 0);
119 EXPECT_EQ(1.0, [sheetWindow alphaValue]); 119 EXPECT_EQ(1.0, [sheetWindow alphaValue]);
120 EXPECT_FALSE([[selector overlayWindow] ignoresMouseEvents]); 120 EXPECT_FALSE([[selector overlayWindow] ignoresMouseEvents]);
121 } 121 }
122
123 @interface DeallocTrackingSSLClientCertificateSelectorCocoa
124 : SSLClientCertificateSelectorCocoa
125 @property(nonatomic) BOOL* wasDeallocated;
126 @end
127
128 @implementation DeallocTrackingSSLClientCertificateSelectorCocoa
129 @synthesize wasDeallocated = wasDeallocated_;
130
131 - (void)dealloc {
132 *wasDeallocated_ = true;
133 [super dealloc];
134 }
135
136 @end
137
138 // Test that we can't trigger the crash from https://crbug.com/653093
139 IN_PROC_BROWSER_TEST_F(SSLClientCertificateSelectorCocoaTest,
140 WorkaroundCrashySierra) {
141 BOOL selector_was_deallocated = false;
142
143 @autoreleasepool {
144 content::WebContents* web_contents =
145 browser()->tab_strip_model()->GetActiveWebContents();
146 DeallocTrackingSSLClientCertificateSelectorCocoa* selector =
147 [[DeallocTrackingSSLClientCertificateSelectorCocoa alloc]
148 initWithBrowserContext:web_contents->GetBrowserContext()
149 certRequestInfo:auth_requestor_->cert_request_info_.get()
150 delegate:nil];
151 [selector displayForWebContents:web_contents];
152 content::RunAllPendingInMessageLoop();
153
154 selector.wasDeallocated = &selector_was_deallocated;
155
156 [selector.overlayWindow endSheet:selector.overlayWindow.attachedSheet];
157 content::RunAllPendingInMessageLoop();
158 }
159
160 EXPECT_TRUE(selector_was_deallocated);
161
162 // Without the workaround, this will crash on Sierra.
163 [[NSNotificationCenter defaultCenter]
164 postNotificationName:NSPreferredScrollerStyleDidChangeNotification
165 object:nil
166 userInfo:@{
167 @"NSScrollerStyle" : @(NSScrollerStyleLegacy)
168 }];
169 [[NSNotificationCenter defaultCenter]
170 postNotificationName:NSPreferredScrollerStyleDidChangeNotification
171 object:nil
172 userInfo:@{
173 @"NSScrollerStyle" : @(NSScrollerStyleOverlay)
174 }];
175 }
OLDNEW
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698