Skip to content

Commit 6aafcb9

Browse files
WKAttachmentTests.InPlaceImageAttachmentToggleDisplayMode times out on macOS bots
https://bugs.webkit.org/show_bug.cgi?id=180200 Reviewed by Alexey Proskuryakov. Rewrites an API test to avoid checking against the hard-coded platform-dependent size of an attachment element. Instead, first insert the attachment element as an icon and compute its size, and then check that the size of the element is restored to this original value after toggling the display mode to in-place mode and back. * TestWebKitAPI/Tests/WebKitCocoa/WKAttachmentTests.mm: (-[TestWKWebView attachmentElementSize]): (-[TestWKWebView waitForAttachmentElementSizeToBecome:]): (TestWebKitAPI::TEST): (platformAttachmentIconElementSize): Deleted. git-svn-id: http://svn.webkit.org/repository/webkit/trunk@225332 268f45cc-cd09-0410-ab3c-d52691b4dbfc
1 parent b905d2a commit 6aafcb9

File tree

2 files changed

+38
-22
lines changed

2 files changed

+38
-22
lines changed

Tools/ChangeLog

+17
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,20 @@
1+
2017-11-30 Wenson Hsieh <[email protected]>
2+
3+
WKAttachmentTests.InPlaceImageAttachmentToggleDisplayMode times out on macOS bots
4+
https://bugs.webkit.org/show_bug.cgi?id=180200
5+
6+
Reviewed by Alexey Proskuryakov.
7+
8+
Rewrites an API test to avoid checking against the hard-coded platform-dependent size of an attachment element.
9+
Instead, first insert the attachment element as an icon and compute its size, and then check that the size of
10+
the element is restored to this original value after toggling the display mode to in-place mode and back.
11+
12+
* TestWebKitAPI/Tests/WebKitCocoa/WKAttachmentTests.mm:
13+
(-[TestWKWebView attachmentElementSize]):
14+
(-[TestWKWebView waitForAttachmentElementSizeToBecome:]):
15+
(TestWebKitAPI::TEST):
16+
(platformAttachmentIconElementSize): Deleted.
17+
118
2017-11-30 Michael Catanzaro <[email protected]>
219

320
[WPE] Stop building Wayland in JHBuild moduleset

Tools/TestWebKitAPI/Tests/WebKitCocoa/WKAttachmentTests.mm

+21-22
Original file line numberDiff line numberDiff line change
@@ -34,15 +34,6 @@
3434

3535
#if WK_API_ENABLED
3636

37-
CGSize platformAttachmentIconElementSize()
38-
{
39-
#if PLATFORM(IOS)
40-
return CGSizeMake(160, 119);
41-
#else
42-
return CGSizeMake(61, 89);
43-
#endif
44-
}
45-
4637
@interface AttachmentUpdateObserver : NSObject <WKUIDelegatePrivate>
4738
@property (nonatomic, readonly) NSArray *inserted;
4839
@property (nonatomic, readonly) NSArray *removed;
@@ -192,18 +183,22 @@ - (_WKAttachment *)synchronouslyInsertAttachmentWithFilename:(NSString *)filenam
192183
return attachment.autorelease();
193184
}
194185

186+
- (CGSize)attachmentElementSize
187+
{
188+
__block CGSize size;
189+
__block bool doneEvaluatingScript = false;
190+
[self evaluateJavaScript:@"r = document.querySelector('attachment').getBoundingClientRect(); [r.width, r.height]" completionHandler:^(NSArray<NSNumber *> *sizeResult, NSError *) {
191+
size = CGSizeMake(sizeResult.firstObject.floatValue, sizeResult.lastObject.floatValue);
192+
doneEvaluatingScript = true;
193+
}];
194+
TestWebKitAPI::Util::run(&doneEvaluatingScript);
195+
return size;
196+
}
197+
195198
- (void)waitForAttachmentElementSizeToBecome:(CGSize)expectedSize
196199
{
197200
while ([[NSRunLoop currentRunLoop] runMode:NSDefaultRunLoopMode beforeDate:[NSDate distantPast]]) {
198-
__block bool doneEvaluatingScript = false;
199-
__block BOOL sizeIsEqual = NO;
200-
[self evaluateJavaScript:@"r = document.querySelector('attachment').getBoundingClientRect(); [r.width, r.height]" completionHandler:^(NSArray<NSNumber *> *sizeResult, NSError *) {
201-
CGSize observedSize { sizeResult.firstObject.floatValue, sizeResult.lastObject.floatValue };
202-
sizeIsEqual = CGSizeEqualToSize(expectedSize, observedSize);
203-
doneEvaluatingScript = true;
204-
}];
205-
TestWebKitAPI::Util::run(&doneEvaluatingScript);
206-
if (sizeIsEqual)
201+
if (CGSizeEqualToSize(self.attachmentElementSize, expectedSize))
207202
break;
208203
}
209204
}
@@ -499,15 +494,19 @@ - (void)expectRequestedDataToBe:(NSData *)expectedData
499494
RetainPtr<_WKAttachment> attachment;
500495
{
501496
ObserveAttachmentUpdatesForScope observer(webView.get());
502-
attachment = retainPtr([webView synchronouslyInsertAttachmentWithFilename:@"icon.png" contentType:@"image/png" data:imageData.get() options:displayOptionsWithMode(_WKAttachmentDisplayModeInPlace)]);
503-
observer.expectAttachmentUpdates(@[], @[attachment.get()]);
497+
attachment = retainPtr([webView synchronouslyInsertAttachmentWithFilename:@"icon.png" contentType:@"image/png" data:imageData.get() options:displayOptionsWithMode(_WKAttachmentDisplayModeAsIcon)]);
504498
[attachment expectRequestedDataToBe:imageData.get()];
505-
[webView waitForAttachmentElementSizeToBecome:CGSizeMake(215, 174)];
499+
observer.expectAttachmentUpdates(@[], @[attachment.get()]);
506500
}
501+
CGSize iconAttachmentSize = [webView attachmentElementSize];
502+
503+
[attachment synchronouslySetDisplayOptions:displayOptionsWithMode(_WKAttachmentDisplayModeInPlace) error:nil];
504+
[attachment expectRequestedDataToBe:imageData.get()];
505+
[webView waitForAttachmentElementSizeToBecome:CGSizeMake(215, 174)];
507506

508507
[attachment synchronouslySetDisplayOptions:displayOptionsWithMode(_WKAttachmentDisplayModeAsIcon) error:nil];
509508
[attachment expectRequestedDataToBe:imageData.get()];
510-
[webView waitForAttachmentElementSizeToBecome:platformAttachmentIconElementSize()];
509+
[webView waitForAttachmentElementSizeToBecome:iconAttachmentSize];
511510

512511
[attachment synchronouslySetDisplayOptions:displayOptionsWithMode(_WKAttachmentDisplayModeInPlace) error:nil];
513512
[attachment expectRequestedDataToBe:imageData.get()];

0 commit comments

Comments
 (0)