haikuwebkit/LayoutTests/fast/forms/selection-direction.html

106 lines
3.5 KiB
HTML
Raw Permalink Normal View History

<!DOCTYPE html>
<html>
<head>
<script src="../../resources/js-test-pre.js"></script>
</head>
<body>
<p id="description"></p>
<div><input id="dummy"></div>
<div id="tests"><input value="hello"><textarea>hello</textarea></div>
<div id="console"></div>
<div>
<script type="text/javascript">
description('Tests for selectionDirection');
var dummy = document.getElementById('dummy');
function assertDirection(expectedDirection, element, description) {
var action = 'selectionDirection was "' + element.selectionDirection
+ '" after ' + description;
if (element.selectionDirection == expectedDirection)
testPassed(action);
else
testFailed(action + ', but expected "' + expectedDirection + '"');
}
function testCache(expectedDirection, element) {
dummy.focus();
assertDirection(expectedDirection, element, 'focusing on another element');
element.style.display = 'none';
assertDirection(expectedDirection, element, 'hiding the element');
element.style.display = null;
}
function runTest(element, platform) {
debug(element.localName + ' on ' + platform);
element.focus();
var noneOnMacAndForwardOnOthers = (platform == 'Mac') ? 'none' : 'forward';
element.setSelectionRange(1, 2);
assertDirection(noneOnMacAndForwardOnOthers, element, 'focusing and setting selection by setSelectionRange(1, 2)');
testCache(noneOnMacAndForwardOnOthers, element);
element.focus();
element.setSelectionRange(1, 2, 'forward');
assertDirection('forward', element, 'focusing and setting selection by setSelectionRange(1, 2, "forward")');
testCache('forward', element);
element.setSelectionRange(1, 2, 'backward');
assertDirection('backward', element, 'setting selection by setSelectionRange(1, 2, "backward") without focus');
testCache('backward', element);
element.selectionDirection = 'none';
assertDirection(noneOnMacAndForwardOnOthers, element, 'setting selection by selectionDirection = "none" without focus');
testCache(noneOnMacAndForwardOnOthers, element);
element.selectionDirection = 'forward';
assertDirection('forward', element, 'focusing and setting selection by selectionDirection = "forward" without focus');
testCache('forward', element);
element.focus();
element.selectionDirection = 'backward';
assertDirection('backward', element, 'focusing and setting selection by selectionDirection = "backward"');
testCache('backward', element);
element.focus();
element.setSelectionRange(1, 1);
window.getSelection().modify('extend', 'forward', 'character');
assertDirection('forward', element, 'extending selection forward by character');
testCache('forward', element);
element.focus();
element.setSelectionRange(1, 1);
window.getSelection().modify('extend', 'backward', 'character');
assertDirection('backward', element, 'extending selection backward by character');
testCache('backward', element);
}
function runTestFor(platform) {
if (window.internals)
internals.settings.setEditingBehavior(platform.toLowerCase());
var tests = document.getElementById('tests');
for (var i = 0; i < tests.childNodes.length; i++) {
runTest(tests.childNodes[i], platform);
debug('');
}
}
if (window.internals) {
runTestFor('Mac');
Source/WebCore: Standardize enums that are used by Settings in preperation for autogeneration https://bugs.webkit.org/show_bug.cgi?id=218960 Reviewed by Tim Horton. Move each enum type used by Settings to its own header and make them all scoped enums in preparation for using them in the generated settings code. Also converted enums used in Settings that are used as flags to use OptionSet, adding the necessary EnumTraits to make it to work. In the change, Settings still generates with getters/setters that work on the raw enum, but in subsequent changes the generation will work directly with OptionSets. * Headers.cmake: * WebCore.xcodeproj/project.pbxproj: Add new headers, adjust for renames. * Scripts/GenerateSettings.rb: Add special case for HTML prefix to keep renamed HTMLParserScriptingFlagPolicy setting using WebCore consistent capitalization. * accessibility/ForcedAccessibilityValue.h: Added. * css/FontLoadTimingOverride.h: Added. * editing/EditableLinkBehavior.h: Added. * editing/cocoa/DataDetectorTypes.h: Added. * html/parser/HTMLParserScriptingFlagPolicy.h: Added. * page/FrameFlattening.h: Added. * page/PDFImageCachingPolicy.h: Added. * page/DebugOverlayRegions.h: Added. * page/StorageBlockingPolicy.h: Added. * page/TextDirectionSubmenuInclusionBehavior.h: Added. * page/UserInterfaceDirectionPolicy.h: Added. * platform/text/FontRenderingMode.h: Added. * platform/text/TextDirection.h: Added. Add new headers. * editing/EditingBehaviorType.h: Added. * editing/EditingBehaviorTypes.h: Removed. Renamed header to match enum name. * css/CSSFontFace.cpp: (WebCore::fontLoadTimingOverride): (WebCore::CSSFontFace::fontLoadTiming const): Update uses of FontLoadTimingOverride to remove Settings scoping. * css/MediaQueryEvaluator.cpp: (WebCore::monochromeEvaluate): (WebCore::invertedColorsEvaluate): (WebCore::dynamicRangeEvaluate): (WebCore::prefersReducedMotionEvaluate): Update uses of ForcedAccessibilityValue to remove Settings scoping. * dom/Document.cpp: (WebCore::Document::applyQuickLookSandbox): Update uses of StorageBlockingPolicy to remove SecurityOrigin scoping. * editing/EditingBehavior.h: Update use of EditingBehaviorType to use scoped syntax. * editing/Editor.cpp: (WebCore::Editor::behavior const): Remove unnecessary duplication of EditingBehavior construction. * editing/cocoa/DataDetection.h: * editing/cocoa/DataDetection.mm: Switch to using OptionSet<DataDetectorTypes> rather than raw DataDetectorTypes. * editing/markup.cpp: (WebCore::createPageForSanitizingWebContent): Update for renamed setter now called setHTMLParserScriptingFlagPolicy to make it clear it is about the HTML parser. * html/HTMLAnchorElement.cpp: (WebCore::HTMLAnchorElement::setActive): (WebCore::HTMLAnchorElement::treatLinkAsLiveForEventType const): Update use of EditableLinkBehavior to use scoped syntax. * html/parser/HTMLParserOptions.cpp: (WebCore::HTMLParserOptions::HTMLParserOptions): Update for renamed setting now called HTMLParserScriptingFlagPolicy to make it clear it is about the HTML parser and no longer scoped to Settings. * loader/FrameLoader.cpp: (WebCore::FrameLoader::checkLoadCompleteForThisFrame): Switch to using OptionSet<DataDetectorTypes> rather than raw DataDetectorTypes. * page/ContextMenuController.cpp: (WebCore::ContextMenuController::populate): Update use of TextDirectionSubmenuInclusionBehavior to use scoped syntax. * page/DebugPageOverlays.cpp: (WebCore::DebugPageOverlays::updateOverlayRegionVisibility): (WebCore::DebugPageOverlays::settingsChanged): * page/DebugPageOverlays.h: Switch to using OptionSet<DebugOverlayRegions> rather than raw DebugOverlayRegions. * page/EventHandler.cpp: (WebCore::EventHandler::useHandCursor): Update use of EditableLinkBehavior to use scoped syntax. * page/FrameView.h: Switch to #including FrameFlattening.h since it is such a trivial include now. * page/Page.cpp: (WebCore::Page::shouldBuildEditableRegion const): Switch to using OptionSet<DebugOverlayRegions> rather than raw DebugOverlayRegions. * page/SecurityOrigin.cpp: * page/SecurityOrigin.h: Update to now include StorageBlockingPolicy.h and switch to use scoped syntax. * page/Settings.yaml: Update setting defaults to use new scoped names where appropriate and rename ParserScriptingFlagPolicy to HTMLParserScriptingFlagPolicy to make it clear which parser it is for. * page/SettingsBase.h: Replace enum definitions with #includes for the new headers. In future changes, these will be automatically included in the generated code and this won't be necessary anymore. * platform/DragImage.h: * platform/graphics/FontDescription.h: Update #includes to keep things building. * platform/graphics/cg/PDFDocumentImage.cpp: (WebCore::PDFDocumentImage::updateCachedImageIfNeeded): * platform/graphics/cg/PDFDocumentImage.h: Update use of PDFImageCachingPolicy to use scoped syntax. * platform/text/TextFlags.h: Extract FontRenderingMode into its own header. * platform/text/WritingMode.h: Extract TextDirection into its own header. Also replace some macros with constexprs while I was here. * rendering/RenderLayer.cpp: (WebCore::RenderLayer::calculateClipRects const): * rendering/RenderLayerBacking.cpp: (WebCore::RenderLayerBacking::paintDebugOverlays): (WebCore::RenderLayerBacking::paintContents): Switch to using OptionSet<DebugOverlayRegions> rather than raw DebugOverlayRegions. * testing/InternalSettings.cpp: * testing/InternalSettings.h: * testing/InternalSettings.idl: Use new enums rather than redeclaring them. Updates EditingBehaviorType to use the value "windows" rather than "win" which requires test changes as does changes to capitalization of PDFImageCachingPolicy enum values. * workers/service/context/ServiceWorkerThreadProxy.cpp: (WebCore::createPageForServiceWorker): (WebCore::ServiceWorkerThreadProxy::ServiceWorkerThreadProxy): * workers/service/context/ServiceWorkerThreadProxy.h: Update for extracted StorageBlockingPolicy enum. Source/WebKit: Standardize enums that are used by Settings in preperation for autogeneration https://bugs.webkit.org/show_bug.cgi?id=218960 Reviewed by Tim Horton. Update enum uses for renames and scoped syntax use. * UIProcess/API/C/WKAPICast.h: (WebKit::toAPI): (WebKit::toEditableLinkBehavior): (WebKit::toStorageBlockingPolicy): * UIProcess/API/C/WKPreferences.cpp: (WKPreferencesSetEditableLinkBehavior): (WKPreferencesSetStorageBlockingPolicy): (WKPreferencesGetStorageBlockingPolicy): * UIProcess/API/Cocoa/WKPreferences.mm: (toStorageBlockingPolicy): (toAPI): (-[WKPreferences _storageBlockingPolicy]): (-[WKPreferences _setStorageBlockingPolicy:]): (toEditableLinkBehavior): (-[WKPreferences _setEditableLinkBehavior:]): * UIProcess/WebPreferences.cpp: (WebKit::WebPreferences::createWithLegacyDefaults): * WebProcess/Storage/WebSWContextManagerConnection.cpp: (WebKit::WebSWContextManagerConnection::updatePreferencesStore): * WebProcess/Storage/WebSWContextManagerConnection.h: * WebProcess/WebPage/WebPage.cpp: (WebKit::WebPage::updatePreferences): (WebKit::WebPage::detectDataInAllFrames): Source/WebKitLegacy/mac: Standardize enums that are used by Settings in preperation for autogeneration https://bugs.webkit.org/show_bug.cgi?id=218960 Reviewed by Tim Horton. Update enum uses for renames and scoped syntax use. * WebView/WebFrame.mm: * WebView/WebView.mm: Source/WTF: Standardize enums that are used by Settings in preperation for autogeneration https://bugs.webkit.org/show_bug.cgi?id=218960 Reviewed by Tim Horton. Update enum uses in default WebPreferences values for renames and scoped syntax use. * Scripts/Preferences/WebPreferences.yaml: LayoutTests: Standardize enums that are used by Settings in preparation for autogeneration https://bugs.webkit.org/show_bug.cgi?id=218960 Reviewed by Tim Horton. Update tests and results for change in EditingBahavior enum value "win" -> "windows". * editing/deleting/delete-ligature-003-expected.txt: * editing/deleting/delete-ligature-003.html: * editing/deleting/paragraph-in-preserveNewline-expected.txt: * editing/deleting/paragraph-in-preserveNewline.html: * editing/deleting/smart-editing-disabled-win.html: * editing/deleting/whitespace-pre-1-expected.txt: * editing/deleting/whitespace-pre-1.html: * editing/execCommand/query-command-state-expected.txt: * editing/execCommand/query-command-state.html: * editing/execCommand/query-text-alignment-expected.txt: * editing/execCommand/query-text-alignment.html: * editing/execCommand/remove-format-multiple-elements-win.html: * editing/execCommand/toggle-compound-styles-expected.txt: * editing/execCommand/toggle-compound-styles.html: * editing/execCommand/toggle-link-win.html: * editing/execCommand/toggle-unlink-win.html: * editing/selection/5195166-1.html: * editing/selection/5354455-1.html: * editing/selection/click-in-margins-inside-editable-div.html: * editing/selection/click-in-padding-with-multiple-line-boxes.html: * editing/selection/context-menu-text-selection-lookup.html: * editing/selection/context-menu-text-selection.html: * editing/selection/extend-after-mouse-selection.html: * editing/selection/extend-selection-after-double-click.html: * editing/selection/extend-selection-enclosing-block-win.html: * editing/selection/move-by-word-visually-crash-test-1.html: * editing/selection/move-by-word-visually-crash-test-2.html: * editing/selection/move-by-word-visually-crash-test-3.html: * editing/selection/move-by-word-visually-crash-test-4.html: * editing/selection/move-by-word-visually-crash-test-5.html: * editing/selection/move-by-word-visually-crash-test-css-generated-content.html: * editing/selection/move-by-word-visually-crash-test-textarea.html: * editing/selection/move-by-word-visually-inline-block-positioned-element.html: * editing/selection/move-by-word-visually-multi-line.html: * editing/selection/move-by-word-visually-multi-space.html: * editing/selection/move-by-word-visually-null-box.html: * editing/selection/move-by-word-visually-single-space-inline-element.html: * editing/selection/move-by-word-visually-single-space-one-element.html: * editing/selection/move-by-word-visually-textarea.html: * editing/selection/move-by-word-visually-wrong-left-right.html: * editing/selection/programmatic-selection-on-mac-is-directionless-expected.txt: * editing/selection/programmatic-selection-on-mac-is-directionless.html: * editing/selection/rtl-move-selection-right-left.html: * editing/selection/selection-extend-should-not-move-across-caret-on-mac-expected.txt: * editing/selection/selection-extend-should-not-move-across-caret-on-mac.html: * editing/selection/shift-click.html: * editing/selection/user-select-all-with-shift-expected.txt: * editing/selection/user-select-all-with-shift.html: * editing/spelling/copy-paste-crash.html: * editing/style/iframe-onload-crash-win.html: * editing/style/make-text-writing-direction-inline-win.html: * editing/style/push-down-font-styles-win.html: * editing/style/push-down-implicit-styles-around-list-win.html: * editing/style/toggle-style-bold-italic-expected.txt: * editing/style/toggle-style-bold-italic-mixed-editability-expected.txt: * editing/style/toggle-style-bold-italic-mixed-editability.html: * editing/style/toggle-style-bold-italic.html: * fast/events/backspace-navigates-back.html: * fast/forms/selection-direction-expected.txt: * fast/forms/selection-direction.html: Canonical link: https://commits.webkit.org/231641@main git-svn-id: https://svn.webkit.org/repository/webkit/trunk@269888 268f45cc-cd09-0410-ab3c-d52691b4dbfc
2020-11-17 01:34:46 +00:00
runTestFor('Windows');
runTestFor('Unix');
} else
runTestFor(navigator.platform.indexOf('Mac') >= 0 ? 'Mac' : 'Win');
tests.style.display = 'none';
dummy.parentNode.style.display = 'none';
</script>
<script src="../../resources/js-test-post.js"></script>
</body>
</html>