[Extra zoom mode] The search field on www.bing.com is missing label text
authorwenson_hsieh@apple.com <wenson_hsieh@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Wed, 25 Apr 2018 21:23:27 +0000 (21:23 +0000)
committerwenson_hsieh@apple.com <wenson_hsieh@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Wed, 25 Apr 2018 21:23:27 +0000 (21:23 +0000)
https://bugs.webkit.org/show_bug.cgi?id=184975
<rdar://problem/39723081>

Reviewed by Tim Horton.

Source/WebKit:

Adds support for displaying the "aria-label" attribute as the input view's label text in extra zoom mode. Also
adds support for grabbing the input label's text for testing.

Test: fast/forms/extrazoom/form-control-label-text.html

* Shared/AssistedNodeInformation.cpp:
(WebKit::AssistedNodeInformation::encode const):
(WebKit::AssistedNodeInformation::decode):
* Shared/AssistedNodeInformation.h:
* UIProcess/API/Cocoa/WKWebView.mm:
(-[WKWebView formInputLabel]):
* UIProcess/API/Cocoa/WKWebViewPrivate.h:
* UIProcess/ios/WKContentViewInteraction.h:
* UIProcess/ios/WKContentViewInteraction.mm:
(-[WKContentView formInputLabel]):
* WebProcess/WebPage/ios/WebPageIOS.mm:
(WebKit::WebPage::getAssistedNodeInformation):

Tools:

Adds UIScriptController.formInputLabel, which asynchronously requests the input label text for the currently
focused element in extra zoom mode.

* DumpRenderTree/ios/UIScriptControllerIOS.mm:
(WTR::UIScriptController::formInputLabel const):
* TestRunnerShared/UIScriptContext/Bindings/UIScriptController.idl:
* TestRunnerShared/UIScriptContext/UIScriptController.cpp:
(WTR::UIScriptController::formInputLabel const):
* TestRunnerShared/UIScriptContext/UIScriptController.h:
* WebKitTestRunner/ios/UIScriptControllerIOS.mm:
(WTR::UIScriptController::formInputLabel const):

LayoutTests:

Adds a layout test to check that the label text of the focused form control in the input view can be sourced
from (1) the "placeholder" attribute, (2) the "title" attribute, (3) the "aria-label" attribute, or (4) an
associated label element.

* fast/forms/extrazoom/form-control-label-text-expected.txt: Added.
* fast/forms/extrazoom/form-control-label-text.html: Added.
* resources/ui-helper.js:
(window.UIHelper.formInputLabel):
(window.UIHelper):

git-svn-id: https://svn.webkit.org/repository/webkit/trunk@231022 268f45cc-cd09-0410-ab3c-d52691b4dbfc

18 files changed:
LayoutTests/ChangeLog
LayoutTests/fast/forms/extrazoom/form-control-label-text-expected.txt [new file with mode: 0644]
LayoutTests/fast/forms/extrazoom/form-control-label-text.html [new file with mode: 0644]
LayoutTests/resources/ui-helper.js
Source/WebKit/ChangeLog
Source/WebKit/Shared/AssistedNodeInformation.cpp
Source/WebKit/Shared/AssistedNodeInformation.h
Source/WebKit/UIProcess/API/Cocoa/WKWebView.mm
Source/WebKit/UIProcess/API/Cocoa/WKWebViewPrivate.h
Source/WebKit/UIProcess/ios/WKContentViewInteraction.h
Source/WebKit/UIProcess/ios/WKContentViewInteraction.mm
Source/WebKit/WebProcess/WebPage/ios/WebPageIOS.mm
Tools/ChangeLog
Tools/DumpRenderTree/ios/UIScriptControllerIOS.mm
Tools/TestRunnerShared/UIScriptContext/Bindings/UIScriptController.idl
Tools/TestRunnerShared/UIScriptContext/UIScriptController.cpp
Tools/TestRunnerShared/UIScriptContext/UIScriptController.h
Tools/WebKitTestRunner/ios/UIScriptControllerIOS.mm

index f39cd25..ca85104 100644 (file)
@@ -1,3 +1,21 @@
+2018-04-25  Wenson Hsieh  <wenson_hsieh@apple.com>
+
+        [Extra zoom mode] The search field on www.bing.com is missing label text
+        https://bugs.webkit.org/show_bug.cgi?id=184975
+        <rdar://problem/39723081>
+
+        Reviewed by Tim Horton.
+
+        Adds a layout test to check that the label text of the focused form control in the input view can be sourced
+        from (1) the "placeholder" attribute, (2) the "title" attribute, (3) the "aria-label" attribute, or (4) an
+        associated label element.
+
+        * fast/forms/extrazoom/form-control-label-text-expected.txt: Added.
+        * fast/forms/extrazoom/form-control-label-text.html: Added.
+        * resources/ui-helper.js:
+        (window.UIHelper.formInputLabel):
+        (window.UIHelper):
+
 2018-04-25  Megan Gardner  <megan_gardner@apple.com>
 
         Don't activate Selection Assistant unless it is actually needed.
diff --git a/LayoutTests/fast/forms/extrazoom/form-control-label-text-expected.txt b/LayoutTests/fast/forms/extrazoom/form-control-label-text-expected.txt
new file mode 100644 (file)
index 0000000..25240d3
--- /dev/null
@@ -0,0 +1,9 @@
+PASS successfullyParsed is true
+
+TEST COMPLETE
+test label 4
+Label text should be missing: ""
+Label text should use the placeholder: "test label 1"
+Label text should use the title: "test label 2"
+Label text should use the accessibility label: "test label 3"
+Label text should use the associated label: "test label 4"
diff --git a/LayoutTests/fast/forms/extrazoom/form-control-label-text.html b/LayoutTests/fast/forms/extrazoom/form-control-label-text.html
new file mode 100644 (file)
index 0000000..808a32f
--- /dev/null
@@ -0,0 +1,54 @@
+<!DOCTYPE html> <!-- webkit-test-runner [ useFlexibleViewport=true ] -->
+<html>
+<meta name="viewport" content="width=device-width">
+<head>
+<script src="../../../resources/js-test.js"></script>
+<script src="../../../resources/ui-helper.js"></script>
+<script>
+jsTestIsAsync = true;
+
+function getLabelTextAfterFocusingInput() {
+    return new Promise(async (resolve) => {
+        await UIHelper.activateAndWaitForInputSessionAt(75, 75);
+        const labelText = await UIHelper.formInputLabel();
+        field.blur();
+        await UIHelper.waitForKeyboardToHide();
+        resolve(labelText);
+    });
+}
+
+async function runTest() {
+    if (!window.testRunner) {
+        description(`This test requires WebKitTestRunner.`);
+        return;
+    }
+
+    missingLabel.textContent = await getLabelTextAfterFocusingInput();
+
+    field.setAttribute("placeholder", "test label 1");
+    labelFromPlaceholder.textContent = await getLabelTextAfterFocusingInput();
+
+    field.setAttribute("title", "test label 2");
+    labelFromTitle.textContent = await getLabelTextAfterFocusingInput();
+
+    field.setAttribute("aria-label", "test label 3");
+    labelFromAriaLabel.textContent = await getLabelTextAfterFocusingInput();
+
+    label.setAttribute("for", "field");
+    labelFromLabelElement.textContent = await getLabelTextAfterFocusingInput();
+
+    finishJSTest();
+}
+</script>
+</head>
+
+<body onload="runTest()">
+<input id="field" style="width: 320px; height: 568px;"></input>
+<label id="label">test label 4</label>
+<div>Label text should be missing: "<code id="missingLabel"></code>"</div>
+<div>Label text should use the placeholder: "<code id="labelFromPlaceholder"></code>"</div>
+<div>Label text should use the title: "<code id="labelFromTitle"></code>"</div>
+<div>Label text should use the accessibility label: "<code id="labelFromAriaLabel"></code>"</div>
+<div>Label text should use the associated label: "<code id="labelFromLabelElement"></code>"</div>
+</body>
+</html>
\ No newline at end of file
index 3be7d72..4463567 100644 (file)
@@ -199,4 +199,13 @@ window.UIHelper = class UIHelper {
         const setValueScript = `(() => uiController.setTimePickerValue(${hours}, ${minutes}))()`;
         return new Promise(resolve => testRunner.runUIScript(setValueScript, resolve));
     }
+
+    static formInputLabel()
+    {
+        return new Promise(resolve => {
+            testRunner.runUIScript(`(() => {
+                uiController.uiScriptComplete(uiController.formInputLabel);
+            })()`, resolve);
+        });
+    }
 }
index c9f39d8..124c673 100644 (file)
@@ -1,3 +1,29 @@
+2018-04-25  Wenson Hsieh  <wenson_hsieh@apple.com>
+
+        [Extra zoom mode] The search field on www.bing.com is missing label text
+        https://bugs.webkit.org/show_bug.cgi?id=184975
+        <rdar://problem/39723081>
+
+        Reviewed by Tim Horton.
+
+        Adds support for displaying the "aria-label" attribute as the input view's label text in extra zoom mode. Also
+        adds support for grabbing the input label's text for testing.
+
+        Test: fast/forms/extrazoom/form-control-label-text.html
+
+        * Shared/AssistedNodeInformation.cpp:
+        (WebKit::AssistedNodeInformation::encode const):
+        (WebKit::AssistedNodeInformation::decode):
+        * Shared/AssistedNodeInformation.h:
+        * UIProcess/API/Cocoa/WKWebView.mm:
+        (-[WKWebView formInputLabel]):
+        * UIProcess/API/Cocoa/WKWebViewPrivate.h:
+        * UIProcess/ios/WKContentViewInteraction.h:
+        * UIProcess/ios/WKContentViewInteraction.mm:
+        (-[WKContentView formInputLabel]):
+        * WebProcess/WebPage/ios/WebPageIOS.mm:
+        (WebKit::WebPage::getAssistedNodeInformation):
+
 2018-04-25  Ryosuke Niwa  <rniwa@webkit.org>
 
         PSON: Don't create a new process when navigating to a blob URL, data URL, and about:blank
index c7cb31a..68e1948 100644 (file)
@@ -93,6 +93,7 @@ void AssistedNodeInformation::encode(IPC::Encoder& encoder) const
     encoder.encodeEnum(autofillFieldName);
     encoder << placeholder;
     encoder << label;
+    encoder << ariaLabel;
     encoder << assistedNodeIdentifier;
 }
 
@@ -188,6 +189,9 @@ bool AssistedNodeInformation::decode(IPC::Decoder& decoder, AssistedNodeInformat
     if (!decoder.decode(result.label))
         return false;
 
+    if (!decoder.decode(result.ariaLabel))
+        return false;
+
     if (!decoder.decode(result.assistedNodeIdentifier))
         return false;
 
index a6124fd..bcc46fb 100644 (file)
@@ -117,6 +117,7 @@ struct AssistedNodeInformation {
     WebCore::AutofillFieldName autofillFieldName { WebCore::AutofillFieldName::None };
     String placeholder;
     String label;
+    String ariaLabel;
 
     uint64_t assistedNodeIdentifier { 0 };
 
index d2dc7a8..8ea437f 100644 (file)
@@ -5921,6 +5921,11 @@ static WebCore::UserInterfaceLayoutDirection toUserInterfaceLayoutDirection(UISe
     return [_contentView selectFormPopoverTitle];
 }
 
+- (NSString *)formInputLabel
+{
+    return [_contentView formInputLabel];
+}
+
 - (void)didStartFormControlInteraction
 {
     // For subclasses to override.
index cf1fca8..8f293f8 100644 (file)
@@ -382,6 +382,7 @@ typedef NS_OPTIONS(NSUInteger, _WKRectEdge) {
 - (void)dismissFormAccessoryView WK_API_AVAILABLE(ios(10.3));
 - (void)selectFormAccessoryPickerRow:(int)rowIndex WK_API_AVAILABLE(ios(10.3));
 @property (nonatomic, readonly) NSString *selectFormPopoverTitle WK_API_AVAILABLE(ios(WK_IOS_TBA));
+@property (nonatomic, readonly) NSString *formInputLabel WK_API_AVAILABLE(ios(WK_IOS_TBA));
 - (void)setTimePickerValueToHour:(NSInteger)hour minute:(NSInteger)minute WK_API_AVAILABLE(ios(WK_IOS_TBA));
 
 - (void)applyAutocorrection:(NSString *)newString toString:(NSString *)oldString withCompletionHandler:(void (^)(void))completionHandler WK_API_AVAILABLE(ios(11.0));
index 787f6b2..3f4ee96 100644 (file)
@@ -365,6 +365,7 @@ FOR_EACH_WKCONTENTVIEW_ACTION(DECLARE_WKCONTENTVIEW_ACTION_FOR_WEB_VIEW)
 - (NSDictionary *)_contentsOfUserInterfaceItem:(NSString *)userInterfaceItem;
 
 @property (nonatomic, readonly) NSString *selectFormPopoverTitle;
+@property (nonatomic, readonly) NSString *formInputLabel;
 
 @end
 
index 7b95cec..c6a35d2 100644 (file)
@@ -5515,6 +5515,15 @@ static NSArray<UIItemProvider *> *extractItemProvidersFromDropSession(id <UIDrop
     return [(WKFormSelectControl *)_inputPeripheral selectFormPopoverTitle];
 }
 
+- (NSString *)formInputLabel
+{
+#if ENABLE(EXTRA_ZOOM_MODE)
+    if (_presentedFullScreenInputViewController)
+        return [self inputLabelTextForViewController:(id)_presentedFullScreenInputViewController.get()];
+#endif
+    return nil;
+}
+
 - (void)setTimePickerValueToHour:(NSInteger)hour minute:(NSInteger)minute
 {
 #if ENABLE(EXTRA_ZOOM_MODE)
index 9f7f49f..5ced48b 100644 (file)
@@ -2345,8 +2345,11 @@ void WebPage::getAssistedNodeInformation(AssistedNodeInformation& information)
         }
     }
 
-    if (is<HTMLElement>(m_assistedNode.get()))
-        information.title = downcast<HTMLElement>(*m_assistedNode).title();
+    if (is<Element>(m_assistedNode.get())) {
+        auto& element = downcast<Element>(*m_assistedNode);
+        information.title = element.title();
+        information.ariaLabel = element.attributeWithoutSynchronization(HTMLNames::aria_labelAttr);
+    }
 
     if (is<HTMLSelectElement>(*m_assistedNode)) {
         HTMLSelectElement& element = downcast<HTMLSelectElement>(*m_assistedNode);
index 8830ea8..876a32c 100644 (file)
@@ -1,3 +1,23 @@
+2018-04-25  Wenson Hsieh  <wenson_hsieh@apple.com>
+
+        [Extra zoom mode] The search field on www.bing.com is missing label text
+        https://bugs.webkit.org/show_bug.cgi?id=184975
+        <rdar://problem/39723081>
+
+        Reviewed by Tim Horton.
+
+        Adds UIScriptController.formInputLabel, which asynchronously requests the input label text for the currently
+        focused element in extra zoom mode.
+
+        * DumpRenderTree/ios/UIScriptControllerIOS.mm:
+        (WTR::UIScriptController::formInputLabel const):
+        * TestRunnerShared/UIScriptContext/Bindings/UIScriptController.idl:
+        * TestRunnerShared/UIScriptContext/UIScriptController.cpp:
+        (WTR::UIScriptController::formInputLabel const):
+        * TestRunnerShared/UIScriptContext/UIScriptController.h:
+        * WebKitTestRunner/ios/UIScriptControllerIOS.mm:
+        (WTR::UIScriptController::formInputLabel const):
+
 2018-04-25  Michael Catanzaro  <mcatanzaro@igalia.com>
 
         [WPE] Should load injected bundle from builddir in developer builds
index b5a3337..72797b7 100644 (file)
@@ -171,6 +171,11 @@ JSRetainPtr<JSStringRef> UIScriptController::selectFormPopoverTitle() const
 {
     return nullptr;
 }
+
+JSRetainPtr<JSStringRef> UIScriptController::formInputLabel() const
+{
+    return nullptr;
+}
     
 JSObjectRef UIScriptController::contentsOfUserInterfaceItem(JSStringRef interfaceItem) const
 {
index 37737a4..23f2ba6 100644 (file)
@@ -189,6 +189,7 @@ interface UIScriptController {
     // <select> picker
     void selectFormAccessoryPickerRow(long rowIndex);
     readonly attribute DOMString selectFormPopoverTitle;
+    readonly attribute DOMString formInputLabel;
 
     void setTimePickerValue(long hour, long minute);
 
index 2b4b493..619286a 100644 (file)
@@ -311,6 +311,11 @@ JSRetainPtr<JSStringRef> UIScriptController::selectFormPopoverTitle() const
     return nullptr;
 }
 
+JSRetainPtr<JSStringRef> UIScriptController::formInputLabel() const
+{
+    return nullptr;
+}
+
 void UIScriptController::scrollToOffset(long x, long y)
 {
 }
index fd6ca93..d3a1d18 100644 (file)
@@ -99,6 +99,7 @@ public:
     void dismissFormAccessoryView();
     void selectFormAccessoryPickerRow(long);
     JSRetainPtr<JSStringRef> selectFormPopoverTitle() const;
+    JSRetainPtr<JSStringRef> formInputLabel() const;
     void setTimePickerValue(long hour, long minute);
     
     JSObjectRef contentsOfUserInterfaceItem(JSStringRef) const;
index 27f391f..a7c739a 100644 (file)
@@ -431,6 +431,12 @@ JSRetainPtr<JSStringRef> UIScriptController::selectFormPopoverTitle() const
     return JSStringCreateWithCFString((CFStringRef)webView.selectFormPopoverTitle);
 }
 
+JSRetainPtr<JSStringRef> UIScriptController::formInputLabel() const
+{
+    TestRunnerWKWebView *webView = TestController::singleton().mainWebView()->platformView();
+    return JSStringCreateWithCFString((CFStringRef)webView.formInputLabel);
+}
+
 void UIScriptController::selectFormAccessoryPickerRow(long rowIndex)
 {
     TestRunnerWKWebView *webView = TestController::singleton().mainWebView()->platformView();