<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1//EN"
"http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head><meta http-equiv="content-type" content="text/html; charset=utf-8" />
<title>[278736] trunk</title>
</head>
<body>

<style type="text/css"><!--
#msg dl.meta { border: 1px #006 solid; background: #369; padding: 6px; color: #fff; }
#msg dl.meta dt { float: left; width: 6em; font-weight: bold; }
#msg dt:after { content:':';}
#msg dl, #msg dt, #msg ul, #msg li, #header, #footer, #logmsg { font-family: verdana,arial,helvetica,sans-serif; font-size: 10pt;  }
#msg dl a { font-weight: bold}
#msg dl a:link    { color:#fc3; }
#msg dl a:active  { color:#ff0; }
#msg dl a:visited { color:#cc6; }
h3 { font-family: verdana,arial,helvetica,sans-serif; font-size: 10pt; font-weight: bold; }
#msg pre { overflow: auto; background: #ffc; border: 1px #fa0 solid; padding: 6px; }
#logmsg { background: #ffc; border: 1px #fa0 solid; padding: 1em 1em 0 1em; }
#logmsg p, #logmsg pre, #logmsg blockquote { margin: 0 0 1em 0; }
#logmsg p, #logmsg li, #logmsg dt, #logmsg dd { line-height: 14pt; }
#logmsg h1, #logmsg h2, #logmsg h3, #logmsg h4, #logmsg h5, #logmsg h6 { margin: .5em 0; }
#logmsg h1:first-child, #logmsg h2:first-child, #logmsg h3:first-child, #logmsg h4:first-child, #logmsg h5:first-child, #logmsg h6:first-child { margin-top: 0; }
#logmsg ul, #logmsg ol { padding: 0; list-style-position: inside; margin: 0 0 0 1em; }
#logmsg ul { text-indent: -1em; padding-left: 1em; }#logmsg ol { text-indent: -1.5em; padding-left: 1.5em; }
#logmsg > ul, #logmsg > ol { margin: 0 0 1em 0; }
#logmsg pre { background: #eee; padding: 1em; }
#logmsg blockquote { border: 1px solid #fa0; border-left-width: 10px; padding: 1em 1em 0 1em; background: white;}
#logmsg dl { margin: 0; }
#logmsg dt { font-weight: bold; }
#logmsg dd { margin: 0; padding: 0 0 0.5em 0; }
#logmsg dd:before { content:'\00bb';}
#logmsg table { border-spacing: 0px; border-collapse: collapse; border-top: 4px solid #fa0; border-bottom: 1px solid #fa0; background: #fff; }
#logmsg table th { text-align: left; font-weight: normal; padding: 0.2em 0.5em; border-top: 1px dotted #fa0; }
#logmsg table td { text-align: right; border-top: 1px dotted #fa0; padding: 0.2em 0.5em; }
#logmsg table thead th { text-align: center; border-bottom: 1px solid #fa0; }
#logmsg table th.Corner { text-align: left; }
#logmsg hr { border: none 0; border-top: 2px dashed #fa0; height: 1px; }
#header, #footer { color: #fff; background: #636; border: 1px #300 solid; padding: 6px; }
#patch { width: 100%; }
#patch h4 {font-family: verdana,arial,helvetica,sans-serif;font-size:10pt;padding:8px;background:#369;color:#fff;margin:0;}
#patch .propset h4, #patch .binary h4 {margin:0;}
#patch pre {padding:0;line-height:1.2em;margin:0;}
#patch .diff {width:100%;background:#eee;padding: 0 0 10px 0;overflow:auto;}
#patch .propset .diff, #patch .binary .diff  {padding:10px 0;}
#patch span {display:block;padding:0 10px;}
#patch .modfile, #patch .addfile, #patch .delfile, #patch .propset, #patch .binary, #patch .copfile {border:1px solid #ccc;margin:10px 0;}
#patch ins {background:#dfd;text-decoration:none;display:block;padding:0 10px;}
#patch del {background:#fdd;text-decoration:none;display:block;padding:0 10px;}
#patch .lines, .info {color:#888;background:#fff;}
--></style>
<div id="msg">
<dl class="meta">
<dt>Revision</dt> <dd><a href="http://trac.webkit.org/projects/webkit/changeset/278736">278736</a></dd>
<dt>Author</dt> <dd>ryanhaddad@apple.com</dd>
<dt>Date</dt> <dd>2021-06-10 16:10:49 -0700 (Thu, 10 Jun 2021)</dd>
</dl>

<h3>Log Message</h3>
<pre>AX: TestWebKitAPI.WebKit.AccessibilityReduceMotion failing on iOS
https://bugs.webkit.org/show_bug.cgi?id=226758
<rdar://problem/78984253>

Patch by Chris Fleizach <cfleizach@apple.com> on 2021-06-10
Reviewed by Alex Christensen.

Source/WebKit:

For releases that don't have the accessibility update method, the direct setters need to be called
in order to update the cache.

* Platform/spi/Cocoa/AccessibilitySupportSPI.h:
* WebProcess/cocoa/WebProcessCocoa.mm:
(WebKit::increaseContrastPreferenceKey):
(WebKit::setPreferenceValue):

Tools:

* TestWebKitAPI/TestWebKitAPI.xcodeproj/project.pbxproj:
* TestWebKitAPI/Tests/WebKit/AccessibilityIncreaseContrast.mm: Added.
(-[WKPreferenceObserverForTestingIncreaseContrast preferenceDidChange:key:encodedValue:]):
(TEST):</pre>

<h3>Modified Paths</h3>
<ul>
<li><a href="#trunkSourceWTFwtfPlatformHaveh">trunk/Source/WTF/wtf/PlatformHave.h</a></li>
<li><a href="#trunkSourceWebKitChangeLog">trunk/Source/WebKit/ChangeLog</a></li>
<li><a href="#trunkSourceWebKitPlatformspiCocoaAccessibilitySupportSPIh">trunk/Source/WebKit/Platform/spi/Cocoa/AccessibilitySupportSPI.h</a></li>
<li><a href="#trunkSourceWebKitWebProcesscocoaWebProcessCocoamm">trunk/Source/WebKit/WebProcess/cocoa/WebProcessCocoa.mm</a></li>
<li><a href="#trunkToolsChangeLog">trunk/Tools/ChangeLog</a></li>
<li><a href="#trunkToolsTestWebKitAPITestWebKitAPIxcodeprojprojectpbxproj">trunk/Tools/TestWebKitAPI/TestWebKitAPI.xcodeproj/project.pbxproj</a></li>
</ul>

<h3>Added Paths</h3>
<ul>
<li><a href="#trunkToolsTestWebKitAPITestsWebKitAccessibilityIncreaseContrastmm">trunk/Tools/TestWebKitAPI/Tests/WebKit/AccessibilityIncreaseContrast.mm</a></li>
</ul>

</div>
<div id="patch">
<h3>Diff</h3>
<a id="trunkSourceWTFwtfPlatformHaveh"></a>
<div class="modfile"><h4>Modified: trunk/Source/WTF/wtf/PlatformHave.h (278735 => 278736)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WTF/wtf/PlatformHave.h      2021-06-10 22:19:21 UTC (rev 278735)
+++ trunk/Source/WTF/wtf/PlatformHave.h 2021-06-10 23:10:49 UTC (rev 278736)
</span><span class="lines">@@ -1006,6 +1006,11 @@
</span><span class="cx"> #define HAVE_UIDATEPICKER_INSETS 1
</span><span class="cx"> #endif
</span><span class="cx"> 
</span><ins>+#if (((PLATFORM(IOS) || PLATFORM(MACCATALYST)) && __IPHONE_OS_VERSION_MIN_REQUIRED >= 150000) \
+    || (PLATFORM(MAC) && __MAC_OS_X_VERSION_MIN_REQUIRED >= 120000))
+#define UPDATE_WEB_ACCESSIBILITY_SETTINGS 1
+#endif
+
</ins><span class="cx"> #if PLATFORM(IOS) || PLATFORM(MACCATALYST)
</span><span class="cx"> #define HAVE_UIBLUREFFECT_STYLE_SYSTEM_MATERIAL 1
</span><span class="cx"> #endif
</span></span></pre></div>
<a id="trunkSourceWebKitChangeLog"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebKit/ChangeLog (278735 => 278736)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebKit/ChangeLog    2021-06-10 22:19:21 UTC (rev 278735)
+++ trunk/Source/WebKit/ChangeLog       2021-06-10 23:10:49 UTC (rev 278736)
</span><span class="lines">@@ -1,3 +1,19 @@
</span><ins>+2021-06-10  Chris Fleizach  <cfleizach@apple.com>
+
+        AX: TestWebKitAPI.WebKit.AccessibilityReduceMotion failing on iOS
+        https://bugs.webkit.org/show_bug.cgi?id=226758
+        <rdar://problem/78984253>
+
+        Reviewed by Alex Christensen.
+
+        For releases that don't have the accessibility update method, the direct setters need to be called
+        in order to update the cache.
+
+        * Platform/spi/Cocoa/AccessibilitySupportSPI.h:
+        * WebProcess/cocoa/WebProcessCocoa.mm:
+        (WebKit::increaseContrastPreferenceKey):
+        (WebKit::setPreferenceValue):
+
</ins><span class="cx"> 2021-06-10  Aditya Keerthi  <akeerthi@apple.com>
</span><span class="cx"> 
</span><span class="cx">         [iOS] VinylWall app crashes when tapping on 'format' dropdown menu in 'Add Record' menu
</span></span></pre></div>
<a id="trunkSourceWebKitPlatformspiCocoaAccessibilitySupportSPIh"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebKit/Platform/spi/Cocoa/AccessibilitySupportSPI.h (278735 => 278736)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebKit/Platform/spi/Cocoa/AccessibilitySupportSPI.h 2021-06-10 22:19:21 UTC (rev 278735)
+++ trunk/Source/WebKit/Platform/spi/Cocoa/AccessibilitySupportSPI.h    2021-06-10 23:10:49 UTC (rev 278736)
</span><span class="lines">@@ -33,6 +33,8 @@
</span><span class="cx"> 
</span><span class="cx"> WTF_EXTERN_C_BEGIN
</span><span class="cx"> 
</span><ins>+extern void _AXSSetReduceMotionEnabled(Boolean enabled);
+extern void _AXSSetDarkenSystemColors(Boolean enabled);
</ins><span class="cx"> extern Boolean _AXSKeyRepeatEnabled();
</span><span class="cx"> extern Boolean _AXSApplicationAccessibilityEnabled();
</span><span class="cx"> extern CFStringRef kAXSApplicationAccessibilityEnabledNotification;
</span></span></pre></div>
<a id="trunkSourceWebKitWebProcesscocoaWebProcessCocoamm"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebKit/WebProcess/cocoa/WebProcessCocoa.mm (278735 => 278736)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebKit/WebProcess/cocoa/WebProcessCocoa.mm  2021-06-10 22:19:21 UTC (rev 278735)
+++ trunk/Source/WebKit/WebProcess/cocoa/WebProcessCocoa.mm     2021-06-10 23:10:49 UTC (rev 278736)
</span><span class="lines">@@ -86,6 +86,7 @@
</span><span class="cx"> #import <pal/spi/cf/CFUtilitiesSPI.h>
</span><span class="cx"> #import <pal/spi/cg/CoreGraphicsSPI.h>
</span><span class="cx"> #import <pal/spi/cocoa/AVFoundationSPI.h>
</span><ins>+#import <pal/spi/cocoa/AccessibilitySupportSPI.h>
</ins><span class="cx"> #import <pal/spi/cocoa/CoreServicesSPI.h>
</span><span class="cx"> #import <pal/spi/cocoa/LaunchServicesSPI.h>
</span><span class="cx"> #import <pal/spi/cocoa/NSAccessibilitySPI.h>
</span><span class="lines">@@ -173,7 +174,7 @@
</span><span class="cx"> SOFT_LINK_FUNCTION_MAY_FAIL_FOR_SOURCE(WebKit, HIServices, _AXSetAuditTokenIsAuthenticatedCallback, void, (AXAuditTokenIsAuthenticatedCallback callback), (callback))
</span><span class="cx"> #endif
</span><span class="cx"> 
</span><del>-#if ENABLE(CFPREFS_DIRECT_MODE)
</del><ins>+#if HAVE(UPDATE_WEB_ACCESSIBILITY_SETTINGS) && ENABLE(CFPREFS_DIRECT_MODE)
</ins><span class="cx"> SOFT_LINK_LIBRARY(libAccessibility)
</span><span class="cx"> SOFT_LINK_OPTIONAL(libAccessibility, _AXSUpdateWebAccessibilitySettings, void, (), ());
</span><span class="cx"> #endif
</span><span class="lines">@@ -1078,6 +1079,14 @@
</span><span class="cx"> }
</span><span class="cx"> #endif
</span><span class="cx"> 
</span><ins>+#if PLATFORM(IOS_FAMILY)
+static const WTF::String& increaseContrastPreferenceKey()
+{
+    static NeverDestroyed<WTF::String> key(MAKE_STATIC_STRING_IMPL("DarkenSystemColors"));
+    return key;
+}
+#endif
+
</ins><span class="cx"> static const WTF::String& captionProfilePreferenceKey()
</span><span class="cx"> {
</span><span class="cx">     static NeverDestroyed<WTF::String> key(MAKE_STATIC_STRING_IMPL("MACaptionActiveProfile"));
</span><span class="lines">@@ -1130,8 +1139,17 @@
</span><span class="cx">     }
</span><span class="cx"> 
</span><span class="cx">     if (domain == String(kAXSAccessibilityPreferenceDomain)) {
</span><ins>+#if HAVE(UPDATE_WEB_ACCESSIBILITY_SETTINGS) && ENABLE(CFPREFS_DIRECT_MODE)
</ins><span class="cx">         if (_AXSUpdateWebAccessibilitySettingsPtr())
</span><span class="cx">             _AXSUpdateWebAccessibilitySettingsPtr()();
</span><ins>+#elif PLATFORM(IOS_FAMILY)
+        // If the update method is not available, to update the cache inside AccessibilitySupport,
+        // these methods need to be called directly.
+        if (CFEqual(key.createCFString().get(), kAXSReduceMotionPreference) && [value isKindOfClass:[NSNumber class]])
+            _AXSSetReduceMotionEnabled([(NSNumber *)value boolValue]);
+        else if (CFEqual(key.createCFString().get(), increaseContrastPreferenceKey()) && [value isKindOfClass:[NSNumber class]])
+            _AXSSetDarkenSystemColors([(NSNumber *)value boolValue]);
+#endif
</ins><span class="cx">     }
</span><span class="cx">     
</span><span class="cx"> #if USE(APPKIT)
</span></span></pre></div>
<a id="trunkToolsChangeLog"></a>
<div class="modfile"><h4>Modified: trunk/Tools/ChangeLog (278735 => 278736)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Tools/ChangeLog    2021-06-10 22:19:21 UTC (rev 278735)
+++ trunk/Tools/ChangeLog       2021-06-10 23:10:49 UTC (rev 278736)
</span><span class="lines">@@ -1,3 +1,16 @@
</span><ins>+2021-06-10  Chris Fleizach  <cfleizach@apple.com>
+
+        AX: TestWebKitAPI.WebKit.AccessibilityReduceMotion failing on iOS
+        https://bugs.webkit.org/show_bug.cgi?id=226758
+        <rdar://problem/78984253>
+
+        Reviewed by Alex Christensen.
+
+        * TestWebKitAPI/TestWebKitAPI.xcodeproj/project.pbxproj:
+        * TestWebKitAPI/Tests/WebKit/AccessibilityIncreaseContrast.mm: Added.
+        (-[WKPreferenceObserverForTestingIncreaseContrast preferenceDidChange:key:encodedValue:]):
+        (TEST):
+
</ins><span class="cx"> 2021-06-10  Jonathan Bedard  <jbedard@apple.com>
</span><span class="cx"> 
</span><span class="cx">         [webkitcorepy] 6x performance improvement in Memoized
</span></span></pre></div>
<a id="trunkToolsTestWebKitAPITestWebKitAPIxcodeprojprojectpbxproj"></a>
<div class="modfile"><h4>Modified: trunk/Tools/TestWebKitAPI/TestWebKitAPI.xcodeproj/project.pbxproj (278735 => 278736)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Tools/TestWebKitAPI/TestWebKitAPI.xcodeproj/project.pbxproj        2021-06-10 22:19:21 UTC (rev 278735)
+++ trunk/Tools/TestWebKitAPI/TestWebKitAPI.xcodeproj/project.pbxproj   2021-06-10 23:10:49 UTC (rev 278736)
</span><span class="lines">@@ -143,6 +143,7 @@
</span><span class="cx">          290A9BB91735F63800D71BBC /* OpenNewWindow.html in Copy Resources */ = {isa = PBXBuildFile; fileRef = 290A9BB81735F42300D71BBC /* OpenNewWindow.html */; };
</span><span class="cx">          290F4275172A221C00939FF0 /* custom-protocol-sync-xhr.html in Copy Resources */ = {isa = PBXBuildFile; fileRef = 290F4274172A1FDE00939FF0 /* custom-protocol-sync-xhr.html */; };
</span><span class="cx">          297234B7173AFAC700983601 /* CustomProtocolsInvalidScheme_Bundle.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 297234B5173AFAC700983601 /* CustomProtocolsInvalidScheme_Bundle.cpp */; };
</span><ins>+               29E06E5E266F3C0600F1A707 /* AccessibilityIncreaseContrast.mm in Sources */ = {isa = PBXBuildFile; fileRef = 29E06E5D266F3C0600F1A707 /* AccessibilityIncreaseContrast.mm */; };
</ins><span class="cx">           2D00065F1C1F589A0088E6A7 /* WKPDFView.mm in Sources */ = {isa = PBXBuildFile; fileRef = 2D00065D1C1F58940088E6A7 /* WKPDFView.mm */; };
</span><span class="cx">          2D01D06E23218FEE0039AA3A /* WKWebViewPrintFormatter.mm in Sources */ = {isa = PBXBuildFile; fileRef = 2D01D06D23218FEE0039AA3A /* WKWebViewPrintFormatter.mm */; };
</span><span class="cx">          2D08E9372267D0F4002518DA /* ReparentWebViewTimeout.mm in Sources */ = {isa = PBXBuildFile; fileRef = 2D08E9362267D0F3002518DA /* ReparentWebViewTimeout.mm */; };
</span><span class="lines">@@ -1921,6 +1922,7 @@
</span><span class="cx">          29AB8A9F164C735800D49BEC /* CustomProtocolsTest.mm */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.objcpp; name = CustomProtocolsTest.mm; path = WebKitObjC/CustomProtocolsTest.mm; sourceTree = "<group>"; };
</span><span class="cx">          29AB8AA2164C7A9300D49BEC /* TestBrowsingContextLoadDelegate.mm */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.objcpp; path = TestBrowsingContextLoadDelegate.mm; sourceTree = "<group>"; };
</span><span class="cx">          29AB8AA3164C7A9300D49BEC /* TestBrowsingContextLoadDelegate.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = TestBrowsingContextLoadDelegate.h; sourceTree = "<group>"; };
</span><ins>+               29E06E5D266F3C0600F1A707 /* AccessibilityIncreaseContrast.mm */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.cpp.objcpp; path = AccessibilityIncreaseContrast.mm; sourceTree = "<group>"; };
</ins><span class="cx">           2D00065D1C1F58940088E6A7 /* WKPDFView.mm */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.objcpp; path = WKPDFView.mm; sourceTree = "<group>"; };
</span><span class="cx">          2D01D06D23218FEE0039AA3A /* WKWebViewPrintFormatter.mm */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.objcpp; path = WKWebViewPrintFormatter.mm; sourceTree = "<group>"; };
</span><span class="cx">          2D08E9362267D0F3002518DA /* ReparentWebViewTimeout.mm */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.objcpp; path = ReparentWebViewTimeout.mm; sourceTree = "<group>"; };
</span><span class="lines">@@ -3307,6 +3309,7 @@
</span><span class="cx">          0F139E741A423A4600F590F5 /* cocoa */ = {
</span><span class="cx">                  isa = PBXGroup;
</span><span class="cx">                  children = (
</span><ins>+                               29E06E5D266F3C0600F1A707 /* AccessibilityIncreaseContrast.mm */,
</ins><span class="cx">                           C1F4840624EDDB400053ECB8 /* AccessibilityReduceMotion.mm */,
</span><span class="cx">                          E3F8AB91241AB9CE003E2A7E /* AccessibilityRemoteUIApp.mm */,
</span><span class="cx">                          C1F7B7382449083F00124557 /* AGXCompilerService.mm */,
</span><span class="lines">@@ -5723,6 +5726,7 @@
</span><span class="cx">                          5CCB10E4213457E000AC5AF0 /* ShouldGoToBackForwardListItem.mm in Sources */,
</span><span class="cx">                          7CCE7F141A411AE600447C4C /* ShouldKeepCurrentBackForwardListItemInList.cpp in Sources */,
</span><span class="cx">                          37BCA61C1B596BA9002012CA /* ShouldOpenExternalURLsInNewWindowActions.mm in Sources */,
</span><ins>+                               29E06E5E266F3C0600F1A707 /* AccessibilityIncreaseContrast.mm in Sources */,
</ins><span class="cx">                           7C83E0C51D0A654600FEBCF3 /* ShrinkToFit.mm in Sources */,
</span><span class="cx">                          7CCE7ECD1A411A7E00447C4C /* SimplifyMarkup.mm in Sources */,
</span><span class="cx">                          C149D550242E98DF003EBB12 /* SleepDisabler.mm in Sources */,
</span></span></pre></div>
<a id="trunkToolsTestWebKitAPITestsWebKitAccessibilityIncreaseContrastmm"></a>
<div class="addfile"><h4>Added: trunk/Tools/TestWebKitAPI/Tests/WebKit/AccessibilityIncreaseContrast.mm (0 => 278736)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Tools/TestWebKitAPI/Tests/WebKit/AccessibilityIncreaseContrast.mm                          (rev 0)
+++ trunk/Tools/TestWebKitAPI/Tests/WebKit/AccessibilityIncreaseContrast.mm     2021-06-10 23:10:49 UTC (rev 278736)
</span><span class="lines">@@ -0,0 +1,96 @@
</span><ins>+/*
+ * 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"
+
+#if ENABLE(CFPREFS_DIRECT_MODE)
+
+#import "PlatformUtilities.h"
+#import "TestWKWebView.h"
+#import "WKWebViewConfigurationExtras.h"
+#import <WebKit/PreferenceObserver.h>
+#import <WebKit/WKProcessPoolPrivate.h>
+#import <WebKit/_WKProcessPoolConfiguration.h>
+
+#if PLATFORM(MAC)
+#import <pal/spi/mac/HIServicesSPI.h>
+#endif
+
+#if PLATFORM(IOS_FAMILY)
+#include <pal/spi/cocoa/AccessibilitySupportSPI.h>
+#include <wtf/SoftLinking.h>
+
+#define NOTIFICATION_CENTER CFNotificationCenterGetDarwinNotifyCenter()
+#define INCREASE_CONTRAST_PREFERENCE CFSTR("DarkenSystemColors")
+#define ACCESSIBILITY_DOMAIN CFSTR("com.apple.Accessibility")
+#else
+#define NOTIFICATION_CENTER CFNotificationCenterGetDistributedCenter()
+#define INCREASE_CONTRAST_PREFERENCE kAXInterfaceIncreaseContrastKey
+#define ACCESSIBILITY_DOMAIN CFSTR("com.apple.universalaccess")
+#endif
+
+static bool receivedPreferenceNotification = false;
+
+@interface WKPreferenceObserverForTestingIncreaseContrast : WKPreferenceObserver
+- (void)preferenceDidChange:(NSString *)domain key:(NSString *)key encodedValue:(NSString *)encodedValue;
+@end
+
+@implementation WKPreferenceObserverForTestingIncreaseContrast
+- (void)preferenceDidChange:(NSString *)domain key:(NSString *)key encodedValue:(NSString *)encodedValue
+{
+    receivedPreferenceNotification = true;
+    [super preferenceDidChange:domain key:key encodedValue:encodedValue];
+}
+@end
+
+TEST(WebKit, AccessibilityIncreaseContrast)
+{
+    WKWebViewConfiguration *configuration = [WKWebViewConfiguration _test_configurationWithTestPlugInClassName:@"WebProcessPlugInWithInternals" configureJSCForTesting:YES];
+    auto webView = adoptNS([[TestWKWebView alloc] initWithFrame:NSMakeRect(0, 0, 300, 300) configuration:configuration addToWindow:YES]);
+
+    CFPreferencesSetAppValue(INCREASE_CONTRAST_PREFERENCE, kCFBooleanFalse, ACCESSIBILITY_DOMAIN);
+
+    auto observer = adoptNS([[WKPreferenceObserverForTestingIncreaseContrast alloc] init]);
+
+    [webView synchronouslyLoadTestPageNamed:@"simple"];
+
+    auto contrastCheck = [&] {
+        return [webView stringByEvaluatingJavaScript:@"window.internals.userPrefersContrast()"].boolValue;
+    };
+
+    ASSERT_FALSE(contrastCheck());
+
+    CFPreferencesSetAppValue(INCREASE_CONTRAST_PREFERENCE, kCFBooleanTrue, ACCESSIBILITY_DOMAIN);
+
+    TestWebKitAPI::Util::run(&receivedPreferenceNotification);
+
+    [webView synchronouslyLoadTestPageNamed:@"simple"];
+
+    ASSERT_TRUE(contrastCheck());
+
+    CFPreferencesSetAppValue(INCREASE_CONTRAST_PREFERENCE, nullptr, ACCESSIBILITY_DOMAIN);
+}
+
+#endif
</ins></span></pre>
</div>
</div>

</body>
</html>