<!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>[286615] branches/safari-613.1.10-branch/Source/WebKit</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/286615">286615</a></dd>
<dt>Author</dt> <dd>repstein@apple.com</dd>
<dt>Date</dt> <dd>2021-12-07 13:19:46 -0800 (Tue, 07 Dec 2021)</dd>
</dl>

<h3>Log Message</h3>
<pre>Cherry-pick <a href="http://trac.webkit.org/projects/webkit/changeset/286533">r286533</a>. rdar://problem/86052131

    Add command line `webpushtool` for daemon development and debugging.
    https://bugs.webkit.org/show_bug.cgi?id=233845

    Reviewed by Tim Horton.

    No behavior change.

    This utility will eventually be quite fleshed out.

    For now, it can act as a terminal that prints debug messages from webpushd.

    * Configurations/webpushtool.xcconfig: Added.
    * Resources/webpushtool.entitlements: Added.
    * WebKit.xcodeproj/project.pbxproj:
    * WebKit.xcodeproj/xcshareddata/xcschemes/webpushtool.xcscheme: Added.

    * webpushd/webpushtool/WebPushToolConnection.h: Added.
    * webpushd/webpushtool/WebPushToolConnection.mm: Added.
    (WebPushTool::Connection::create):
    (WebPushTool::maybeConnectToService):
    (WebPushTool::Connection::Connection):
    (WebPushTool::Connection::connectToService):
    (WebPushTool::Connection::startAction):
    (WebPushTool::Connection::startDebugStreamAction):
    (WebPushTool::Connection::sendAuditToken):
    (WebPushTool::Connection::connectionDropped):
    (WebPushTool::Connection::messageReceived):
    * webpushd/webpushtool/WebPushToolMain.mm: Added.
    (printUsageAndTerminate):
    (main):

    git-svn-id: https://svn.webkit.org/repository/webkit/trunk@286533 268f45cc-cd09-0410-ab3c-d52691b4dbfc</pre>

<h3>Modified Paths</h3>
<ul>
<li><a href="#branchessafari613110branchSourceWebKitChangeLog">branches/safari-613.1.10-branch/Source/WebKit/ChangeLog</a></li>
<li><a href="#branchessafari613110branchSourceWebKitWebKitxcodeprojprojectpbxproj">branches/safari-613.1.10-branch/Source/WebKit/WebKit.xcodeproj/project.pbxproj</a></li>
</ul>

<h3>Added Paths</h3>
<ul>
<li><a href="#branchessafari613110branchSourceWebKitConfigurationswebpushtoolxcconfig">branches/safari-613.1.10-branch/Source/WebKit/Configurations/webpushtool.xcconfig</a></li>
<li><a href="#branchessafari613110branchSourceWebKitResourceswebpushtoolentitlements">branches/safari-613.1.10-branch/Source/WebKit/Resources/webpushtool.entitlements</a></li>
<li><a href="#branchessafari613110branchSourceWebKitWebKitxcodeprojxcshareddataxcschemeswebpushtoolxcscheme">branches/safari-613.1.10-branch/Source/WebKit/WebKit.xcodeproj/xcshareddata/xcschemes/webpushtool.xcscheme</a></li>
<li>branches/safari-613.1.10-branch/Source/WebKit/webpushd/webpushtool/</li>
<li><a href="#branchessafari613110branchSourceWebKitwebpushdwebpushtoolWebPushToolConnectionh">branches/safari-613.1.10-branch/Source/WebKit/webpushd/webpushtool/WebPushToolConnection.h</a></li>
<li><a href="#branchessafari613110branchSourceWebKitwebpushdwebpushtoolWebPushToolConnectionmm">branches/safari-613.1.10-branch/Source/WebKit/webpushd/webpushtool/WebPushToolConnection.mm</a></li>
<li><a href="#branchessafari613110branchSourceWebKitwebpushdwebpushtoolWebPushToolMainmm">branches/safari-613.1.10-branch/Source/WebKit/webpushd/webpushtool/WebPushToolMain.mm</a></li>
</ul>

</div>
<div id="patch">
<h3>Diff</h3>
<a id="branchessafari613110branchSourceWebKitChangeLog"></a>
<div class="modfile"><h4>Modified: branches/safari-613.1.10-branch/Source/WebKit/ChangeLog (286614 => 286615)</h4>
<pre class="diff"><span>
<span class="info">--- branches/safari-613.1.10-branch/Source/WebKit/ChangeLog  2021-12-07 21:19:42 UTC (rev 286614)
+++ branches/safari-613.1.10-branch/Source/WebKit/ChangeLog     2021-12-07 21:19:46 UTC (rev 286615)
</span><span class="lines">@@ -1,5 +1,75 @@
</span><span class="cx"> 2021-12-06  Russell Epstein  <repstein@apple.com>
</span><span class="cx"> 
</span><ins>+        Cherry-pick r286533. rdar://problem/86052131
+
+    Add command line `webpushtool` for daemon development and debugging.
+    https://bugs.webkit.org/show_bug.cgi?id=233845
+    
+    Reviewed by Tim Horton.
+    
+    No behavior change.
+    
+    This utility will eventually be quite fleshed out.
+    
+    For now, it can act as a terminal that prints debug messages from webpushd.
+    
+    * Configurations/webpushtool.xcconfig: Added.
+    * Resources/webpushtool.entitlements: Added.
+    * WebKit.xcodeproj/project.pbxproj:
+    * WebKit.xcodeproj/xcshareddata/xcschemes/webpushtool.xcscheme: Added.
+    
+    * webpushd/webpushtool/WebPushToolConnection.h: Added.
+    * webpushd/webpushtool/WebPushToolConnection.mm: Added.
+    (WebPushTool::Connection::create):
+    (WebPushTool::maybeConnectToService):
+    (WebPushTool::Connection::Connection):
+    (WebPushTool::Connection::connectToService):
+    (WebPushTool::Connection::startAction):
+    (WebPushTool::Connection::startDebugStreamAction):
+    (WebPushTool::Connection::sendAuditToken):
+    (WebPushTool::Connection::connectionDropped):
+    (WebPushTool::Connection::messageReceived):
+    * webpushd/webpushtool/WebPushToolMain.mm: Added.
+    (printUsageAndTerminate):
+    (main):
+    
+    git-svn-id: https://svn.webkit.org/repository/webkit/trunk@286533 268f45cc-cd09-0410-ab3c-d52691b4dbfc
+
+    2021-12-04  Brady Eidson  <beidson@apple.com>
+
+            Add command line `webpushtool` for daemon development and debugging.
+            https://bugs.webkit.org/show_bug.cgi?id=233845
+
+            Reviewed by Tim Horton.
+
+            No behavior change.
+
+            This utility will eventually be quite fleshed out.
+
+            For now, it can act as a terminal that prints debug messages from webpushd.
+
+            * Configurations/webpushtool.xcconfig: Added.
+            * Resources/webpushtool.entitlements: Added.
+            * WebKit.xcodeproj/project.pbxproj:
+            * WebKit.xcodeproj/xcshareddata/xcschemes/webpushtool.xcscheme: Added.
+
+            * webpushd/webpushtool/WebPushToolConnection.h: Added.
+            * webpushd/webpushtool/WebPushToolConnection.mm: Added.
+            (WebPushTool::Connection::create):
+            (WebPushTool::maybeConnectToService):
+            (WebPushTool::Connection::Connection):
+            (WebPushTool::Connection::connectToService):
+            (WebPushTool::Connection::startAction):
+            (WebPushTool::Connection::startDebugStreamAction):
+            (WebPushTool::Connection::sendAuditToken):
+            (WebPushTool::Connection::connectionDropped):
+            (WebPushTool::Connection::messageReceived):
+            * webpushd/webpushtool/WebPushToolMain.mm: Added.
+            (printUsageAndTerminate):
+            (main):
+
+2021-12-06  Russell Epstein  <repstein@apple.com>
+
</ins><span class="cx">         Cherry-pick r286355. rdar://problem/86052131
</span><span class="cx"> 
</span><span class="cx">     Add WKWebsiteDataStore configuration option to enable Mock app bundle testing.
</span></span></pre></div>
<a id="branchessafari613110branchSourceWebKitConfigurationswebpushtoolxcconfig"></a>
<div class="addfile"><h4>Added: branches/safari-613.1.10-branch/Source/WebKit/Configurations/webpushtool.xcconfig (0 => 286615)</h4>
<pre class="diff"><span>
<span class="info">--- branches/safari-613.1.10-branch/Source/WebKit/Configurations/webpushtool.xcconfig                                (rev 0)
+++ branches/safari-613.1.10-branch/Source/WebKit/Configurations/webpushtool.xcconfig   2021-12-07 21:19:46 UTC (rev 286615)
</span><span class="lines">@@ -0,0 +1,35 @@
</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. ``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
+// 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.
+
+#include "BaseTarget.xcconfig"
+
+PRODUCT_NAME = webpushtool;
+SKIP_INSTALL = YES;
+
+EXCLUDED_SOURCE_FILE_NAMES[sdk=appletv*] = *;
+EXCLUDED_SOURCE_FILE_NAMES[sdk=watch*] = *;
+
+OTHER_LDFLAGS = -l WTF -framework Foundation -framework CoreFoundation;
+LIBRARY_SEARCH_PATHS = $(BUILT_PRODUCTS_DIR);
+
+CODE_SIGN_ENTITLEMENTS = Resources/webpushtool.entitlements;
</ins></span></pre></div>
<a id="branchessafari613110branchSourceWebKitResourceswebpushtoolentitlements"></a>
<div class="addfile"><h4>Added: branches/safari-613.1.10-branch/Source/WebKit/Resources/webpushtool.entitlements (0 => 286615)</h4>
<pre class="diff"><span>
<span class="info">--- branches/safari-613.1.10-branch/Source/WebKit/Resources/webpushtool.entitlements                         (rev 0)
+++ branches/safari-613.1.10-branch/Source/WebKit/Resources/webpushtool.entitlements    2021-12-07 21:19:46 UTC (rev 286615)
</span><span class="lines">@@ -0,0 +1,8 @@
</span><ins>+<?xml version="1.0" encoding="UTF-8"?>
+<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
+<plist version="1.0">
+<dict>
+       <key>com.apple.private.webkit.webpush</key>
+       <true/>
+</dict>
+</plist>
</ins></span></pre></div>
<a id="branchessafari613110branchSourceWebKitWebKitxcodeprojprojectpbxproj"></a>
<div class="modfile"><h4>Modified: branches/safari-613.1.10-branch/Source/WebKit/WebKit.xcodeproj/project.pbxproj (286614 => 286615)</h4>
<pre class="diff"><span>
<span class="info">--- branches/safari-613.1.10-branch/Source/WebKit/WebKit.xcodeproj/project.pbxproj   2021-12-07 21:19:42 UTC (rev 286614)
+++ branches/safari-613.1.10-branch/Source/WebKit/WebKit.xcodeproj/project.pbxproj      2021-12-07 21:19:46 UTC (rev 286615)
</span><span class="lines">@@ -14,6 +14,7 @@
</span><span class="cx">                          BCFFCA8A160D6DEA003DF315 /* Add XPCServices symlink */,
</span><span class="cx">                  );
</span><span class="cx">                  dependencies = (
</span><ins>+                               517B5F6D275B07C3002DC22D /* PBXTargetDependency */,
</ins><span class="cx">                           5C1579DF27165E0800ED5280 /* PBXTargetDependency */,
</span><span class="cx">                          5CAF7AA926F93F9F0003F19E /* PBXTargetDependency */,
</span><span class="cx">                          5742A2FA2535619D00B7BA14 /* PBXTargetDependency */,
</span><span class="lines">@@ -1021,6 +1022,8 @@
</span><span class="cx">          517A53101F47A86200DCDC0A /* WebSWClientConnectionMessages.h in Headers */ = {isa = PBXBuildFile; fileRef = 517A530D1F47A84300DCDC0A /* WebSWClientConnectionMessages.h */; };
</span><span class="cx">          517B5F2E2757382A002DC22D /* WebPushDaemonConnectionConfiguration.h in Headers */ = {isa = PBXBuildFile; fileRef = 517B5F2D2757382A002DC22D /* WebPushDaemonConnectionConfiguration.h */; };
</span><span class="cx">          517B5F2F2757382B002DC22D /* WebPushDaemonConnectionConfiguration.h in Headers */ = {isa = PBXBuildFile; fileRef = 517B5F2D2757382A002DC22D /* WebPushDaemonConnectionConfiguration.h */; };
</span><ins>+               517B5F65275A8D7F002DC22D /* WebPushToolMain.mm in Sources */ = {isa = PBXBuildFile; fileRef = 517B5F64275A8D7E002DC22D /* WebPushToolMain.mm */; };
+               517B5F68275A9A78002DC22D /* WebPushToolConnection.mm in Sources */ = {isa = PBXBuildFile; fileRef = 517B5F67275A9A78002DC22D /* WebPushToolConnection.mm */; };
</ins><span class="cx">           517CF0E3163A486C00C2950E /* NetworkProcessConnectionMessageReceiver.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 517CF0E1163A486C00C2950E /* NetworkProcessConnectionMessageReceiver.cpp */; };
</span><span class="cx">          517CF0E3163A486C00C2950F /* CacheStorageEngineConnectionMessageReceiver.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 517CF0E1163A486C00C2950F /* CacheStorageEngineConnectionMessageReceiver.cpp */; };
</span><span class="cx">          517CF0E4163A486C00C2950E /* NetworkProcessConnectionMessages.h in Headers */ = {isa = PBXBuildFile; fileRef = 517CF0E2163A486C00C2950E /* NetworkProcessConnectionMessages.h */; };
</span><span class="lines">@@ -2115,6 +2118,13 @@
</span><span class="cx">                  remoteGlobalIDString = C0CE72851247E66800BC0EC4;
</span><span class="cx">                  remoteInfo = "Derived Sources";
</span><span class="cx">          };
</span><ins>+               517B5F6C275B07C3002DC22D /* PBXContainerItemProxy */ = {
+                       isa = PBXContainerItemProxy;
+                       containerPortal = 0867D690FE84028FC02AAC07 /* Project object */;
+                       proxyType = 1;
+                       remoteGlobalIDString = 517B5F5A275A8D3E002DC22D;
+                       remoteInfo = webpushtool;
+               };
</ins><span class="cx">           5742A2E72535613F00B7BA14 /* PBXContainerItemProxy */ = {
</span><span class="cx">                  isa = PBXContainerItemProxy;
</span><span class="cx">                  containerPortal = 0867D690FE84028FC02AAC07 /* Project object */;
</span><span class="lines">@@ -4320,6 +4330,12 @@
</span><span class="cx">          517A530D1F47A84300DCDC0A /* WebSWClientConnectionMessages.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = WebSWClientConnectionMessages.h; path = DerivedSources/WebKit2/WebSWClientConnectionMessages.h; sourceTree = BUILT_PRODUCTS_DIR; };
</span><span class="cx">          517A530E1F47A84300DCDC0A /* WebSWClientConnectionMessageReceiver.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = WebSWClientConnectionMessageReceiver.cpp; path = DerivedSources/WebKit2/WebSWClientConnectionMessageReceiver.cpp; sourceTree = BUILT_PRODUCTS_DIR; };
</span><span class="cx">          517B5F2D2757382A002DC22D /* WebPushDaemonConnectionConfiguration.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = WebPushDaemonConnectionConfiguration.h; sourceTree = "<group>"; };
</span><ins>+               517B5F5B275A8D3E002DC22D /* webpushtool */ = {isa = PBXFileReference; explicitFileType = "compiled.mach-o.executable"; includeInIndex = 0; path = webpushtool; sourceTree = BUILT_PRODUCTS_DIR; };
+               517B5F64275A8D7E002DC22D /* WebPushToolMain.mm */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.objcpp; path = WebPushToolMain.mm; sourceTree = "<group>"; };
+               517B5F66275A9A78002DC22D /* WebPushToolConnection.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = WebPushToolConnection.h; sourceTree = "<group>"; };
+               517B5F67275A9A78002DC22D /* WebPushToolConnection.mm */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.objcpp; path = WebPushToolConnection.mm; sourceTree = "<group>"; };
+               517B5F6A275AA199002DC22D /* webpushtool.xcconfig */ = {isa = PBXFileReference; lastKnownFileType = text.xcconfig; path = webpushtool.xcconfig; sourceTree = "<group>"; };
+               517B5F6B275AE50B002DC22D /* webpushtool.entitlements */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.plist.entitlements; name = webpushtool.entitlements; path = Resources/webpushtool.entitlements; sourceTree = "<group>"; };
</ins><span class="cx">           517CF0E1163A486C00C2950E /* NetworkProcessConnectionMessageReceiver.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = NetworkProcessConnectionMessageReceiver.cpp; path = DerivedSources/WebKit2/NetworkProcessConnectionMessageReceiver.cpp; sourceTree = BUILT_PRODUCTS_DIR; };
</span><span class="cx">          517CF0E1163A486C00C2950F /* CacheStorageEngineConnectionMessageReceiver.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = CacheStorageEngineConnectionMessageReceiver.cpp; path = DerivedSources/WebKit2/CacheStorageEngineConnectionMessageReceiver.cpp; sourceTree = BUILT_PRODUCTS_DIR; };
</span><span class="cx">          517CF0E2163A486C00C2950E /* NetworkProcessConnectionMessages.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = NetworkProcessConnectionMessages.h; path = DerivedSources/WebKit2/NetworkProcessConnectionMessages.h; sourceTree = BUILT_PRODUCTS_DIR; };
</span><span class="lines">@@ -6372,6 +6388,13 @@
</span><span class="cx">                  );
</span><span class="cx">                  runOnlyForDeploymentPostprocessing = 0;
</span><span class="cx">          };
</span><ins>+               517B5F58275A8D3E002DC22D /* Frameworks */ = {
+                       isa = PBXFrameworksBuildPhase;
+                       buildActionMask = 2147483647;
+                       files = (
+                       );
+                       runOnlyForDeploymentPostprocessing = 0;
+               };
</ins><span class="cx">           5742A2ED2535613F00B7BA14 /* Frameworks */ = {
</span><span class="cx">                  isa = PBXFrameworksBuildPhase;
</span><span class="cx">                  buildActionMask = 2147483647;
</span><span class="lines">@@ -6457,6 +6480,7 @@
</span><span class="cx">                          CD95493526159004008372D9 /* libWebKitSwift.dylib */,
</span><span class="cx">                          A16E66002581930800EE1749 /* MediaFormatReader.bundle */,
</span><span class="cx">                          8DC2EF5B0486A6940098B216 /* WebKit.framework */,
</span><ins>+                               517B5F5B275A8D3E002DC22D /* webpushtool */,
</ins><span class="cx">                   );
</span><span class="cx">                  name = Products;
</span><span class="cx">                  sourceTree = "<group>";
</span><span class="lines">@@ -6699,6 +6723,7 @@
</span><span class="cx">                          5C8BC796218CB58A00813886 /* SafeBrowsing.xcassets */,
</span><span class="cx">                          E1D26A4C1759634E0095BFD1 /* WebContentProcess.xib */,
</span><span class="cx">                          E133FD891423DD7F00FC7BFB /* WebKit.icns */,
</span><ins>+                               517B5F6B275AE50B002DC22D /* webpushtool.entitlements */,
</ins><span class="cx">                   );
</span><span class="cx">                  name = Resources;
</span><span class="cx">                  sourceTree = "<group>";
</span><span class="lines">@@ -6849,6 +6874,7 @@
</span><span class="cx">                          CD09FD0A26152E2300E4ACF1 /* WebKitSwift.xcconfig */,
</span><span class="cx">                          37119A7C20CCB64E002C6DC9 /* WebKitTargetConditionals.xcconfig */,
</span><span class="cx">                          5C1579DD27165BE500ED5280 /* webpushd.xcconfig */,
</span><ins>+                               517B5F6A275AA199002DC22D /* webpushtool.xcconfig */,
</ins><span class="cx">                   );
</span><span class="cx">                  path = Configurations;
</span><span class="cx">                  sourceTree = "<group>";
</span><span class="lines">@@ -9338,6 +9364,16 @@
</span><span class="cx">                  name = mac;
</span><span class="cx">                  sourceTree = "<group>";
</span><span class="cx">          };
</span><ins>+               517B5F63275A8D5C002DC22D /* webpushtool */ = {
+                       isa = PBXGroup;
+                       children = (
+                               517B5F66275A9A78002DC22D /* WebPushToolConnection.h */,
+                               517B5F67275A9A78002DC22D /* WebPushToolConnection.mm */,
+                               517B5F64275A8D7E002DC22D /* WebPushToolMain.mm */,
+                       );
+                       path = webpushtool;
+                       sourceTree = "<group>";
+               };
</ins><span class="cx">           518E8EF116B208F000E91429 /* Authentication */ = {
</span><span class="cx">                  isa = PBXGroup;
</span><span class="cx">                  children = (
</span><span class="lines">@@ -9817,6 +9853,7 @@
</span><span class="cx">                  isa = PBXGroup;
</span><span class="cx">                  children = (
</span><span class="cx">                          5CBB6D4D271F67CC00FD1A5D /* com.apple.webkit.webpushd.plist */,
</span><ins>+                               517B5F63275A8D5C002DC22D /* webpushtool */,
</ins><span class="cx">                           5160E954274B887100567388 /* AppBundleRequest.h */,
</span><span class="cx">                          5160E953274B887100567388 /* AppBundleRequest.mm */,
</span><span class="cx">                          51F7BB75274498BB00C45A72 /* MockAppBundleForTesting.h */,
</span><span class="lines">@@ -13868,6 +13905,22 @@
</span><span class="cx">                  productReference = 372EBB462017E64300085064 /* com.apple.WebKit.WebContent.Development.xpc */;
</span><span class="cx">                  productType = "com.apple.product-type.xpc-service";
</span><span class="cx">          };
</span><ins>+               517B5F5A275A8D3E002DC22D /* webpushtool */ = {
+                       isa = PBXNativeTarget;
+                       buildConfigurationList = 517B5F62275A8D3E002DC22D /* Build configuration list for PBXNativeTarget "webpushtool" */;
+                       buildPhases = (
+                               517B5F57275A8D3E002DC22D /* Sources */,
+                               517B5F58275A8D3E002DC22D /* Frameworks */,
+                       );
+                       buildRules = (
+                       );
+                       dependencies = (
+                       );
+                       name = webpushtool;
+                       productName = webpushtool;
+                       productReference = 517B5F5B275A8D3E002DC22D /* webpushtool */;
+                       productType = "com.apple.product-type.tool";
+               };
</ins><span class="cx">           5742A2E52535613F00B7BA14 /* WebAuthn */ = {
</span><span class="cx">                  isa = PBXNativeTarget;
</span><span class="cx">                  buildConfigurationList = 5742A2F32535613F00B7BA14 /* Build configuration list for PBXNativeTarget "WebAuthn" */;
</span><span class="lines">@@ -14064,6 +14117,9 @@
</span><span class="cx">                          LastSwiftUpdateCheck = 1300;
</span><span class="cx">                          LastUpgradeCheck = 1140;
</span><span class="cx">                          TargetAttributes = {
</span><ins>+                                       517B5F5A275A8D3E002DC22D = {
+                                               CreatedOnToolsVersion = 13.0;
+                                       };
</ins><span class="cx">                                   5325BDCD21DFF47700A0DEE1 = {
</span><span class="cx">                                          CreatedOnToolsVersion = 10.1;
</span><span class="cx">                                          ProvisioningStyle = Automatic;
</span><span class="lines">@@ -14120,6 +14176,7 @@
</span><span class="cx">                          942DB232257EE6D4009BD80A /* EmptyDSTROOT */,
</span><span class="cx">                          5CAF7A9926F93A750003F19E /* adattributiond */,
</span><span class="cx">                          5C1579CC27165B2F00ED5280 /* webpushd */,
</span><ins>+                               517B5F5A275A8D3E002DC22D /* webpushtool */,
</ins><span class="cx">                   );
</span><span class="cx">          };
</span><span class="cx"> /* End PBXProject section */
</span><span class="lines">@@ -14847,6 +14904,15 @@
</span><span class="cx">                  );
</span><span class="cx">                  runOnlyForDeploymentPostprocessing = 0;
</span><span class="cx">          };
</span><ins>+               517B5F57275A8D3E002DC22D /* Sources */ = {
+                       isa = PBXSourcesBuildPhase;
+                       buildActionMask = 2147483647;
+                       files = (
+                               517B5F68275A9A78002DC22D /* WebPushToolConnection.mm in Sources */,
+                               517B5F65275A8D7F002DC22D /* WebPushToolMain.mm in Sources */,
+                       );
+                       runOnlyForDeploymentPostprocessing = 0;
+               };
</ins><span class="cx">           5742A2EA2535613F00B7BA14 /* Sources */ = {
</span><span class="cx">                  isa = PBXSourcesBuildPhase;
</span><span class="cx">                  buildActionMask = 2147483647;
</span><span class="lines">@@ -15401,6 +15467,11 @@
</span><span class="cx">                  target = C0CE72851247E66800BC0EC4 /* Derived Sources */;
</span><span class="cx">                  targetProxy = 37F7407812721F740093869B /* PBXContainerItemProxy */;
</span><span class="cx">          };
</span><ins>+               517B5F6D275B07C3002DC22D /* PBXTargetDependency */ = {
+                       isa = PBXTargetDependency;
+                       target = 517B5F5A275A8D3E002DC22D /* webpushtool */;
+                       targetProxy = 517B5F6C275B07C3002DC22D /* PBXContainerItemProxy */;
+               };
</ins><span class="cx">           5742A2E62535613F00B7BA14 /* PBXTargetDependency */ = {
</span><span class="cx">                  isa = PBXTargetDependency;
</span><span class="cx">                  target = E1AC2E2720F7B94C00B0897D /* Unlock Keychain */;
</span><span class="lines">@@ -15630,6 +15701,27 @@
</span><span class="cx">                  };
</span><span class="cx">                  name = Production;
</span><span class="cx">          };
</span><ins>+               517B5F5F275A8D3E002DC22D /* Debug */ = {
+                       isa = XCBuildConfiguration;
+                       baseConfigurationReference = 517B5F6A275AA199002DC22D /* webpushtool.xcconfig */;
+                       buildSettings = {
+                       };
+                       name = Debug;
+               };
+               517B5F60275A8D3E002DC22D /* Release */ = {
+                       isa = XCBuildConfiguration;
+                       baseConfigurationReference = 517B5F6A275AA199002DC22D /* webpushtool.xcconfig */;
+                       buildSettings = {
+                       };
+                       name = Release;
+               };
+               517B5F61275A8D3E002DC22D /* Production */ = {
+                       isa = XCBuildConfiguration;
+                       baseConfigurationReference = 517B5F6A275AA199002DC22D /* webpushtool.xcconfig */;
+                       buildSettings = {
+                       };
+                       name = Production;
+               };
</ins><span class="cx">           5325BDCE21DFF47800A0DEE1 /* Debug */ = {
</span><span class="cx">                  isa = XCBuildConfiguration;
</span><span class="cx">                  baseConfigurationReference = BCB86F4B116AAACD00CE20B7 /* WebKit.xcconfig */;
</span><span class="lines">@@ -16023,6 +16115,16 @@
</span><span class="cx">                  defaultConfigurationIsVisible = 0;
</span><span class="cx">                  defaultConfigurationName = Production;
</span><span class="cx">          };
</span><ins>+               517B5F62275A8D3E002DC22D /* Build configuration list for PBXNativeTarget "webpushtool" */ = {
+                       isa = XCConfigurationList;
+                       buildConfigurations = (
+                               517B5F5F275A8D3E002DC22D /* Debug */,
+                               517B5F60275A8D3E002DC22D /* Release */,
+                               517B5F61275A8D3E002DC22D /* Production */,
+                       );
+                       defaultConfigurationIsVisible = 0;
+                       defaultConfigurationName = Production;
+               };
</ins><span class="cx">           5325BDD121DFF47800A0DEE1 /* Build configuration list for PBXAggregateTarget "Apply Configuration to XCFileLists" */ = {
</span><span class="cx">                  isa = XCConfigurationList;
</span><span class="cx">                  buildConfigurations = (
</span></span></pre></div>
<a id="branchessafari613110branchSourceWebKitWebKitxcodeprojxcshareddataxcschemeswebpushtoolxcscheme"></a>
<div class="addfile"><h4>Added: branches/safari-613.1.10-branch/Source/WebKit/WebKit.xcodeproj/xcshareddata/xcschemes/webpushtool.xcscheme (0 => 286615)</h4>
<pre class="diff"><span>
<span class="info">--- branches/safari-613.1.10-branch/Source/WebKit/WebKit.xcodeproj/xcshareddata/xcschemes/webpushtool.xcscheme                               (rev 0)
+++ branches/safari-613.1.10-branch/Source/WebKit/WebKit.xcodeproj/xcshareddata/xcschemes/webpushtool.xcscheme  2021-12-07 21:19:46 UTC (rev 286615)
</span><span class="lines">@@ -0,0 +1,81 @@
</span><ins>+<?xml version="1.0" encoding="UTF-8"?>
+<Scheme
+   LastUpgradeVersion = "1300"
+   version = "1.7">
+   <BuildAction
+      parallelizeBuildables = "YES"
+      buildImplicitDependencies = "YES">
+      <BuildActionEntries>
+         <BuildActionEntry
+            buildForTesting = "YES"
+            buildForRunning = "YES"
+            buildForProfiling = "YES"
+            buildForArchiving = "YES"
+            buildForAnalyzing = "YES">
+            <BuildableReference
+               BuildableIdentifier = "primary"
+               BlueprintIdentifier = "517B5F5A275A8D3E002DC22D"
+               BuildableName = "webpushtool"
+               BlueprintName = "webpushtool"
+               ReferencedContainer = "container:WebKit.xcodeproj">
+            </BuildableReference>
+         </BuildActionEntry>
+      </BuildActionEntries>
+   </BuildAction>
+   <TestAction
+      buildConfiguration = "Debug"
+      selectedDebuggerIdentifier = "Xcode.DebuggerFoundation.Debugger.LLDB"
+      selectedLauncherIdentifier = "Xcode.DebuggerFoundation.Launcher.LLDB"
+      shouldUseLaunchSchemeArgsEnv = "YES">
+      <Testables>
+      </Testables>
+   </TestAction>
+   <LaunchAction
+      buildConfiguration = "Debug"
+      selectedDebuggerIdentifier = "Xcode.DebuggerFoundation.Debugger.LLDB"
+      selectedLauncherIdentifier = "Xcode.DebuggerFoundation.Launcher.LLDB"
+      launchStyle = "0"
+      useCustomWorkingDirectory = "NO"
+      ignoresPersistentStateOnLaunch = "NO"
+      debugDocumentVersioning = "YES"
+      debugServiceExtension = "internal"
+      allowLocationSimulation = "YES">
+      <BuildableProductRunnable
+         runnableDebuggingMode = "0">
+         <BuildableReference
+            BuildableIdentifier = "primary"
+            BlueprintIdentifier = "517B5F5A275A8D3E002DC22D"
+            BuildableName = "webpushtool"
+            BlueprintName = "webpushtool"
+            ReferencedContainer = "container:WebKit.xcodeproj">
+         </BuildableReference>
+      </BuildableProductRunnable>
+   </LaunchAction>
+   <ProfileAction
+      buildConfiguration = "Release"
+      shouldUseLaunchSchemeArgsEnv = "YES"
+      savedToolIdentifier = ""
+      useCustomWorkingDirectory = "NO"
+      debugDocumentVersioning = "YES">
+      <BuildableProductRunnable
+         runnableDebuggingMode = "0">
+         <BuildableReference
+            BuildableIdentifier = "primary"
+            BlueprintIdentifier = "517B5F5A275A8D3E002DC22D"
+            BuildableName = "webpushtool"
+            BlueprintName = "webpushtool"
+            ReferencedContainer = "container:WebKit.xcodeproj">
+         </BuildableReference>
+      </BuildableProductRunnable>
+   </ProfileAction>
+   <AnalyzeAction
+      buildConfiguration = "Debug">
+   </AnalyzeAction>
+   <ArchiveAction
+      buildConfiguration = "Release"
+      revealArchiveInOrganizer = "YES">
+   </ArchiveAction>
+   <InstallAction
+      buildConfiguration = "Release">
+   </InstallAction>
+</Scheme>
</ins></span></pre></div>
<a id="branchessafari613110branchSourceWebKitwebpushdwebpushtoolWebPushToolConnectionh"></a>
<div class="addfile"><h4>Added: branches/safari-613.1.10-branch/Source/WebKit/webpushd/webpushtool/WebPushToolConnection.h (0 => 286615)</h4>
<pre class="diff"><span>
<span class="info">--- branches/safari-613.1.10-branch/Source/WebKit/webpushd/webpushtool/WebPushToolConnection.h                               (rev 0)
+++ branches/safari-613.1.10-branch/Source/WebKit/webpushd/webpushtool/WebPushToolConnection.h  2021-12-07 21:19:46 UTC (rev 286615)
</span><span class="lines">@@ -0,0 +1,61 @@
</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.
+ */
+
+#pragma once
+
+#include <memory>
+#include <wtf/RetainPtr.h>
+#include <wtf/WeakPtr.h>
+#include <wtf/spi/darwin/XPCSPI.h>
+
+namespace WebPushTool {
+
+enum class Action {
+    StreamDebugMessages,
+};
+
+class Connection : public CanMakeWeakPtr<Connection> {
+    WTF_MAKE_FAST_ALLOCATED;
+public:
+    static std::unique_ptr<Connection> create(Action, bool preferTestService);
+    Connection(Action, bool preferTestService);
+
+    void connectToService();
+
+private:
+    void messageReceived(xpc_object_t);
+    void connectionDropped();
+
+    void startAction();
+    void startDebugStreamAction();
+
+    void sendAuditToken();
+    
+    Action m_action;
+    RetainPtr<xpc_connection_t> m_connection;
+    const char* m_serviceName;
+};
+
+} // namespace WebPushTool
</ins></span></pre></div>
<a id="branchessafari613110branchSourceWebKitwebpushdwebpushtoolWebPushToolConnectionmm"></a>
<div class="addfile"><h4>Added: branches/safari-613.1.10-branch/Source/WebKit/webpushd/webpushtool/WebPushToolConnection.mm (0 => 286615)</h4>
<pre class="diff"><span>
<span class="info">--- branches/safari-613.1.10-branch/Source/WebKit/webpushd/webpushtool/WebPushToolConnection.mm                              (rev 0)
+++ branches/safari-613.1.10-branch/Source/WebKit/webpushd/webpushtool/WebPushToolConnection.mm 2021-12-07 21:19:46 UTC (rev 286615)
</span><span class="lines">@@ -0,0 +1,169 @@
</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"
+#import "WebPushToolConnection.h"
+
+#import <mach/mach_init.h>
+#import <mach/task.h>
+#import <pal/spi/cocoa/ServersSPI.h>
+#import <wtf/RetainPtr.h>
+
+namespace WebPushTool {
+
+std::unique_ptr<Connection> Connection::create(Action action, bool preferTestService)
+{
+    return makeUnique<Connection>(action, preferTestService);
+}
+
+static mach_port_t maybeConnectToService(const char* serviceName)
+{
+    mach_port_t bsPort;
+    task_get_special_port(mach_task_self(), TASK_BOOTSTRAP_PORT, &bsPort);
+
+    mach_port_t servicePort;
+    kern_return_t err = bootstrap_look_up(bsPort, serviceName, &servicePort);
+
+    if (err == KERN_SUCCESS)
+        return servicePort;
+
+    return MACH_PORT_NULL;
+}
+
+Connection::Connection(Action action, bool preferTestService)
+    : m_action(action)
+{
+    if (preferTestService)
+        m_serviceName = "org.webkit.webpushtestdaemon.service";
+    else
+        m_serviceName = "com.apple.webkit.webpushd.service";
+
+    m_connection = adoptNS(xpc_connection_create_mach_service(m_serviceName, dispatch_get_main_queue(), 0));
+
+    xpc_connection_set_event_handler(m_connection.get(), [this, weakThis = WeakPtr { *this }](xpc_object_t event) {
+        if (!weakThis)
+            return;
+
+        if (event == XPC_ERROR_CONNECTION_INVALID) {
+            printf("Failed to start listening for connections to mach service\n");
+            connectionDropped();
+            return;
+        }
+
+        if (event == XPC_ERROR_CONNECTION_INTERRUPTED) {
+            printf("Connection closed\n");
+            connectionDropped();
+            return;
+        }
+
+        if (xpc_get_type(event) == XPC_TYPE_DICTIONARY) {
+            messageReceived(event);
+            return;
+        }
+
+        RELEASE_ASSERT_NOT_REACHED();
+    });
+}
+
+void Connection::connectToService()
+{
+    if (!m_connection)
+        return;
+
+    auto result = maybeConnectToService(m_serviceName);
+    if (result == MACH_PORT_NULL)
+        printf("Waiting for service '%s' to be available\n", m_serviceName);
+
+    while (result == MACH_PORT_NULL) {
+        usleep(1000);
+        result = maybeConnectToService(m_serviceName);
+    }
+
+    xpc_connection_activate(m_connection.get());
+
+    sendAuditToken();
+    startAction();
+}
+
+void Connection::startAction()
+{
+    switch (m_action) {
+    case Action::StreamDebugMessages:
+        startDebugStreamAction();
+        break;
+    };
+}
+
+void Connection::startDebugStreamAction()
+{
+    auto dictionary = adoptNS(xpc_dictionary_create(nullptr, nullptr, 0));
+    std::array<uint8_t, 1> encodedMessage { 1 };
+    xpc_dictionary_set_uint64(dictionary.get(), "protocol version", 1);
+    xpc_dictionary_set_uint64(dictionary.get(), "message type", 5);
+    xpc_dictionary_set_data(dictionary.get(), "encoded message", encodedMessage.data(), encodedMessage.size());
+
+    xpc_connection_send_message(m_connection.get(), dictionary.get());
+
+    printf("Now streaming debug messages\n");
+}
+
+void Connection::sendAuditToken()
+{
+    audit_token_t token = { 0, 0, 0, 0, 0, 0, 0, 0 };
+    mach_msg_type_number_t auditTokenCount = TASK_AUDIT_TOKEN_COUNT;
+    kern_return_t result = task_info(mach_task_self(), TASK_AUDIT_TOKEN, (task_info_t)(&token), &auditTokenCount);
+    if (result != KERN_SUCCESS) {
+        printf("Unable to get audit token to send\n");
+        return;
+    }
+
+    std::array<uint8_t, 42> encodedMessage;
+    encodedMessage.fill(0);
+    encodedMessage[1] = 1;
+    encodedMessage[2] = 32;
+    memcpy(&encodedMessage[10], &token, sizeof(token));
+    auto dictionary = adoptNS(xpc_dictionary_create(nullptr, nullptr, 0));
+    xpc_dictionary_set_uint64(dictionary.get(), "protocol version", 1);
+    xpc_dictionary_set_uint64(dictionary.get(), "message type", 6);
+    xpc_dictionary_set_data(dictionary.get(), "encoded message", encodedMessage.data(), encodedMessage.size());
+    xpc_connection_send_message(m_connection.get(), dictionary.get());
+}
+
+void Connection::connectionDropped()
+{
+    m_connection = nullptr;
+    CFRunLoopStop(CFRunLoopGetCurrent());
+}
+
+void Connection::messageReceived(xpc_object_t message)
+{
+    const char* debugMessage = xpc_dictionary_get_string(message, "debug message");
+    if (!debugMessage)
+        return;
+
+    printf("%s\n", debugMessage);
+}
+
+} // namespace WebPushTool
</ins></span></pre></div>
<a id="branchessafari613110branchSourceWebKitwebpushdwebpushtoolWebPushToolMainmm"></a>
<div class="addfile"><h4>Added: branches/safari-613.1.10-branch/Source/WebKit/webpushd/webpushtool/WebPushToolMain.mm (0 => 286615)</h4>
<pre class="diff"><span>
<span class="info">--- branches/safari-613.1.10-branch/Source/WebKit/webpushd/webpushtool/WebPushToolMain.mm                            (rev 0)
+++ branches/safari-613.1.10-branch/Source/WebKit/webpushd/webpushtool/WebPushToolMain.mm       2021-12-07 21:19:46 UTC (rev 286615)
</span><span class="lines">@@ -0,0 +1,76 @@
</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"
+#import "WebPushToolConnection.h"
+#import <Foundation/Foundation.h>
+#import <optional>
+
+__attribute__((__noreturn__))
+static void printUsageAndTerminate(NSString *message)
+{
+    fprintf(stderr, "%s\n\n", message.UTF8String);
+
+    fprintf(stderr, "Usage: webpushtool [options]\n");
+    fprintf(stderr, "\n");
+    fprintf(stderr, "  --development              Connects to mach service \"org.webkit.webpushtestdaemon.service\" (Default)\n");
+    fprintf(stderr, "  --production               Connects to mach service \"com.apple.webkit.webpushd.service\"\n");
+    fprintf(stderr, "  --streamDebugMessages      Stream debug messages from webpushd\n");
+    fprintf(stderr, "\n");
+
+    exit(-1);
+}
+
+int main(int, const char **)
+{
+    bool preferTestService = true;
+    std::optional<WebPushTool::Action> action;
+
+    @autoreleasepool {
+        NSArray *arguments = [[NSProcessInfo processInfo] arguments];
+        if (arguments.count == 1)
+            printUsageAndTerminate(@"No arguments provided");
+
+        for (NSString *argument in [arguments subarrayWithRange:NSMakeRange(1, arguments.count - 1)]) {
+            if ([argument isEqualToString:@"--production"])
+                preferTestService = false;
+            if ([argument isEqualToString:@"--development"])
+                preferTestService = true;
+            else if ([argument isEqualToString:@"--streamDebugMessages"])
+                action = WebPushTool::Action::StreamDebugMessages;
+            else
+                printUsageAndTerminate([NSString stringWithFormat:@"Invalid option provided: %@", argument]);
+        }
+    }
+
+    if (!action)
+        printUsageAndTerminate(@"No action provided");
+
+    auto connection = WebPushTool::Connection::create(*action, preferTestService);
+    connection->connectToService();
+
+    CFRunLoopRun();
+    return 0;
+}
</ins></span></pre>
</div>
</div>

</body>
</html>