Skip to content

Commit

Permalink
[iOS] 3 fast/viewport/ios/viewport-fit-*.html layout tests constantly…
Browse files Browse the repository at this point in the history
… failing.

https://bugs.webkit.org/show_bug.cgi?id=271778
rdar://125502337

Reviewed by Wenson Hsieh.

This patch addresses the failing fast/viewport/ios/viewport-fit-*.html
layout tests in two distinct ways:

1. The test expectations around the screen dimensions were updated to
   reflect the fact that layout tests now run in an iPhone 12 simulator,
   and not an iPhone SE simulator, which the stale expectations
   correspond to.

2. The tests sometimes flakily fail because some overriden safe area
   inset values are not reflected in the screen dimensions queried
   post visible rect update. This is fixed by delegating that same test
   query to after a visible rect update and the next stable presentation
   update, which required hooking up some new functionality in WKWebView
   testing API, as well as UIScriptController.

* LayoutTests/fast/viewport/ios/viewport-fit-auto-expected.txt:
* LayoutTests/fast/viewport/ios/viewport-fit-auto.html:
* LayoutTests/fast/viewport/ios/viewport-fit-contain-expected.txt:
* LayoutTests/fast/viewport/ios/viewport-fit-contain.html:
* LayoutTests/fast/viewport/ios/viewport-fit-cover-expected.txt:
* LayoutTests/fast/viewport/ios/viewport-fit-cover.html:

* LayoutTests/platform/ios/TestExpectations:
Remove the failing annotations for the tests we're addressing.

* Source/WebKit/UIProcess/API/ios/WKWebViewPrivateForTestingIOS.h:
* Source/WebKit/UIProcess/API/ios/WKWebViewTestingIOS.mm:
(-[WKWebView _doAfterNextVisibleContentRectAndStablePresentationUpdate:]):
* Tools/TestRunnerShared/UIScriptContext/Bindings/UIScriptController.idl:
* Tools/TestRunnerShared/UIScriptContext/UIScriptController.h:
(WTR::UIScriptController::doAfterNextVisibleContentRectAndStablePresentationUpdate):
* Tools/WebKitTestRunner/ios/UIScriptControllerIOS.h:
* Tools/WebKitTestRunner/ios/UIScriptControllerIOS.mm:
(WTR::UIScriptControllerIOS::doAfterNextVisibleContentRectAndStablePresentationUpdate):
(WTR::UIScriptControllerIOS::zoomToScale):
(WTR::setModifierFlagsForUIPhysicalKeyboardEvent): Deleted.

Canonical link: https://commits.webkit.org/276847@main
  • Loading branch information
aprotyas committed Mar 30, 2024
1 parent f71983c commit dfe516c
Show file tree
Hide file tree
Showing 13 changed files with 31 additions and 14 deletions.
4 changes: 2 additions & 2 deletions LayoutTests/fast/viewport/ios/viewport-fit-auto-expected.txt
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
Viewport: initial-scale=1, viewport-fit=auto

Window Size: 260 x 538
Window Size: 330 x 787

scale 1.00000
maxScale 5.00000
minScale 1.00000
visibleRect {"left":"-40.00000","top":"-10.00000","width":"320.00000","height":"548.00000"}
visibleRect {"left":"-40.00000","top":"-10.00000","width":"390.00000","height":"797.00000"}
2 changes: 1 addition & 1 deletion LayoutTests/fast/viewport/ios/viewport-fit-auto.html
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
return `
(function() {
uiController.setSafeAreaInsets(10, 20, 30, 40);
uiController.doAfterVisibleContentRectUpdate(function () {
uiController.doAfterNextVisibleContentRectAndStablePresentationUpdate(function () {
uiController.uiScriptComplete();
})
})();`
Expand Down
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
Viewport: initial-scale=1, viewport-fit=contain

Window Size: 260 x 538
Window Size: 330 x 787

scale 1.00000
maxScale 5.00000
minScale 1.00000
visibleRect {"left":"-40.00000","top":"-10.00000","width":"320.00000","height":"548.00000"}
visibleRect {"left":"-40.00000","top":"-10.00000","width":"390.00000","height":"797.00000"}
2 changes: 1 addition & 1 deletion LayoutTests/fast/viewport/ios/viewport-fit-contain.html
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
return `
(function() {
uiController.setSafeAreaInsets(10, 20, 30, 40);
uiController.doAfterVisibleContentRectUpdate(function () {
uiController.doAfterNextVisibleContentRectAndStablePresentationUpdate(function () {
uiController.uiScriptComplete();
})
})();`
Expand Down
4 changes: 2 additions & 2 deletions LayoutTests/fast/viewport/ios/viewport-fit-cover-expected.txt
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
Viewport: initial-scale=1, viewport-fit=cover

Window Size: 320 x 548
Window Size: 390 x 797

scale 1.00000
maxScale 5.00000
minScale 1.00000
visibleRect {"left":"0.00000","top":"0.00000","width":"320.00000","height":"548.00000"}
visibleRect {"left":"0.00000","top":"0.00000","width":"390.00000","height":"797.00000"}
2 changes: 1 addition & 1 deletion LayoutTests/fast/viewport/ios/viewport-fit-cover.html
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
return `
(function() {
uiController.setSafeAreaInsets(10, 20, 30, 40);
uiController.doAfterVisibleContentRectUpdate(function () {
uiController.doAfterNextVisibleContentRectAndStablePresentationUpdate(function () {
uiController.uiScriptComplete();
})
})();`
Expand Down
5 changes: 0 additions & 5 deletions LayoutTests/platform/ios/TestExpectations
Original file line number Diff line number Diff line change
Expand Up @@ -1369,11 +1369,6 @@ http/wpt/crypto/rsa-pss-crash.any.worker.html [ Pass ]
# Depend on iOS 11 API.
fast/css/variables/env/ios [ Pass ]

# webkit.org/b/271778 (3 fast/viewport/ios/viewport-fit-*.html layout tests constantly failing.)
fast/viewport/ios/viewport-fit-contain.html [ Failure ]
fast/viewport/ios/viewport-fit-cover.html [ Failure ]
fast/viewport/ios/viewport-fit-auto.html [ Failure ]

###
# Known failures
##
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -92,6 +92,8 @@

+ (void)_resetPresentLockdownModeMessage;

- (void)_doAfterNextVisibleContentRectAndStablePresentationUpdate:(void (^)(void))updateBlock;

@end

#endif // TARGET_OS_IPHONE
7 changes: 7 additions & 0 deletions Source/WebKit/UIProcess/API/ios/WKWebViewTestingIOS.mm
Original file line number Diff line number Diff line change
Expand Up @@ -489,6 +489,13 @@ + (void)_resetPresentLockdownModeMessage
#endif
}

- (void)_doAfterNextVisibleContentRectAndStablePresentationUpdate:(void (^)(void))updateBlock
{
[self _doAfterNextVisibleContentRectUpdate:makeBlockPtr([strongSelf = retainPtr(self), updateBlock = makeBlockPtr(updateBlock)] {
[strongSelf _doAfterNextStablePresentationUpdate:updateBlock.get()];
}).get()];
}

@end

#endif // PLATFORM(IOS_FAMILY)
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,7 @@ interface UIScriptController {
undefined doAfterNextStablePresentationUpdate(object callback);
undefined ensurePositionInformationIsUpToDateAt(long x, long y, object callback);
undefined doAfterVisibleContentRectUpdate(object callback);
undefined doAfterNextVisibleContentRectAndStablePresentationUpdate(object callback);

undefined doAfterDoubleTapDelay(object callback);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -83,6 +83,7 @@ class UIScriptController : public JSWrappable {
virtual void doAfterNextStablePresentationUpdate(JSValueRef callback) { doAfterPresentationUpdate(callback); }
virtual void ensurePositionInformationIsUpToDateAt(long, long, JSValueRef callback) { doAsyncTask(callback); }
virtual void doAfterVisibleContentRectUpdate(JSValueRef callback) { doAsyncTask(callback); }
virtual void doAfterNextVisibleContentRectAndStablePresentationUpdate(JSValueRef callback) { doAsyncTask(callback); }

virtual void doAfterDoubleTapDelay(JSValueRef callback) { doAsyncTask(callback); }

Expand Down
1 change: 1 addition & 0 deletions Tools/WebKitTestRunner/ios/UIScriptControllerIOS.h
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,7 @@ class UIScriptControllerIOS final : public UIScriptControllerCocoa {
void doAfterNextStablePresentationUpdate(JSValueRef) override;
void ensurePositionInformationIsUpToDateAt(long x, long y, JSValueRef) override;
void doAfterVisibleContentRectUpdate(JSValueRef) override;
void doAfterNextVisibleContentRectAndStablePresentationUpdate(JSValueRef) override;
void doAfterDoubleTapDelay(JSValueRef) override;
void zoomToScale(double scale, JSValueRef) override;
void retrieveSpeakSelectionContent(JSValueRef) override;
Expand Down
10 changes: 10 additions & 0 deletions Tools/WebKitTestRunner/ios/UIScriptControllerIOS.mm
Original file line number Diff line number Diff line change
Expand Up @@ -221,6 +221,16 @@ static Class internalClassNamed(NSString *className)
}).get()];
}

void UIScriptControllerIOS::doAfterNextVisibleContentRectAndStablePresentationUpdate(JSValueRef callback)
{
unsigned callbackID = m_context->prepareForAsyncTask(callback, CallbackTypeNonPersistent);
[webView() _doAfterNextVisibleContentRectAndStablePresentationUpdate:makeBlockPtr([this, protectedThis = Ref { *this }, callbackID] {
if (!m_context)
return;
m_context->asyncTaskComplete(callbackID);
}).get()];
}

void UIScriptControllerIOS::zoomToScale(double scale, JSValueRef callback)
{
unsigned callbackID = m_context->prepareForAsyncTask(callback, CallbackTypeNonPersistent);
Expand Down

0 comments on commit dfe516c

Please sign in to comment.