REGRESSION(251087): Several API tests are failing
https://bugs.webkit.org/show_bug.cgi?id=202961

Reviewed by Brent Fulgham.

WebPageProxy::maybeInitializeSandboxExtensionHandle returns early if the WebContent process is currently launching,
since the audit token is needed to create the sandbox extension. The audit token will not be available until the
process has finished launching. In the same way, the method should return early if the WebContent process has
terminated.

* UIProcess/WebPageProxy.cpp:
(WebKit::WebPageProxy::maybeInitializeSandboxExtensionHandle):


git-svn-id: http://svn.webkit.org/repository/webkit/trunk@251116 268f45cc-cd09-0410-ab3c-d52691b4dbfc
diff --git a/Source/WebKit/ChangeLog b/Source/WebKit/ChangeLog
index 1b40757..80d2724 100644
--- a/Source/WebKit/ChangeLog
+++ b/Source/WebKit/ChangeLog
@@ -1,3 +1,18 @@
+2019-10-14  Per Arne Vollan  <pvollan@apple.com>
+
+        REGRESSION(251087): Several API tests are failing
+        https://bugs.webkit.org/show_bug.cgi?id=202961
+
+        Reviewed by Brent Fulgham.
+
+        WebPageProxy::maybeInitializeSandboxExtensionHandle returns early if the WebContent process is currently launching,
+        since the audit token is needed to create the sandbox extension. The audit token will not be available until the
+        process has finished launching. In the same way, the method should return early if the WebContent process has
+        terminated.
+
+        * UIProcess/WebPageProxy.cpp:
+        (WebKit::WebPageProxy::maybeInitializeSandboxExtensionHandle):
+
 2019-10-14  Matt Mokary  <mmokary@apple.com>
 
         FindController::findString always updates foundStringMatchIndex even if match is the same as before
diff --git a/Source/WebKit/UIProcess/WebPageProxy.cpp b/Source/WebKit/UIProcess/WebPageProxy.cpp
index 0152f6c..e1c5c10 100644
--- a/Source/WebKit/UIProcess/WebPageProxy.cpp
+++ b/Source/WebKit/UIProcess/WebPageProxy.cpp
@@ -1091,7 +1091,7 @@
 #if HAVE(SANDBOX_ISSUE_READ_EXTENSION_TO_PROCESS_BY_AUDIT_TOKEN)
     // If the process is still launching then it does not have a PID yet. We will take care of creating the sandbox extension
     // once the process has finished launching.
-    if (process.isLaunching())
+    if (process.isLaunching() || process.wasTerminated())
         return;
 #endif