Diff
Modified: trunk/LayoutTests/ChangeLog (271458 => 271459)
--- trunk/LayoutTests/ChangeLog 2021-01-13 22:42:35 UTC (rev 271458)
+++ trunk/LayoutTests/ChangeLog 2021-01-13 22:50:25 UTC (rev 271459)
@@ -1,3 +1,20 @@
+2021-01-13 Wenson Hsieh <[email protected]>
+
+ [macOS] "Correct Spelling Automatically" menu items are inconsistent when autocorrect="off"
+ https://bugs.webkit.org/show_bug.cgi?id=220598
+ <rdar://problem/71713611>
+
+ Reviewed by Tim Horton.
+
+ Add a new API test to verify that the context menu item to toggle "Correct Spelling Automatically" is disabled
+ when autocorrect="off".
+
+ * editing/mac/spelling/disable-automatic-spelling-correction-context-menu-item-expected.txt: Added.
+ * editing/mac/spelling/disable-automatic-spelling-correction-context-menu-item.html: Added.
+ * platform/mac-wk1/TestExpectations:
+
+ Disable the test in DumpRenderTree, due to lack of support for context menu testing in WebKit1.
+
2021-01-13 Truitt Savell <[email protected]>
REGRESSION (r269627?): ASSERTION FAILED: &layoutState().establishedFormattingState(layoutBox.formattingContextRoot()) == this in WebCore::Layout::FormattingState::boxGeometry
Added: trunk/LayoutTests/editing/mac/spelling/disable-automatic-spelling-correction-context-menu-item-expected.txt (0 => 271459)
--- trunk/LayoutTests/editing/mac/spelling/disable-automatic-spelling-correction-context-menu-item-expected.txt (rev 0)
+++ trunk/LayoutTests/editing/mac/spelling/disable-automatic-spelling-correction-context-menu-item-expected.txt 2021-01-13 22:50:25 UTC (rev 271459)
@@ -0,0 +1,13 @@
+
+
+Verifies that autocorrect='off' disables the 'Correct Spelling Automatically' context menu item on macOS. To manually test, check that the menu item is disabled when right clicking the top text field, but enabled when clicking the bottom text field.
+
+On success, you will see a series of "PASS" messages, followed by "TEST COMPLETE".
+
+
+PASS isSpellingCorrectionMenuItemEnabled(topInput) is false
+PASS isSpellingCorrectionMenuItemEnabled(bottomInput) is true
+PASS successfullyParsed is true
+
+TEST COMPLETE
+
Added: trunk/LayoutTests/editing/mac/spelling/disable-automatic-spelling-correction-context-menu-item.html (0 => 271459)
--- trunk/LayoutTests/editing/mac/spelling/disable-automatic-spelling-correction-context-menu-item.html (rev 0)
+++ trunk/LayoutTests/editing/mac/spelling/disable-automatic-spelling-correction-context-menu-item.html 2021-01-13 22:50:25 UTC (rev 271459)
@@ -0,0 +1,33 @@
+<!DOCTYPE html>
+<html>
+<head>
+<script src=""
+</head>
+<body>
+ <div><input id="top" autocorrect="off"></input></div>
+ <div><input id="bottom"></input></div>
+</body>
+<p id="description"></p>
+<p id="console"></p>
+</body>
+<script>
+function isSpellingCorrectionMenuItemEnabled(element)
+{
+ const elementRect = element.getBoundingClientRect();
+ eventSender.mouseMoveTo(elementRect.left + elementRect.width / 2, elementRect.top + elementRect.height / 2);
+
+ const spellingMenuItem = eventSender.contextClick().find(item => item.title === "Spelling and Grammar");
+ return spellingMenuItem.children.find(item => item.title === "Correct Spelling Automatically").enabled;
+}
+
+description("Verifies that autocorrect='off' disables the 'Correct Spelling Automatically' context menu item on macOS. To manually test, check that the menu item is disabled when right clicking the top text field, but enabled when clicking the bottom text field.");
+
+topInput = document.getElementById("top");
+bottomInput = document.getElementById("bottom");
+
+if (window.eventSender) {
+ shouldBeFalse("isSpellingCorrectionMenuItemEnabled(topInput)");
+ shouldBeTrue("isSpellingCorrectionMenuItemEnabled(bottomInput)");
+}
+</script>
+</html>
Modified: trunk/LayoutTests/platform/mac-wk1/TestExpectations (271458 => 271459)
--- trunk/LayoutTests/platform/mac-wk1/TestExpectations 2021-01-13 22:42:35 UTC (rev 271458)
+++ trunk/LayoutTests/platform/mac-wk1/TestExpectations 2021-01-13 22:50:25 UTC (rev 271459)
@@ -290,6 +290,9 @@
# Fails with WebKit1 only.
editing/secure-input/reset-state-on-navigation.html [ Failure ]
+# Context menu API is not exposed on DumpRenderTree.
+editing/mac/spelling/disable-automatic-spelling-correction-context-menu-item.html [ Skip ]
+
http/tests/plugins/nounsupported-plugin.html [ Skip ]
http/tests/plugins/supported-plugin-all-origin-visibility.html [ Skip ]
http/tests/plugins/supported-plugin-origin-specific-visibility.html [ Skip ]
Modified: trunk/Source/WebCore/ChangeLog (271458 => 271459)
--- trunk/Source/WebCore/ChangeLog 2021-01-13 22:42:35 UTC (rev 271458)
+++ trunk/Source/WebCore/ChangeLog 2021-01-13 22:50:25 UTC (rev 271459)
@@ -1,3 +1,33 @@
+2021-01-13 Wenson Hsieh <[email protected]>
+
+ [macOS] "Correct Spelling Automatically" menu items are inconsistent when autocorrect="off"
+ https://bugs.webkit.org/show_bug.cgi?id=220598
+ <rdar://problem/71713611>
+
+ Reviewed by Tim Horton.
+
+ Disable the context menu item to toggle automatic spelling correction, as well as the menu bar item to toggle
+ automatic spelling correction, in the case where the autocorrect attribute is set to "off". See below for more
+ details.
+
+ Tests: editing/mac/spelling/disable-automatic-spelling-correction-context-menu-item.html
+ DisableAutomaticSpellingCorrection.AutocorrectAttribute
+
+ * editing/AlternativeTextController.cpp:
+ (WebCore::AlternativeTextController::canEnableAutomaticSpellingCorrection const):
+
+ Factor out logic for checking the `autocorrect` attribute into a separate helper function; this is used to
+ determine whether or not we should enable both the context menu item and menu item in the menu bar.
+
+ (WebCore::AlternativeTextController::isAutomaticSpellingCorrectionEnabled):
+ * editing/AlternativeTextController.h:
+ (WebCore::AlternativeTextController::UNLESS_ENABLED):
+ * editing/Editor.cpp:
+ (WebCore::Editor::canEnableAutomaticSpellingCorrection const):
+ * editing/Editor.h:
+ * page/ContextMenuController.cpp:
+ (WebCore::ContextMenuController::checkOrEnableIfNeeded const):
+
2021-01-13 Fujii Hironori <[email protected]>
Reimplement WebCore::isInWebProcess() family as cross-platform by using AuxiliaryProcessInitializationParameters.processType
Modified: trunk/Source/WebCore/editing/AlternativeTextController.cpp (271458 => 271459)
--- trunk/Source/WebCore/editing/AlternativeTextController.cpp 2021-01-13 22:42:35 UTC (rev 271458)
+++ trunk/Source/WebCore/editing/AlternativeTextController.cpp 2021-01-13 22:50:25 UTC (rev 271459)
@@ -335,11 +335,8 @@
m_rangeWithAlternative = WTF::nullopt;
}
-bool AlternativeTextController::isAutomaticSpellingCorrectionEnabled()
+bool AlternativeTextController::canEnableAutomaticSpellingCorrection() const
{
- if (!editorClient() || !editorClient()->isAutomaticSpellingCorrectionEnabled())
- return false;
-
#if ENABLE(AUTOCORRECT)
auto position = m_document.selection().selection().start();
if (auto editableRoot = position.rootEditableElement()) {
@@ -356,6 +353,14 @@
return true;
}
+bool AlternativeTextController::isAutomaticSpellingCorrectionEnabled()
+{
+ if (!editorClient() || !editorClient()->isAutomaticSpellingCorrectionEnabled())
+ return false;
+
+ return canEnableAutomaticSpellingCorrection();
+}
+
FloatRect AlternativeTextController::rootViewRectForRange(const SimpleRange& range) const
{
auto* view = m_document.view();
Modified: trunk/Source/WebCore/editing/AlternativeTextController.h (271458 => 271459)
--- trunk/Source/WebCore/editing/AlternativeTextController.h 2021-01-13 22:42:35 UTC (rev 271458)
+++ trunk/Source/WebCore/editing/AlternativeTextController.h 2021-01-13 22:50:25 UTC (rev 271459)
@@ -86,6 +86,7 @@
bool hasPendingCorrection() const UNLESS_ENABLED({ return false; })
bool isSpellingMarkerAllowed(const SimpleRange& misspellingRange) const UNLESS_ENABLED({ UNUSED_PARAM(misspellingRange); return true; })
bool isAutomaticSpellingCorrectionEnabled() UNLESS_ENABLED({ return false; })
+ bool canEnableAutomaticSpellingCorrection() const UNLESS_ENABLED({ return false; })
bool shouldRemoveMarkersUponEditing();
void recordAutocorrectionResponse(AutocorrectionResponse, const String& replacedString, const SimpleRange& replacementRange) UNLESS_ENABLED({ UNUSED_PARAM(replacedString); UNUSED_PARAM(replacementRange); })
Modified: trunk/Source/WebCore/editing/Editor.cpp (271458 => 271459)
--- trunk/Source/WebCore/editing/Editor.cpp 2021-01-13 22:42:35 UTC (rev 271458)
+++ trunk/Source/WebCore/editing/Editor.cpp 2021-01-13 22:50:25 UTC (rev 271459)
@@ -1765,6 +1765,11 @@
client()->toggleAutomaticTextReplacement();
}
+bool Editor::canEnableAutomaticSpellingCorrection() const
+{
+ return m_alternativeTextController->canEnableAutomaticSpellingCorrection();
+}
+
bool Editor::isAutomaticSpellingCorrectionEnabled()
{
return m_alternativeTextController->isAutomaticSpellingCorrectionEnabled();
Modified: trunk/Source/WebCore/editing/Editor.h (271458 => 271459)
--- trunk/Source/WebCore/editing/Editor.h 2021-01-13 22:42:35 UTC (rev 271458)
+++ trunk/Source/WebCore/editing/Editor.h 2021-01-13 22:50:25 UTC (rev 271459)
@@ -511,6 +511,7 @@
WEBCORE_EXPORT void toggleAutomaticTextReplacement();
WEBCORE_EXPORT bool isAutomaticSpellingCorrectionEnabled();
WEBCORE_EXPORT void toggleAutomaticSpellingCorrection();
+ WEBCORE_EXPORT bool canEnableAutomaticSpellingCorrection() const;
#endif
RefPtr<DocumentFragment> webContentFromPasteboard(Pasteboard&, const SimpleRange& context, bool allowPlainText, bool& chosePlainText);
Modified: trunk/Source/WebCore/page/ContextMenuController.cpp (271458 => 271459)
--- trunk/Source/WebCore/page/ContextMenuController.cpp 2021-01-13 22:42:35 UTC (rev 271458)
+++ trunk/Source/WebCore/page/ContextMenuController.cpp 2021-01-13 22:50:25 UTC (rev 271459)
@@ -1324,6 +1324,7 @@
break;
case ContextMenuItemTagCorrectSpellingAutomatically:
shouldCheck = frame->editor().isAutomaticSpellingCorrectionEnabled();
+ shouldEnable = frame->editor().canEnableAutomaticSpellingCorrection();
break;
case ContextMenuItemTagSmartCopyPaste:
shouldCheck = frame->editor().smartInsertDeleteEnabled();
Modified: trunk/Source/WebKit/ChangeLog (271458 => 271459)
--- trunk/Source/WebKit/ChangeLog 2021-01-13 22:42:35 UTC (rev 271458)
+++ trunk/Source/WebKit/ChangeLog 2021-01-13 22:50:25 UTC (rev 271459)
@@ -1,3 +1,25 @@
+2021-01-13 Wenson Hsieh <[email protected]>
+
+ [macOS] "Correct Spelling Automatically" menu items are inconsistent when autocorrect="off"
+ https://bugs.webkit.org/show_bug.cgi?id=220598
+ <rdar://problem/71713611>
+
+ Reviewed by Tim Horton.
+
+ Plumb the new `canEnableAutomaticSpellingCorrection` flag through `EditorState` to the UI process, where we can
+ consult it when validating user interface items (namely, the "Correct Spelling Automatically" menu item, which
+ corresponds to the `-toggleAutomaticSpellingCorrection:` selector).
+
+ * Shared/EditorState.cpp:
+ (WebKit::EditorState::PostLayoutData::encode const):
+ (WebKit::EditorState::PostLayoutData::decode):
+ (WebKit::operator<<):
+ * Shared/EditorState.h:
+ * UIProcess/Cocoa/WebViewImpl.mm:
+ (WebKit::WebViewImpl::validateUserInterfaceItem):
+ * WebProcess/WebPage/mac/WebPageMac.mm:
+ (WebKit::WebPage::getPlatformEditorState const):
+
2021-01-13 Alex Christensen <[email protected]>
Remove deprecated script and stylesheet SPI, replaced with more inclusively-named SPI
Modified: trunk/Source/WebKit/Shared/EditorState.cpp (271458 => 271459)
--- trunk/Source/WebKit/Shared/EditorState.cpp 2021-01-13 22:42:35 UTC (rev 271458)
+++ trunk/Source/WebKit/Shared/EditorState.cpp 2021-01-13 22:50:25 UTC (rev 271459)
@@ -132,6 +132,7 @@
encoder << candidateRequestStartPosition;
encoder << paragraphContextForCandidateRequest;
encoder << stringForCandidateRequest;
+ encoder << canEnableAutomaticSpellingCorrection;
#endif
#if PLATFORM(GTK) || PLATFORM(WPE)
encoder << surroundingContext;
@@ -224,6 +225,9 @@
if (!decoder.decode(result.stringForCandidateRequest))
return false;
+
+ if (!decoder.decode(result.canEnableAutomaticSpellingCorrection))
+ return false;
#endif
#if PLATFORM(GTK) || PLATFORM(WPE)
if (!decoder.decode(result.surroundingContext))
@@ -338,6 +342,8 @@
ts.dumpProperty("paragraphContextForCandidateRequest", editorState.postLayoutData().paragraphContextForCandidateRequest);
if (editorState.postLayoutData().stringForCandidateRequest.length())
ts.dumpProperty("stringForCandidateRequest", editorState.postLayoutData().stringForCandidateRequest);
+ if (editorState.postLayoutData().canEnableAutomaticSpellingCorrection)
+ ts.dumpProperty("canEnableAutomaticSpellingCorrection", editorState.postLayoutData().canEnableAutomaticSpellingCorrection);
#endif
if (editorState.postLayoutData().canCut)
Modified: trunk/Source/WebKit/Shared/EditorState.h (271458 => 271459)
--- trunk/Source/WebKit/Shared/EditorState.h 2021-01-13 22:42:35 UTC (rev 271458)
+++ trunk/Source/WebKit/Shared/EditorState.h 2021-01-13 22:50:25 UTC (rev 271459)
@@ -123,6 +123,7 @@
uint64_t candidateRequestStartPosition { 0 };
String paragraphContextForCandidateRequest;
String stringForCandidateRequest;
+ bool canEnableAutomaticSpellingCorrection { true };
#endif
#if PLATFORM(GTK) || PLATFORM(WPE)
String surroundingContext;
Modified: trunk/Source/WebKit/UIProcess/Cocoa/WebViewImpl.mm (271458 => 271459)
--- trunk/Source/WebKit/UIProcess/Cocoa/WebViewImpl.mm 2021-01-13 22:42:35 UTC (rev 271458)
+++ trunk/Source/WebKit/UIProcess/Cocoa/WebViewImpl.mm 2021-01-13 22:50:25 UTC (rev 271459)
@@ -3063,9 +3063,10 @@
}
if (action == @selector(toggleAutomaticSpellingCorrection:)) {
- bool checked = TextChecker::state().isAutomaticSpellingCorrectionEnabled;
- [menuItem(item) setState:checked ? NSControlStateValueOn : NSControlStateValueOff];
- return m_page->editorState().isContentEditable;
+ auto& editorState = m_page->editorState();
+ bool enable = editorState.isContentEditable && (editorState.isMissingPostLayoutData || editorState.postLayoutData().canEnableAutomaticSpellingCorrection);
+ menuItem(item).state = TextChecker::state().isAutomaticSpellingCorrectionEnabled && enable ? NSControlStateValueOn : NSControlStateValueOff;
+ return enable;
}
if (action == @selector(orderFrontSubstitutionsPanel:)) {
Modified: trunk/Source/WebKit/WebProcess/WebPage/mac/WebPageMac.mm (271458 => 271459)
--- trunk/Source/WebKit/WebProcess/WebPage/mac/WebPageMac.mm 2021-01-13 22:42:35 UTC (rev 271458)
+++ trunk/Source/WebKit/WebProcess/WebPage/mac/WebPageMac.mm 2021-01-13 22:50:25 UTC (rev 271459)
@@ -164,6 +164,7 @@
postLayoutData.selectedTextLength = characterCount({ *selectionStartBoundary, *selectionEnd });
postLayoutData.paragraphContextForCandidateRequest = contextRangeForCandidateRequest ? plainText(*contextRangeForCandidateRequest) : String();
postLayoutData.stringForCandidateRequest = frame.editor().stringForCandidateRequest();
+ postLayoutData.canEnableAutomaticSpellingCorrection = frame.editor().canEnableAutomaticSpellingCorrection();
auto quads = RenderObject::absoluteTextQuads(*selectedRange);
if (!quads.isEmpty())
Modified: trunk/Tools/ChangeLog (271458 => 271459)
--- trunk/Tools/ChangeLog 2021-01-13 22:42:35 UTC (rev 271458)
+++ trunk/Tools/ChangeLog 2021-01-13 22:50:25 UTC (rev 271459)
@@ -1,3 +1,23 @@
+2021-01-13 Wenson Hsieh <[email protected]>
+
+ [macOS] "Correct Spelling Automatically" menu items are inconsistent when autocorrect="off"
+ https://bugs.webkit.org/show_bug.cgi?id=220598
+ <rdar://problem/71713611>
+
+ Reviewed by Tim Horton.
+
+ * TestWebKitAPI/TestWebKitAPI.xcodeproj/project.pbxproj:
+ * TestWebKitAPI/Tests/mac/DisableAutomaticSpellingCorrection.mm: Added.
+
+ Add a new API test to verify that the `NSMenuItem` for toggling automatic spelling correction is invalid when
+ editing inside a form control with autocorrect="off".
+
+ * WebKitTestRunner/InjectedBundle/EventSendingController.cpp:
+ (WTR::getMenuItemEnabledCallback):
+
+ Add the readonly `enabled` JS property on context menu items. See the new layout test,
+ editing/mac/spelling/disable-automatic-spelling-correction-context-menu-item.html, for more information.
+
2021-01-13 Jonathan Bedard <[email protected]>
[webkitscmpy] Handle single commit touching multiple branches
Modified: trunk/Tools/TestWebKitAPI/TestWebKitAPI.xcodeproj/project.pbxproj (271458 => 271459)
--- trunk/Tools/TestWebKitAPI/TestWebKitAPI.xcodeproj/project.pbxproj 2021-01-13 22:42:35 UTC (rev 271458)
+++ trunk/Tools/TestWebKitAPI/TestWebKitAPI.xcodeproj/project.pbxproj 2021-01-13 22:50:25 UTC (rev 271459)
@@ -1197,6 +1197,7 @@
F4D2986E20FEE7370092D636 /* RunScriptAfterDocumentLoad.mm in Sources */ = {isa = PBXBuildFile; fileRef = F4D2986D20FEE7370092D636 /* RunScriptAfterDocumentLoad.mm */; };
F4D4F3B61E4E2BCB00BB2767 /* DragAndDropSimulatorIOS.mm in Sources */ = {isa = PBXBuildFile; fileRef = F4D4F3B41E4E2BCB00BB2767 /* DragAndDropSimulatorIOS.mm */; };
F4D4F3B91E4E36E400BB2767 /* DragAndDropTestsIOS.mm in Sources */ = {isa = PBXBuildFile; fileRef = F4D4F3B71E4E36E400BB2767 /* DragAndDropTestsIOS.mm */; };
+ F4D5D69525AF8BE400205280 /* DisableAutomaticSpellingCorrection.mm in Sources */ = {isa = PBXBuildFile; fileRef = F4D5D69425AF8BE400205280 /* DisableAutomaticSpellingCorrection.mm */; };
F4D5E4E81F0C5D38008C1A49 /* dragstart-clear-selection.html in Copy Resources */ = {isa = PBXBuildFile; fileRef = F4D5E4E71F0C5D27008C1A49 /* dragstart-clear-selection.html */; };
F4D65DA81F5E4704009D8C27 /* selected-text-image-link-and-editable.html in Copy Resources */ = {isa = PBXBuildFile; fileRef = F4D65DA71F5E46C0009D8C27 /* selected-text-image-link-and-editable.html */; };
F4D9818F2196B920008230FC /* editable-nested-lists.html in Copy Resources */ = {isa = PBXBuildFile; fileRef = F4D9818E2196B911008230FC /* editable-nested-lists.html */; };
@@ -2967,6 +2968,7 @@
F4D2986D20FEE7370092D636 /* RunScriptAfterDocumentLoad.mm */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.cpp.objcpp; path = RunScriptAfterDocumentLoad.mm; sourceTree = "<group>"; };
F4D4F3B41E4E2BCB00BB2767 /* DragAndDropSimulatorIOS.mm */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.objcpp; path = DragAndDropSimulatorIOS.mm; sourceTree = "<group>"; };
F4D4F3B71E4E36E400BB2767 /* DragAndDropTestsIOS.mm */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.objcpp; path = DragAndDropTestsIOS.mm; sourceTree = "<group>"; };
+ F4D5D69425AF8BE400205280 /* DisableAutomaticSpellingCorrection.mm */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.cpp.objcpp; path = DisableAutomaticSpellingCorrection.mm; sourceTree = "<group>"; };
F4D5E4E71F0C5D27008C1A49 /* dragstart-clear-selection.html */ = {isa = PBXFileReference; lastKnownFileType = text.html; path = "dragstart-clear-selection.html"; sourceTree = "<group>"; };
F4D65DA71F5E46C0009D8C27 /* selected-text-image-link-and-editable.html */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.html; path = "selected-text-image-link-and-editable.html"; sourceTree = "<group>"; };
F4D9818E2196B911008230FC /* editable-nested-lists.html */ = {isa = PBXFileReference; lastKnownFileType = text.html; path = "editable-nested-lists.html"; sourceTree = "<group>"; };
@@ -4505,6 +4507,7 @@
7AEAD47C1E20113800416EFE /* CrossPartitionFileSchemeAccess.mm */,
E5AA8D1C25151CC60051CC45 /* DateInputTests.mm */,
939BA91614103412001A01BD /* DeviceScaleFactorOnBack.mm */,
+ F4D5D69425AF8BE400205280 /* DisableAutomaticSpellingCorrection.mm */,
37E1064A1697676400B78BD0 /* DOMHTMLTableCellCellAbove.mm */,
2D51A0C51C8BF00400765C45 /* DOMHTMLVideoElementWrapper.mm */,
46397B941DC2C850009A78AE /* DOMNode.mm */,
@@ -5194,6 +5197,8 @@
7CCE7EE91A411AE600447C4C /* DidAssociateFormControls.cpp in Sources */,
7CCE7EEA1A411AE600447C4C /* DidNotHandleKeyDown.cpp in Sources */,
AD57AC211DA7465B00FF1BDE /* DidRemoveFrameFromHiearchyInPageCache.cpp in Sources */,
+ F4D5D69525AF8BE400205280 /* DisableAutomaticSpellingCorrection.mm in Sources */,
+ F4B0168325AE060F00E445C4 /* DisableSpellcheck.mm in Sources */,
FEC2A85424CE975F00ADBC35 /* DisallowVMEntry.cpp in Sources */,
F4094CC725545BD5003D73E3 /* DisplayListTests.cpp in Sources */,
F457275E25578D06007ACA34 /* DisplayListTestsCG.cpp in Sources */,
@@ -5520,7 +5525,6 @@
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 */,
@@ -5704,7 +5708,6 @@
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 */,
@@ -5713,6 +5716,7 @@
A14FC58B1B89927100D107EB /* ContentFilteringPlugIn.mm in Sources */,
5C121E8D2410704900486F9B /* ContentWorldPlugIn.mm in Sources */,
CEA7F57D2089624B0078EF6E /* DidResignInputElementStrongPasswordAppearance.mm in Sources */,
+ F4B0168425AE08F800E445C4 /* DisableSpellcheckPlugIn.mm in Sources */,
518EE51920A78CE500E024F3 /* DoubleDefersLoadingPlugin.mm in Sources */,
5CB5B3C21FFC55CF00C27BB0 /* FrameHandleSerialization.mm in Sources */,
0E404A8C2166DE0A008271BA /* InjectedBundleNodeHandleIsSelectElement.mm in Sources */,
Added: trunk/Tools/TestWebKitAPI/Tests/mac/DisableAutomaticSpellingCorrection.mm (0 => 271459)
--- trunk/Tools/TestWebKitAPI/Tests/mac/DisableAutomaticSpellingCorrection.mm (rev 0)
+++ trunk/Tools/TestWebKitAPI/Tests/mac/DisableAutomaticSpellingCorrection.mm 2021-01-13 22:50:25 UTC (rev 271459)
@@ -0,0 +1,44 @@
+/*
+ * 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 <wtf/RetainPtr.h>
+
+TEST(DisableAutomaticSpellingCorrection, AutocorrectAttribute)
+{
+ auto webView = adoptNS([[TestWKWebView alloc] initWithFrame:NSMakeRect(0, 0, 400, 400)]);
+ [webView synchronouslyLoadHTMLString:@"<body><input autocorrect='off' autofocus><input autocorrect='on'></body>"];
+ [webView waitForNextPresentationUpdate];
+
+ auto item = adoptNS([[NSMenuItem alloc] init]);
+ [item setAction:@selector(toggleAutomaticSpellingCorrection:)];
+ EXPECT_FALSE([webView validateUserInterfaceItem:item.get()]);
+
+ [webView stringByEvaluatingJavaScript:@"document.querySelector('input[autocorrect=on]').focus()"];
+ [webView waitForNextPresentationUpdate];
+ EXPECT_TRUE([webView validateUserInterfaceItem:item.get()]);
+}
Modified: trunk/Tools/WebKitTestRunner/InjectedBundle/EventSendingController.cpp (271458 => 271459)
--- trunk/Tools/WebKitTestRunner/InjectedBundle/EventSendingController.cpp 2021-01-13 22:42:35 UTC (rev 271458)
+++ trunk/Tools/WebKitTestRunner/InjectedBundle/EventSendingController.cpp 2021-01-13 22:50:25 UTC (rev 271459)
@@ -67,6 +67,12 @@
return JSValueMakeString(context, toJS(wkTitle).get());
}
+static JSValueRef getMenuItemEnabledCallback(JSContextRef context, JSObjectRef object, JSStringRef propertyName, JSValueRef* exception)
+{
+ auto* privateData = static_cast<MenuItemPrivateData*>(JSObjectGetPrivate(object));
+ return JSValueMakeBoolean(context, WKContextMenuItemGetEnabled(privateData->m_item.get()));
+}
+
static JSClassRef getMenuItemClass();
static JSValueRef getMenuItemChildrenCallback(JSContextRef context, JSObjectRef object, JSStringRef propertyName, JSValueRef* exception)
@@ -90,6 +96,7 @@
static JSStaticValue staticMenuItemValues[] = {
{ "title", getMenuItemTitleCallback, 0, kJSPropertyAttributeReadOnly },
{ "children", getMenuItemChildrenCallback, 0, kJSPropertyAttributeReadOnly },
+ { "enabled", getMenuItemEnabledCallback, 0, kJSPropertyAttributeReadOnly },
{ 0, 0, 0, 0 }
};