Add a test to check for the service worker process name
authoryouenn@apple.com <youenn@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Mon, 8 Apr 2019 22:29:47 +0000 (22:29 +0000)
committeryouenn@apple.com <youenn@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Mon, 8 Apr 2019 22:29:47 +0000 (22:29 +0000)
https://bugs.webkit.org/show_bug.cgi?id=196621

Reviewed by Chris Dumez.

Source/WebCore:

Add a service worker internal API to get process name.
Covered by updated test.

* WebCore.xcodeproj/project.pbxproj:
* testing/ServiceWorkerInternals.cpp:
(WebCore::ServiceWorkerInternals::processName const):
* testing/ServiceWorkerInternals.h:
* testing/ServiceWorkerInternals.idl:
* testing/ServiceWorkerInternals.mm: Added.

LayoutTests:

* http/wpt/service-workers/online-worker.js:
(async.doTest):

git-svn-id: https://svn.webkit.org/repository/webkit/trunk@244054 268f45cc-cd09-0410-ab3c-d52691b4dbfc

LayoutTests/ChangeLog
LayoutTests/http/wpt/service-workers/online-worker.js
Source/WebCore/ChangeLog
Source/WebCore/WebCore.xcodeproj/project.pbxproj
Source/WebCore/testing/ServiceWorkerInternals.cpp
Source/WebCore/testing/ServiceWorkerInternals.h
Source/WebCore/testing/ServiceWorkerInternals.idl
Source/WebCore/testing/ServiceWorkerInternals.mm [new file with mode: 0644]

index 2d91839..ef0535b 100644 (file)
@@ -1,3 +1,13 @@
+2019-04-08  Youenn Fablet  <youenn@apple.com>
+
+        Add a test to check for the service worker process name
+        https://bugs.webkit.org/show_bug.cgi?id=196621
+
+        Reviewed by Chris Dumez.
+
+        * http/wpt/service-workers/online-worker.js:
+        (async.doTest):
+
 2019-04-08  Shawn Roberts  <sroberts@apple.com>
 
         fast/parser/xml-error-adopted.xml is a flaky timeout
index 165ce3f..3ce0ca8 100644 (file)
@@ -27,6 +27,11 @@ async function doTest(event)
             return;
         }
 
+        if (self.internals.processName !== "none" && self.internals.processName !== "WebKitTestRunner Service Worker (localhost)") {
+            event.source.postMessage("FAIL: wrong service worker process name: " + self.internals.processName + "'");
+            return;
+        }
+
         internals.setOnline(true);
         var eventName = await waitForOnlineEvent();
         if (!navigator.onLine)
index 67a3b71..285c7bb 100644 (file)
@@ -1,3 +1,20 @@
+2019-04-08  Youenn Fablet  <youenn@apple.com>
+
+        Add a test to check for the service worker process name
+        https://bugs.webkit.org/show_bug.cgi?id=196621
+
+        Reviewed by Chris Dumez.
+
+        Add a service worker internal API to get process name.
+        Covered by updated test.
+
+        * WebCore.xcodeproj/project.pbxproj:
+        * testing/ServiceWorkerInternals.cpp:
+        (WebCore::ServiceWorkerInternals::processName const):
+        * testing/ServiceWorkerInternals.h:
+        * testing/ServiceWorkerInternals.idl:
+        * testing/ServiceWorkerInternals.mm: Added.
+
 2019-04-08  Yusuke Suzuki  <ysuzuki@apple.com>
 
         Unreviewed, speculative fix for build failure in old macOS after r243887
index d010d51..a89379e 100644 (file)
                41D129D51F3D0F6900D15E47 /* CacheStorageProvider.h in Headers */ = {isa = PBXBuildFile; fileRef = 41D129D41F3D0F6600D15E47 /* CacheStorageProvider.h */; settings = {ATTRIBUTES = (Private, ); }; };
                41D129DB1F3D143800D15E47 /* FetchHeaders.h in Headers */ = {isa = PBXBuildFile; fileRef = 41F54F831C50C4F600338488 /* FetchHeaders.h */; settings = {ATTRIBUTES = (Private, ); }; };
                41D28D0D2139E05800F4206F /* LibWebRTCStatsCollector.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 41D28D0B2139E01D00F4206F /* LibWebRTCStatsCollector.cpp */; };
+               41D41C672256874F00697942 /* ServiceWorkerInternals.mm in Sources */ = {isa = PBXBuildFile; fileRef = 41D41C652256859200697942 /* ServiceWorkerInternals.mm */; };
                41DE7C7C222DA14300532B65 /* StorageQuotaManager.h in Headers */ = {isa = PBXBuildFile; fileRef = 41DE7C7B222DA13E00532B65 /* StorageQuotaManager.h */; settings = {ATTRIBUTES = (Private, ); }; };
                41DE7C7D222DA14800532B65 /* StorageQuotaUser.h in Headers */ = {isa = PBXBuildFile; fileRef = 41DE7C78222DA13C00532B65 /* StorageQuotaUser.h */; settings = {ATTRIBUTES = (Private, ); }; };
                41DEFCB61E56C1BD000D9E5F /* JSDOMMapLike.h in Headers */ = {isa = PBXBuildFile; fileRef = 41DEFCB41E56C1B9000D9E5F /* JSDOMMapLike.h */; };
                41D1A04C213EDDFF0063FB6B /* LibWebRTCUtils.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; name = LibWebRTCUtils.h; path = libwebrtc/LibWebRTCUtils.h; sourceTree = "<group>"; };
                41D28D0B2139E01D00F4206F /* LibWebRTCStatsCollector.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = LibWebRTCStatsCollector.cpp; path = libwebrtc/LibWebRTCStatsCollector.cpp; sourceTree = "<group>"; };
                41D28D0C2139E01E00F4206F /* LibWebRTCStatsCollector.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = LibWebRTCStatsCollector.h; path = libwebrtc/LibWebRTCStatsCollector.h; sourceTree = "<group>"; };
+               41D41C652256859200697942 /* ServiceWorkerInternals.mm */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.objcpp; path = ServiceWorkerInternals.mm; sourceTree = "<group>"; };
                41D51BB21E4E2E8100131A5B /* LibWebRTCAudioFormat.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = LibWebRTCAudioFormat.h; path = libwebrtc/LibWebRTCAudioFormat.h; sourceTree = "<group>"; };
                41DE7C78222DA13C00532B65 /* StorageQuotaUser.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = StorageQuotaUser.h; sourceTree = "<group>"; };
                41DE7C7A222DA13D00532B65 /* StorageQuotaManager.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = StorageQuotaManager.cpp; sourceTree = "<group>"; };
                                417F0D801FFEE14F008EF303 /* ServiceWorkerInternals.cpp */,
                                417F0D7E1FFEE14E008EF303 /* ServiceWorkerInternals.h */,
                                417F0D811FFEE150008EF303 /* ServiceWorkerInternals.idl */,
+                               41D41C652256859200697942 /* ServiceWorkerInternals.mm */,
                                EB081CD81696084400553730 /* TypeConversions.h */,
                                EB081CD91696084400553730 /* TypeConversions.idl */,
                                E1BA67191742BEF400C20251 /* WebCoreTestShimLibrary.cpp */,
                                939885C408B7E3D100E707C4 /* EventNames.h in Headers */,
                                9B714E211C91166900AC0E92 /* EventPath.h in Headers */,
                                8F67561B1288B17B0047ACA3 /* EventQueue.h in Headers */,
+                               E4A8D21622578DB700A8463C /* EventRegion.h in Headers */,
                                E0FEF372B17C53EAC1C1FBEE /* EventSource.h in Headers */,
                                E12EDB7B0B308A78002704B6 /* EventTarget.h in Headers */,
                                97AA3CA5145237CC003E1DA6 /* EventTargetHeaders.h in Headers */,
                                E446143A0CD689C800FADA75 /* JSHTMLMediaElement.h in Headers */,
                                1AE2AE5C0A1D26F200B42B25 /* JSHTMLMenuElement.h in Headers */,
                                A80E7A180A19C3D6007FB8C5 /* JSHTMLMetaElement.h in Headers */,
-                               E4A8D21622578DB700A8463C /* EventRegion.h in Headers */,
                                A7BBE26711AFB3F20005EA03 /* JSHTMLMeterElement.h in Headers */,
                                1AE2AB2A0A1CE63B00B42B25 /* JSHTMLModElement.h in Headers */,
                                BC305C7A0C076BB300CD20F0 /* JSHTMLObjectElement.h in Headers */,
                                A140618B1E2ECA0A0032B34E /* MockPreviewLoaderClient.cpp in Sources */,
                                AA5F3B8F16CC4B3900455EB0 /* PlatformSpeechSynthesizerMock.cpp in Sources */,
                                417F0D821FFEE979008EF303 /* ServiceWorkerInternals.cpp in Sources */,
+                               41D41C672256874F00697942 /* ServiceWorkerInternals.mm in Sources */,
                                DE7710861FA2F0D600460016 /* WebArchiveDumpSupport.mm in Sources */,
                                41815C1E138319830057AAA4 /* WebCoreTestSupport.cpp in Sources */,
                        );
index 887894e..27417da 100644 (file)
@@ -89,6 +89,13 @@ Vector<String> ServiceWorkerInternals::fetchResponseHeaderList(FetchResponse& re
     return headerNames;
 }
 
+#if !PLATFORM(MAC)
+String ServiceWorkerInternals::processName() const
+{
+    return "none"_s;
+}
+#endif
+
 } // namespace WebCore
 
 #endif
index 01de501..8171c86 100644 (file)
@@ -49,6 +49,8 @@ public:
 
     Vector<String> fetchResponseHeaderList(FetchResponse&);
 
+    String processName() const;
+
 private:
     explicit ServiceWorkerInternals(ServiceWorkerIdentifier);
 
index d0e2de5..1d131b2 100644 (file)
@@ -35,4 +35,6 @@
     [CallWith=ScriptExecutionContext] FetchResponse createOpaqueWithBlobBodyResponse();
 
     sequence<ByteString> fetchResponseHeaderList(FetchResponse response);
+
+    readonly attribute DOMString processName;
 };
diff --git a/Source/WebCore/testing/ServiceWorkerInternals.mm b/Source/WebCore/testing/ServiceWorkerInternals.mm
new file mode 100644 (file)
index 0000000..0d6d01d
--- /dev/null
@@ -0,0 +1,46 @@
+/*
+ * Copyright (C) 2018 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 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 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.
+ */
+
+#include "config.h"
+#include "ServiceWorkerInternals.h"
+
+#if ENABLE(SERVICE_WORKER)
+
+#if PLATFORM(MAC)
+
+#import <pal/spi/cocoa/LaunchServicesSPI.h>
+
+namespace WebCore {
+
+String ServiceWorkerInternals::processName() const
+{
+    return adoptCF((CFStringRef)_LSCopyApplicationInformationItem(kLSDefaultSessionID, _LSGetCurrentApplicationASN(), _kLSDisplayNameKey)).get();
+}
+
+} // namespace WebCore
+
+#endif
+
+#endif