Commit 88fc23eb authored by patricialor's avatar patricialor Committed by Commit bot

Mac: Fix SSLClientCertificateSelectorCocoaTest.HideShow (fails on macOS Sierra).

SSLClientCertificateSelectorCocoaTest.HideShow is failing on macOS Sierra,
blocking 10.12 rollout for Chrome. Fix this using the same refactor as seen in
r400627, which ignores mouse events instead of resizing the certificate selector
window when it's hidden.

BUG=650898

Review-Url: https://codereview.chromium.org/2559763003
Cr-Commit-Position: refs/heads/master@{#438065}
parent 9dac0955
...@@ -36,15 +36,13 @@ class SSLClientAuthObserverCocoaBridge; ...@@ -36,15 +36,13 @@ class SSLClientAuthObserverCocoaBridge;
// The list of identities offered to the user. // The list of identities offered to the user.
base::ScopedCFTypeRef<CFMutableArrayRef> identities_; base::ScopedCFTypeRef<CFMutableArrayRef> identities_;
// The corresponding list of certificates. // The corresponding list of certificates.
std::vector<scoped_refptr<net::X509Certificate> > certificates_; std::vector<scoped_refptr<net::X509Certificate>> certificates_;
// A C++ object to bridge SSLClientAuthObserver notifications to us. // A C++ object to bridge SSLClientAuthObserver notifications to us.
std::unique_ptr<SSLClientAuthObserverCocoaBridge> observer_; std::unique_ptr<SSLClientAuthObserverCocoaBridge> observer_;
base::scoped_nsobject<SFChooseIdentityPanel> panel_; base::scoped_nsobject<SFChooseIdentityPanel> panel_;
std::unique_ptr<ConstrainedWindowMac> constrainedWindow_; std::unique_ptr<ConstrainedWindowMac> constrainedWindow_;
base::scoped_nsobject<NSWindow> overlayWindow_; base::scoped_nsobject<NSWindow> overlayWindow_;
BOOL closePending_; BOOL closePending_;
// A copy of the sheet's frame used to restore on show.
NSRect oldSheetFrame_;
// A copy of the sheet's |autoresizesSubviews| flag to restore on show. // A copy of the sheet's |autoresizesSubviews| flag to restore on show.
BOOL oldResizesSubviews_; BOOL oldResizesSubviews_;
// True if the user dismissed the dialog directly, either via the OK (continue // True if the user dismissed the dialog directly, either via the OK (continue
......
...@@ -282,25 +282,17 @@ void ClearTableViewDataSourcesIfNeeded(NSWindow*) {} ...@@ -282,25 +282,17 @@ void ClearTableViewDataSourcesIfNeeded(NSWindow*) {}
- (void)hideSheet { - (void)hideSheet {
NSWindow* sheetWindow = [overlayWindow_ attachedSheet]; NSWindow* sheetWindow = [overlayWindow_ attachedSheet];
[sheetWindow setAlphaValue:0.0]; [sheetWindow setAlphaValue:0.0];
[sheetWindow setIgnoresMouseEvents:YES];
oldResizesSubviews_ = [[sheetWindow contentView] autoresizesSubviews]; oldResizesSubviews_ = [[sheetWindow contentView] autoresizesSubviews];
[[sheetWindow contentView] setAutoresizesSubviews:NO]; [[sheetWindow contentView] setAutoresizesSubviews:NO];
oldSheetFrame_ = [sheetWindow frame];
NSRect overlayFrame = [overlayWindow_ frame];
oldSheetFrame_.origin.x -= NSMinX(overlayFrame);
oldSheetFrame_.origin.y -= NSMinY(overlayFrame);
[sheetWindow setFrame:ui::kWindowSizeDeterminedLater display:NO];
} }
- (void)unhideSheet { - (void)unhideSheet {
NSWindow* sheetWindow = [overlayWindow_ attachedSheet]; NSWindow* sheetWindow = [overlayWindow_ attachedSheet];
NSRect overlayFrame = [overlayWindow_ frame];
oldSheetFrame_.origin.x += NSMinX(overlayFrame);
oldSheetFrame_.origin.y += NSMinY(overlayFrame);
[sheetWindow setFrame:oldSheetFrame_ display:NO];
[[sheetWindow contentView] setAutoresizesSubviews:oldResizesSubviews_]; [[sheetWindow contentView] setAutoresizesSubviews:oldResizesSubviews_];
[[overlayWindow_ attachedSheet] setAlphaValue:1.0]; [sheetWindow setAlphaValue:1.0];
[sheetWindow setIgnoresMouseEvents:NO];
} }
- (void)pulseSheet { - (void)pulseSheet {
......
...@@ -105,16 +105,17 @@ IN_PROC_BROWSER_TEST_F(SSLClientCertificateSelectorCocoaTest, HideShow) { ...@@ -105,16 +105,17 @@ IN_PROC_BROWSER_TEST_F(SSLClientCertificateSelectorCocoaTest, HideShow) {
content::RunAllPendingInMessageLoop(); content::RunAllPendingInMessageLoop();
NSWindow* sheetWindow = [[selector overlayWindow] attachedSheet]; NSWindow* sheetWindow = [[selector overlayWindow] attachedSheet];
NSRect sheetFrame = [sheetWindow frame];
EXPECT_EQ(1.0, [sheetWindow alphaValue]); EXPECT_EQ(1.0, [sheetWindow alphaValue]);
// Switch to another tab and verify that the sheet is hidden. // Switch to another tab and verify that the sheet is hidden. Interaction with
// the tab underneath should not be blocked.
AddBlankTabAndShow(browser()); AddBlankTabAndShow(browser());
EXPECT_EQ(0.0, [sheetWindow alphaValue]); EXPECT_EQ(0.0, [sheetWindow alphaValue]);
EXPECT_NSEQ(ui::kWindowSizeDeterminedLater, [sheetWindow frame]); EXPECT_TRUE([[selector overlayWindow] ignoresMouseEvents]);
// Switch back and verify that the sheet is shown. // Switch back and verify that the sheet is shown. Interaction with the tab
// underneath should be blocked while the sheet is showing.
chrome::SelectNumberedTab(browser(), 0); chrome::SelectNumberedTab(browser(), 0);
EXPECT_EQ(1.0, [sheetWindow alphaValue]); EXPECT_EQ(1.0, [sheetWindow alphaValue]);
EXPECT_NSEQ(sheetFrame, [sheetWindow frame]); EXPECT_FALSE([[selector overlayWindow] ignoresMouseEvents]);
} }
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment