Title: [272107] branches/safari-611-branch
Revision
272107
Author
[email protected]
Date
2021-01-29 21:41:13 -0800 (Fri, 29 Jan 2021)

Log Message

Cherry-pick r271414. rdar://problem/73473727

    REGRESSION (r265044): [macOS] Safari autocorrects text when typing in login field on amazon.com
    https://bugs.webkit.org/show_bug.cgi?id=220556
    <rdar://problem/71602937>

    Reviewed by Darin Adler.

    Source/WebCore:

    Add an internal testing hook to ask an input element whether it has disabled spellchecking (except for text
    replacement).

    * testing/Internals.cpp:
    (WebCore::Internals::isSpellcheckDisabledExceptTextReplacement const):
    * testing/Internals.h:
    * testing/Internals.idl:

    Source/WebKit:

    Restores the implementation of `WKBundleNodeHandleSetHTMLInputElementSpellcheckEnabled`, which was removed in
    r265044, with the reasoning that the code was unused. However, Safari still uses this SPI on macOS to prevent
    automatic spelling correction from triggering when editing form fields that are AutoFillable.

    Test: WebKit.DisableSpellcheck

    * WebProcess/InjectedBundle/API/c/WKBundleNodeHandle.cpp:
    (WKBundleNodeHandleSetHTMLInputElementSpellcheckEnabled):

    Tools:

    Add an API test that uses WebKit C API (`WKBundleNodeHandleSetHTMLInputElementSpellcheckEnabled`) to disable or
    enable spellchecking on input elements.

    * TestWebKitAPI/TestWebKitAPI.xcodeproj/project.pbxproj:
    * TestWebKitAPI/Tests/WebKitCocoa/DisableSpellcheck.mm: Added.
    * TestWebKitAPI/Tests/WebKitCocoa/DisableSpellcheckPlugIn.mm: Added.
    (-[DisableSpellcheckPlugIn webProcessPlugIn:didCreateBrowserContextController:]):
    (-[DisableSpellcheckPlugIn webProcessPlugInBrowserContextController:didClearWindowObjectForFrame:inScriptWorld:]):
    (-[DisableSpellcheckPlugIn webProcessPlugInBrowserContextController:didFinishLoadForFrame:]):

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

Modified Paths

Added Paths

Diff

Modified: branches/safari-611-branch/Source/WebCore/ChangeLog (272106 => 272107)


--- branches/safari-611-branch/Source/WebCore/ChangeLog	2021-01-30 05:41:08 UTC (rev 272106)
+++ branches/safari-611-branch/Source/WebCore/ChangeLog	2021-01-30 05:41:13 UTC (rev 272107)
@@ -1,5 +1,67 @@
 2021-01-29  Alan Coon  <[email protected]>
 
+        Cherry-pick r271414. rdar://problem/73473727
+
+    REGRESSION (r265044): [macOS] Safari autocorrects text when typing in login field on amazon.com
+    https://bugs.webkit.org/show_bug.cgi?id=220556
+    <rdar://problem/71602937>
+    
+    Reviewed by Darin Adler.
+    
+    Source/WebCore:
+    
+    Add an internal testing hook to ask an input element whether it has disabled spellchecking (except for text
+    replacement).
+    
+    * testing/Internals.cpp:
+    (WebCore::Internals::isSpellcheckDisabledExceptTextReplacement const):
+    * testing/Internals.h:
+    * testing/Internals.idl:
+    
+    Source/WebKit:
+    
+    Restores the implementation of `WKBundleNodeHandleSetHTMLInputElementSpellcheckEnabled`, which was removed in
+    r265044, with the reasoning that the code was unused. However, Safari still uses this SPI on macOS to prevent
+    automatic spelling correction from triggering when editing form fields that are AutoFillable.
+    
+    Test: WebKit.DisableSpellcheck
+    
+    * WebProcess/InjectedBundle/API/c/WKBundleNodeHandle.cpp:
+    (WKBundleNodeHandleSetHTMLInputElementSpellcheckEnabled):
+    
+    Tools:
+    
+    Add an API test that uses WebKit C API (`WKBundleNodeHandleSetHTMLInputElementSpellcheckEnabled`) to disable or
+    enable spellchecking on input elements.
+    
+    * TestWebKitAPI/TestWebKitAPI.xcodeproj/project.pbxproj:
+    * TestWebKitAPI/Tests/WebKitCocoa/DisableSpellcheck.mm: Added.
+    * TestWebKitAPI/Tests/WebKitCocoa/DisableSpellcheckPlugIn.mm: Added.
+    (-[DisableSpellcheckPlugIn webProcessPlugIn:didCreateBrowserContextController:]):
+    (-[DisableSpellcheckPlugIn webProcessPlugInBrowserContextController:didClearWindowObjectForFrame:inScriptWorld:]):
+    (-[DisableSpellcheckPlugIn webProcessPlugInBrowserContextController:didFinishLoadForFrame:]):
+    
+    
+    git-svn-id: https://svn.webkit.org/repository/webkit/trunk@271414 268f45cc-cd09-0410-ab3c-d52691b4dbfc
+
+    2021-01-12  Wenson Hsieh  <[email protected]>
+
+            REGRESSION (r265044): [macOS] Safari autocorrects text when typing in login field on amazon.com
+            https://bugs.webkit.org/show_bug.cgi?id=220556
+            <rdar://problem/71602937>
+
+            Reviewed by Darin Adler.
+
+            Add an internal testing hook to ask an input element whether it has disabled spellchecking (except for text
+            replacement).
+
+            * testing/Internals.cpp:
+            (WebCore::Internals::isSpellcheckDisabledExceptTextReplacement const):
+            * testing/Internals.h:
+            * testing/Internals.idl:
+
+2021-01-29  Alan Coon  <[email protected]>
+
         Cherry-pick r271388. rdar://problem/73473676
 
     Safari 14 on 2x display renders NYS DMV page as blurry

Modified: branches/safari-611-branch/Source/WebCore/testing/Internals.cpp (272106 => 272107)


--- branches/safari-611-branch/Source/WebCore/testing/Internals.cpp	2021-01-30 05:41:08 UTC (rev 272106)
+++ branches/safari-611-branch/Source/WebCore/testing/Internals.cpp	2021-01-30 05:41:13 UTC (rev 272107)
@@ -2489,6 +2489,11 @@
 #endif
 }
 
+bool Internals::isSpellcheckDisabledExceptTextReplacement(const HTMLInputElement& element) const
+{
+    return element.isSpellcheckDisabledExceptTextReplacement();
+}
+
 void Internals::handleAcceptedCandidate(const String& candidate, unsigned location, unsigned length)
 {
     if (!contextDocument() || !contextDocument()->frame())

Modified: branches/safari-611-branch/Source/WebCore/testing/Internals.h (272106 => 272107)


--- branches/safari-611-branch/Source/WebCore/testing/Internals.h	2021-01-30 05:41:08 UTC (rev 272106)
+++ branches/safari-611-branch/Source/WebCore/testing/Internals.h	2021-01-30 05:41:13 UTC (rev 272107)
@@ -368,6 +368,8 @@
     void setAutomaticTextReplacementEnabled(bool);
     void setAutomaticSpellingCorrectionEnabled(bool);
 
+    bool isSpellcheckDisabledExceptTextReplacement(const HTMLInputElement&) const;
+
     void handleAcceptedCandidate(const String& candidate, unsigned location, unsigned length);
     void changeSelectionListType();
     void changeBackToReplacedString(const String& replacedString);

Modified: branches/safari-611-branch/Source/WebCore/testing/Internals.idl (272106 => 272107)


--- branches/safari-611-branch/Source/WebCore/testing/Internals.idl	2021-01-30 05:41:08 UTC (rev 272106)
+++ branches/safari-611-branch/Source/WebCore/testing/Internals.idl	2021-01-30 05:41:13 UTC (rev 272107)
@@ -379,6 +379,7 @@
     [MayThrowException] unsigned long countFindMatches(DOMString text, sequence<DOMString> findOptions);
 
     [MayThrowException] DOMString autofillFieldName(Element formControlElement);
+    boolean isSpellcheckDisabledExceptTextReplacement(HTMLInputElement inputElement);
 
     [MayThrowException] undefined invalidateControlTints();
 

Modified: branches/safari-611-branch/Source/WebKit/ChangeLog (272106 => 272107)


--- branches/safari-611-branch/Source/WebKit/ChangeLog	2021-01-30 05:41:08 UTC (rev 272106)
+++ branches/safari-611-branch/Source/WebKit/ChangeLog	2021-01-30 05:41:13 UTC (rev 272107)
@@ -1,5 +1,68 @@
 2021-01-29  Alan Coon  <[email protected]>
 
+        Cherry-pick r271414. rdar://problem/73473727
+
+    REGRESSION (r265044): [macOS] Safari autocorrects text when typing in login field on amazon.com
+    https://bugs.webkit.org/show_bug.cgi?id=220556
+    <rdar://problem/71602937>
+    
+    Reviewed by Darin Adler.
+    
+    Source/WebCore:
+    
+    Add an internal testing hook to ask an input element whether it has disabled spellchecking (except for text
+    replacement).
+    
+    * testing/Internals.cpp:
+    (WebCore::Internals::isSpellcheckDisabledExceptTextReplacement const):
+    * testing/Internals.h:
+    * testing/Internals.idl:
+    
+    Source/WebKit:
+    
+    Restores the implementation of `WKBundleNodeHandleSetHTMLInputElementSpellcheckEnabled`, which was removed in
+    r265044, with the reasoning that the code was unused. However, Safari still uses this SPI on macOS to prevent
+    automatic spelling correction from triggering when editing form fields that are AutoFillable.
+    
+    Test: WebKit.DisableSpellcheck
+    
+    * WebProcess/InjectedBundle/API/c/WKBundleNodeHandle.cpp:
+    (WKBundleNodeHandleSetHTMLInputElementSpellcheckEnabled):
+    
+    Tools:
+    
+    Add an API test that uses WebKit C API (`WKBundleNodeHandleSetHTMLInputElementSpellcheckEnabled`) to disable or
+    enable spellchecking on input elements.
+    
+    * TestWebKitAPI/TestWebKitAPI.xcodeproj/project.pbxproj:
+    * TestWebKitAPI/Tests/WebKitCocoa/DisableSpellcheck.mm: Added.
+    * TestWebKitAPI/Tests/WebKitCocoa/DisableSpellcheckPlugIn.mm: Added.
+    (-[DisableSpellcheckPlugIn webProcessPlugIn:didCreateBrowserContextController:]):
+    (-[DisableSpellcheckPlugIn webProcessPlugInBrowserContextController:didClearWindowObjectForFrame:inScriptWorld:]):
+    (-[DisableSpellcheckPlugIn webProcessPlugInBrowserContextController:didFinishLoadForFrame:]):
+    
+    
+    git-svn-id: https://svn.webkit.org/repository/webkit/trunk@271414 268f45cc-cd09-0410-ab3c-d52691b4dbfc
+
+    2021-01-12  Wenson Hsieh  <[email protected]>
+
+            REGRESSION (r265044): [macOS] Safari autocorrects text when typing in login field on amazon.com
+            https://bugs.webkit.org/show_bug.cgi?id=220556
+            <rdar://problem/71602937>
+
+            Reviewed by Darin Adler.
+
+            Restores the implementation of `WKBundleNodeHandleSetHTMLInputElementSpellcheckEnabled`, which was removed in
+            r265044, with the reasoning that the code was unused. However, Safari still uses this SPI on macOS to prevent
+            automatic spelling correction from triggering when editing form fields that are AutoFillable.
+
+            Test: WebKit.DisableSpellcheck
+
+            * WebProcess/InjectedBundle/API/c/WKBundleNodeHandle.cpp:
+            (WKBundleNodeHandleSetHTMLInputElementSpellcheckEnabled):
+
+2021-01-29  Alan Coon  <[email protected]>
+
         Cherry-pick r271384. rdar://problem/73473494
 
     Crash in pageDidComputePageRects()

Modified: branches/safari-611-branch/Source/WebKit/WebProcess/InjectedBundle/API/c/WKBundleNodeHandle.cpp (272106 => 272107)


--- branches/safari-611-branch/Source/WebKit/WebProcess/InjectedBundle/API/c/WKBundleNodeHandle.cpp	2021-01-30 05:41:08 UTC (rev 272106)
+++ branches/safari-611-branch/Source/WebKit/WebProcess/InjectedBundle/API/c/WKBundleNodeHandle.cpp	2021-01-30 05:41:13 UTC (rev 272107)
@@ -115,9 +115,9 @@
     WebKit::toImpl(htmlInputElementHandleRef)->setHTMLInputElementValueForUser(WebKit::toWTFString(valueRef));
 }
 
-void WKBundleNodeHandleSetHTMLInputElementSpellcheckEnabled(WKBundleNodeHandleRef, bool)
+void WKBundleNodeHandleSetHTMLInputElementSpellcheckEnabled(WKBundleNodeHandleRef htmlInputElementHandleRef, bool enabled)
 {
-    // FIXME: Would put ASSERT_NOT_REACHED() here but some compilers are warning the function is "noreturn".
+    WebKit::toImpl(htmlInputElementHandleRef)->setHTMLInputElementSpellcheckEnabled(enabled);
 }
 
 bool WKBundleNodeHandleGetHTMLInputElementAutoFilled(WKBundleNodeHandleRef)

Modified: branches/safari-611-branch/Tools/ChangeLog (272106 => 272107)


--- branches/safari-611-branch/Tools/ChangeLog	2021-01-30 05:41:08 UTC (rev 272106)
+++ branches/safari-611-branch/Tools/ChangeLog	2021-01-30 05:41:13 UTC (rev 272107)
@@ -1,5 +1,69 @@
 2021-01-29  Alan Coon  <[email protected]>
 
+        Cherry-pick r271414. rdar://problem/73473727
+
+    REGRESSION (r265044): [macOS] Safari autocorrects text when typing in login field on amazon.com
+    https://bugs.webkit.org/show_bug.cgi?id=220556
+    <rdar://problem/71602937>
+    
+    Reviewed by Darin Adler.
+    
+    Source/WebCore:
+    
+    Add an internal testing hook to ask an input element whether it has disabled spellchecking (except for text
+    replacement).
+    
+    * testing/Internals.cpp:
+    (WebCore::Internals::isSpellcheckDisabledExceptTextReplacement const):
+    * testing/Internals.h:
+    * testing/Internals.idl:
+    
+    Source/WebKit:
+    
+    Restores the implementation of `WKBundleNodeHandleSetHTMLInputElementSpellcheckEnabled`, which was removed in
+    r265044, with the reasoning that the code was unused. However, Safari still uses this SPI on macOS to prevent
+    automatic spelling correction from triggering when editing form fields that are AutoFillable.
+    
+    Test: WebKit.DisableSpellcheck
+    
+    * WebProcess/InjectedBundle/API/c/WKBundleNodeHandle.cpp:
+    (WKBundleNodeHandleSetHTMLInputElementSpellcheckEnabled):
+    
+    Tools:
+    
+    Add an API test that uses WebKit C API (`WKBundleNodeHandleSetHTMLInputElementSpellcheckEnabled`) to disable or
+    enable spellchecking on input elements.
+    
+    * TestWebKitAPI/TestWebKitAPI.xcodeproj/project.pbxproj:
+    * TestWebKitAPI/Tests/WebKitCocoa/DisableSpellcheck.mm: Added.
+    * TestWebKitAPI/Tests/WebKitCocoa/DisableSpellcheckPlugIn.mm: Added.
+    (-[DisableSpellcheckPlugIn webProcessPlugIn:didCreateBrowserContextController:]):
+    (-[DisableSpellcheckPlugIn webProcessPlugInBrowserContextController:didClearWindowObjectForFrame:inScriptWorld:]):
+    (-[DisableSpellcheckPlugIn webProcessPlugInBrowserContextController:didFinishLoadForFrame:]):
+    
+    
+    git-svn-id: https://svn.webkit.org/repository/webkit/trunk@271414 268f45cc-cd09-0410-ab3c-d52691b4dbfc
+
+    2021-01-12  Wenson Hsieh  <[email protected]>
+
+            REGRESSION (r265044): [macOS] Safari autocorrects text when typing in login field on amazon.com
+            https://bugs.webkit.org/show_bug.cgi?id=220556
+            <rdar://problem/71602937>
+
+            Reviewed by Darin Adler.
+
+            Add an API test that uses WebKit C API (`WKBundleNodeHandleSetHTMLInputElementSpellcheckEnabled`) to disable or
+            enable spellchecking on input elements.
+
+            * TestWebKitAPI/TestWebKitAPI.xcodeproj/project.pbxproj:
+            * TestWebKitAPI/Tests/WebKitCocoa/DisableSpellcheck.mm: Added.
+            * TestWebKitAPI/Tests/WebKitCocoa/DisableSpellcheckPlugIn.mm: Added.
+            (-[DisableSpellcheckPlugIn webProcessPlugIn:didCreateBrowserContextController:]):
+            (-[DisableSpellcheckPlugIn webProcessPlugInBrowserContextController:didClearWindowObjectForFrame:inScriptWorld:]):
+            (-[DisableSpellcheckPlugIn webProcessPlugInBrowserContextController:didFinishLoadForFrame:]):
+
+2021-01-29  Alan Coon  <[email protected]>
+
         Cherry-pick r271369. rdar://problem/73473654
 
     WebProcessPool::establishWorkerContextConnectionToNetworkProcess should make sure to remove the selected process from the cache

Modified: branches/safari-611-branch/Tools/TestWebKitAPI/TestWebKitAPI.xcodeproj/project.pbxproj (272106 => 272107)


--- branches/safari-611-branch/Tools/TestWebKitAPI/TestWebKitAPI.xcodeproj/project.pbxproj	2021-01-30 05:41:08 UTC (rev 272106)
+++ branches/safari-611-branch/Tools/TestWebKitAPI/TestWebKitAPI.xcodeproj/project.pbxproj	2021-01-30 05:41:13 UTC (rev 272107)
@@ -1182,6 +1182,8 @@
 		F4A32ECB1F0643370047C544 /* contenteditable-in-iframe.html in Copy Resources */ = {isa = PBXBuildFile; fileRef = F4A32ECA1F0642F40047C544 /* contenteditable-in-iframe.html */; };
 		F4A9202F1FEE34E900F59590 /* apple-data-url.html in Copy Resources */ = {isa = PBXBuildFile; fileRef = F4A9202E1FEE34C800F59590 /* apple-data-url.html */; };
 		F4AB578A1F65165400DB0DA1 /* custom-draggable-div.html in Copy Resources */ = {isa = PBXBuildFile; fileRef = F4AB57891F65164B00DB0DA1 /* custom-draggable-div.html */; };
+		F4B0168325AE060F00E445C4 /* DisableSpellcheck.mm in Sources */ = {isa = PBXBuildFile; fileRef = F4B0168225AE060F00E445C4 /* DisableSpellcheck.mm */; };
+		F4B0168425AE08F800E445C4 /* DisableSpellcheckPlugIn.mm in Sources */ = {isa = PBXBuildFile; fileRef = F4B0167F25AE02D600E445C4 /* DisableSpellcheckPlugIn.mm */; };
 		F4B825D81EF4DBFB006E417F /* compressed-files.zip in Copy Resources */ = {isa = PBXBuildFile; fileRef = F4B825D61EF4DBD4006E417F /* compressed-files.zip */; };
 		F4B86D4F20BCD5B20099A7E6 /* paint-significant-area-milestone.html in Copy Resources */ = {isa = PBXBuildFile; fileRef = F4B86D4E20BCD5970099A7E6 /* paint-significant-area-milestone.html */; };
 		F4BC0B142146C849002A0478 /* FocusPreservationTests.mm in Sources */ = {isa = PBXBuildFile; fileRef = F4BC0B132146C849002A0478 /* FocusPreservationTests.mm */; };
@@ -2947,6 +2949,8 @@
 		F4A32ECA1F0642F40047C544 /* contenteditable-in-iframe.html */ = {isa = PBXFileReference; lastKnownFileType = text.html; path = "contenteditable-in-iframe.html"; sourceTree = "<group>"; };
 		F4A9202E1FEE34C800F59590 /* apple-data-url.html */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.html; path = "apple-data-url.html"; sourceTree = "<group>"; };
 		F4AB57891F65164B00DB0DA1 /* custom-draggable-div.html */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.html; path = "custom-draggable-div.html"; sourceTree = "<group>"; };
+		F4B0167F25AE02D600E445C4 /* DisableSpellcheckPlugIn.mm */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.cpp.objcpp; path = DisableSpellcheckPlugIn.mm; sourceTree = "<group>"; };
+		F4B0168225AE060F00E445C4 /* DisableSpellcheck.mm */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.cpp.objcpp; path = DisableSpellcheck.mm; sourceTree = "<group>"; };
 		F4B825D61EF4DBD4006E417F /* compressed-files.zip */ = {isa = PBXFileReference; lastKnownFileType = archive.zip; path = "compressed-files.zip"; sourceTree = "<group>"; };
 		F4B86D4E20BCD5970099A7E6 /* paint-significant-area-milestone.html */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.html; path = "paint-significant-area-milestone.html"; sourceTree = "<group>"; };
 		F4BC0B132146C849002A0478 /* FocusPreservationTests.mm */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.cpp.objcpp; path = FocusPreservationTests.mm; sourceTree = "<group>"; };
@@ -3276,6 +3280,8 @@
 				2D2D13B2229F408B005068AF /* DeviceManagementRestrictions.mm */,
 				46918EFB2237283500468DFE /* DeviceOrientation.mm */,
 				CEA7F57B20895F5B0078EF6E /* DidResignInputElementStrongPasswordAppearance.mm */,
+				F4B0168225AE060F00E445C4 /* DisableSpellcheck.mm */,
+				F4B0167F25AE02D600E445C4 /* DisableSpellcheckPlugIn.mm */,
 				73BD731723A846500020F450 /* DisplayName.mm */,
 				518EE51A20A78CFB00E024F3 /* DoAfterNextPresentationUpdateAfterCrash.mm */,
 				2D7FD19222419087007887F1 /* DocumentEditingContext.mm */,
@@ -5514,6 +5520,7 @@
 				515BE1711D428E4B00DD7C68 /* StoreBlobThenDelete.mm in Sources */,
 				7CCE7ED01A411A7E00447C4C /* StringByEvaluatingJavaScriptFromString.mm in Sources */,
 				7CCE7ED11A411A7E00447C4C /* StringTruncator.mm in Sources */,
+				F4B0168325AE060F00E445C4 /* DisableSpellcheck.mm in Sources */,
 				ECA680CE1E68CC0900731D20 /* StringUtilities.mm in Sources */,
 				CE4D5DE71F6743BA0072CFC6 /* StringWithDirection.cpp in Sources */,
 				7CCE7ED21A411A7E00447C4C /* SubresourceErrorCrash.mm in Sources */,
@@ -5697,6 +5704,7 @@
 				5C4259462266A68A0039AA7A /* BasicProposedCredentialPlugIn.mm in Sources */,
 				374B7A611DF371CF00ACCB6C /* BundleEditingDelegatePlugIn.mm in Sources */,
 				7A89BB682331643A0042CB1E /* BundleFormDelegatePlugIn.mm in Sources */,
+				F4B0168425AE08F800E445C4 /* DisableSpellcheckPlugIn.mm in Sources */,
 				A13EBBB01B87436F00097110 /* BundleParametersPlugIn.mm in Sources */,
 				37A709AF1E3EA97E00CA5969 /* BundleRangeHandlePlugIn.mm in Sources */,
 				5C75716122124C5200B9E5AC /* BundleRetainPagePlugIn.mm in Sources */,

Added: branches/safari-611-branch/Tools/TestWebKitAPI/Tests/WebKitCocoa/DisableSpellcheck.mm (0 => 272107)


--- branches/safari-611-branch/Tools/TestWebKitAPI/Tests/WebKitCocoa/DisableSpellcheck.mm	                        (rev 0)
+++ branches/safari-611-branch/Tools/TestWebKitAPI/Tests/WebKitCocoa/DisableSpellcheck.mm	2021-01-30 05:41:13 UTC (rev 272107)
@@ -0,0 +1,43 @@
+/*
+ * Copyright (C) 2021 Apple Inc. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ *    notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ *    notice, this list of conditions and the following disclaimer in the
+ *    documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY APPLE INC. AND ITS CONTRIBUTORS ``AS IS''
+ * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
+ * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR ITS CONTRIBUTORS
+ * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
+ * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
+ * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+ * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
+ * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
+ * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF
+ * THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#import "config.h"
+
+#import "TestWKWebView.h"
+#import "Utilities.h"
+#import "WKWebViewConfigurationExtras.h"
+
+TEST(WebKit, DisableSpellcheck)
+{
+    auto configuration = [WKWebViewConfiguration _test_configurationWithTestPlugInClassName:@"DisableSpellcheckPlugIn" configureJSCForTesting:YES];
+    auto webView = adoptNS([[TestWKWebView alloc] initWithFrame:CGRectMake(0, 0, 800, 600) configuration:configuration]);
+    [webView synchronouslyLoadTestPageNamed:@"simple"];
+
+    BOOL isSpellcheckDisabled = [[webView objectByEvaluatingJavaScript:@"internals.isSpellcheckDisabledExceptTextReplacement(document.getElementById('disabled'))"] boolValue];
+    EXPECT_TRUE(isSpellcheckDisabled);
+
+    isSpellcheckDisabled = [[webView objectByEvaluatingJavaScript:@"internals.isSpellcheckDisabledExceptTextReplacement(document.getElementById('enabled'))"] boolValue];
+    EXPECT_FALSE(isSpellcheckDisabled);
+}

Added: branches/safari-611-branch/Tools/TestWebKitAPI/Tests/WebKitCocoa/DisableSpellcheckPlugIn.mm (0 => 272107)


--- branches/safari-611-branch/Tools/TestWebKitAPI/Tests/WebKitCocoa/DisableSpellcheckPlugIn.mm	                        (rev 0)
+++ branches/safari-611-branch/Tools/TestWebKitAPI/Tests/WebKitCocoa/DisableSpellcheckPlugIn.mm	2021-01-30 05:41:13 UTC (rev 272107)
@@ -0,0 +1,73 @@
+/*
+ * Copyright (C) 2021 Apple Inc. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ *    notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ *    notice, this list of conditions and the following disclaimer in the
+ *    documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY APPLE INC. AND ITS CONTRIBUTORS ``AS IS''
+ * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
+ * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR ITS CONTRIBUTORS
+ * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
+ * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
+ * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+ * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
+ * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
+ * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF
+ * THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#import "config.h"
+
+#import "WebCoreTestSupport.h"
+#import <WebKit/WKBundleNodeHandlePrivate.h>
+#import <WebKit/WKDOMDocument.h>
+#import <WebKit/WKDOMElement.h>
+#import <WebKit/WKDOMNodePrivate.h>
+#import <WebKit/WKWebProcessPlugIn.h>
+#import <WebKit/WKWebProcessPlugInBrowserContextControllerPrivate.h>
+#import <WebKit/WKWebProcessPlugInFrame.h>
+#import <WebKit/WKWebProcessPlugInLoadDelegate.h>
+#import <WebKit/WKWebProcessPlugInNodeHandlePrivate.h>
+#import <WebKit/WKWebProcessPlugInScriptWorld.h>
+
+@interface DisableSpellcheckPlugIn : NSObject <WKWebProcessPlugIn, WKWebProcessPlugInLoadDelegate>
+@end
+
+@implementation DisableSpellcheckPlugIn
+
+- (void)webProcessPlugIn:(WKWebProcessPlugInController *)plugInController didCreateBrowserContextController:(WKWebProcessPlugInBrowserContextController *)browserContextController
+{
+    browserContextController.loadDelegate = self;
+}
+
+- (void)webProcessPlugInBrowserContextController:(WKWebProcessPlugInBrowserContextController *)controller didClearWindowObjectForFrame:(WKWebProcessPlugInFrame *)frame inScriptWorld:(WKWebProcessPlugInScriptWorld *)scriptWorld
+{
+    WebCoreTestSupport::injectInternalsObject([frame jsContextForWorld:scriptWorld].JSGlobalContextRef);
+}
+
+- (void)webProcessPlugInBrowserContextController:(WKWebProcessPlugInBrowserContextController *)controller didFinishLoadForFrame:(WKWebProcessPlugInFrame *)frame
+{
+    auto document = [controller mainFrameDocument];
+    auto inputElement1 = [document createElement:@"input"];
+    [inputElement1 setAttribute:@"id" value:@"disabled"];
+    [document.body appendChild:inputElement1];
+
+    auto inputElement2 = [document createElement:@"input"];
+    [inputElement2 setAttribute:@"id" value:@"enabled"];
+    [document.body appendChild:inputElement2];
+
+    auto inputElementHandle1 = [inputElement1 _copyBundleNodeHandleRef];
+    WKBundleNodeHandleSetHTMLInputElementSpellcheckEnabled(inputElementHandle1, false);
+
+    auto inputElementHandle2 = [inputElement2 _copyBundleNodeHandleRef];
+    WKBundleNodeHandleSetHTMLInputElementSpellcheckEnabled(inputElementHandle2, true);
+}
+
+@end
_______________________________________________
webkit-changes mailing list
[email protected]
https://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to