Allow NSFileCoordinator to be called from WebContent process
https://bugs.webkit.org/show_bug.cgi?id=197895
<rdar://problem/50107679>

Patch by Alex Christensen <achristensen@webkit.org> on 2019-05-15
Reviewed by Brent Fulgham.

Source/WebKit:

* WebProcess/com.apple.WebProcess.sb.in:
Expand sandbox to allow use of com.apple.FileCoordination mach service like we do on iOS.

Tools:

Add a unit test that verifies calling the block succeeds.

* TestWebKitAPI/Tests/WebKitCocoa/AdditionalReadAccessAllowedURLsPlugin.mm:
(-[AdditionalReadAccessAllowedURLsPlugIn webProcessPlugIn:didCreateBrowserContextController:]):

git-svn-id: http://svn.webkit.org/repository/webkit/trunk@245322 268f45cc-cd09-0410-ab3c-d52691b4dbfc
diff --git a/Source/WebKit/ChangeLog b/Source/WebKit/ChangeLog
index 5df2e3d..b25a8b54 100644
--- a/Source/WebKit/ChangeLog
+++ b/Source/WebKit/ChangeLog
@@ -1,3 +1,14 @@
+2019-05-15  Alex Christensen  <achristensen@webkit.org>
+
+        Allow NSFileCoordinator to be called from WebContent process
+        https://bugs.webkit.org/show_bug.cgi?id=197895
+        <rdar://problem/50107679>
+
+        Reviewed by Brent Fulgham.
+
+        * WebProcess/com.apple.WebProcess.sb.in:
+        Expand sandbox to allow use of com.apple.FileCoordination mach service like we do on iOS.
+
 2019-05-15  Devin Rousso  <drousso@apple.com>
 
         Web Automation: elements larger than the viewport have incorrect in-view center point
diff --git a/Source/WebKit/WebProcess/com.apple.WebProcess.sb.in b/Source/WebKit/WebProcess/com.apple.WebProcess.sb.in
index eab254e..af6f30a 100644
--- a/Source/WebKit/WebProcess/com.apple.WebProcess.sb.in
+++ b/Source/WebKit/WebProcess/com.apple.WebProcess.sb.in
@@ -593,6 +593,9 @@
 (allow mach-lookup
        (global-name "com.apple.webinspector"))
 
+(allow mach-lookup
+    (global-name "com.apple.FileCoordination"))
+
 ;; Various services required by AppKit and other frameworks
 (allow mach-lookup
 #if __MAC_OS_X_VERSION_MIN_REQUIRED < 101400
@@ -986,6 +989,9 @@
         (syscall-number SYS_quotactl) ;; <rdar://problem/49945031>
         (syscall-number SYS_stat64_extended) ;; <rdar://problem/50473330>
         (syscall-number SYS_lstat64_extended)
+        (syscall-number SYS_iopolicysys)
+        (syscall-number SYS_workq_open)
+        (syscall-number SYS_getgroups)
     )
 )
 
diff --git a/Tools/ChangeLog b/Tools/ChangeLog
index 40a60b5..63db5da7 100644
--- a/Tools/ChangeLog
+++ b/Tools/ChangeLog
@@ -1,3 +1,16 @@
+2019-05-15  Alex Christensen  <achristensen@webkit.org>
+
+        Allow NSFileCoordinator to be called from WebContent process
+        https://bugs.webkit.org/show_bug.cgi?id=197895
+        <rdar://problem/50107679>
+
+        Reviewed by Brent Fulgham.
+
+        Add a unit test that verifies calling the block succeeds.
+
+        * TestWebKitAPI/Tests/WebKitCocoa/AdditionalReadAccessAllowedURLsPlugin.mm:
+        (-[AdditionalReadAccessAllowedURLsPlugIn webProcessPlugIn:didCreateBrowserContextController:]):
+
 2019-05-14  Andy Estes  <aestes@apple.com>
 
         [Apple Pay] Payment APIs should be completely disabled in web views into which clients have injected user scripts
diff --git a/Tools/TestWebKitAPI/Tests/WebKitCocoa/AdditionalReadAccessAllowedURLsPlugin.mm b/Tools/TestWebKitAPI/Tests/WebKitCocoa/AdditionalReadAccessAllowedURLsPlugin.mm
index 1083367..f99e1ac 100644
--- a/Tools/TestWebKitAPI/Tests/WebKitCocoa/AdditionalReadAccessAllowedURLsPlugin.mm
+++ b/Tools/TestWebKitAPI/Tests/WebKitCocoa/AdditionalReadAccessAllowedURLsPlugin.mm
@@ -52,6 +52,13 @@
 
     _interface = [_WKRemoteObjectInterface remoteObjectInterfaceWithProtocol:@protocol(AdditionalReadAccessAllowedURLsProtocol)];
     [[browserContextController _remoteObjectRegistry] registerExportedObject:self interface:_interface.get()];
+
+    __block bool blockCalled = false;
+    NSFileCoordinator *coordinator = [[NSFileCoordinator alloc] initWithFilePresenter:nil];
+    [coordinator coordinateReadingItemAtURL:[NSURL fileURLWithPath:@"/Applications/Safari.app"] options:NSFileCoordinatorReadingWithoutChanges error:nil byAccessor:^(NSURL *newURL) {
+        blockCalled = true;
+    }];
+    ASSERT(blockCalled);
 }
 
 - (void)dealloc