WebKit Bugzilla
Attachment 357380 Details for
Bug 192735
: Allow clients to set the navigator platform
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Requests
|
Help
|
New Account
|
Log In
Remember
[x]
|
Forgot Password
Login:
[x]
[patch]
Patch
bug-192735-20181214193524.patch (text/plain), 87.61 KB, created by
Megan Gardner
on 2018-12-14 19:35:25 PST
(
hide
)
Description:
Patch
Filename:
MIME Type:
Creator:
Megan Gardner
Created:
2018-12-14 19:35:25 PST
Size:
87.61 KB
patch
obsolete
>Subversion Revision: 239171 >diff --git a/Source/WebCore/ChangeLog b/Source/WebCore/ChangeLog >index c7c333bbc491e236532813334d0f41a531b75075..d92f1456b41cde729f53b241276aea47c36bdd80 100644 >--- a/Source/WebCore/ChangeLog >+++ b/Source/WebCore/ChangeLog >@@ -1,3 +1,76 @@ >+2018-12-14 Megan Gardner <megan_gardner@apple.com> >+ >+ Allow clients to set the navigator platform >+ https://bugs.webkit.org/show_bug.cgi?id=192735 >+ >+ Reviewed by NOBODY (OOPS!). >+ >+ Expanded TestWebKitAPI/Tests/WebKitCocoa/WebsitePolicies.mm. >+ >+ Lots of piping to allow the setting of a custom navigator platform. >+ >+ * dom/Document.cpp: >+ (WebCore::Document::navigatorPlatform const): >+ * dom/Document.h: >+ * dom/ScriptExecutionContext.h: >+ * loader/DocumentLoader.h: >+ (WebCore::DocumentLoader::setCustomNavigatorPlatform): >+ (WebCore::DocumentLoader::customNavigatorPlatform const): >+ * loader/EmptyFrameLoaderClient.h: >+ * loader/FrameLoader.cpp: >+ (WebCore::FrameLoader::navigatorPlatform const): >+ * loader/FrameLoader.h: >+ * loader/FrameLoaderClient.h: >+ * page/Navigator.cpp: >+ (WebCore::Navigator::platform const): >+ * page/Navigator.h: >+ * page/NavigatorBase.cpp: >+ (WebCore::NavigatorBase::platform): Deleted. >+ * page/NavigatorBase.h: >+ * page/WorkerNavigator.cpp: >+ (WebCore::WorkerNavigator::WorkerNavigator): >+ (WebCore::WorkerNavigator::platform const): >+ * page/WorkerNavigator.h: >+ * workers/DedicatedWorkerGlobalScope.cpp: >+ (WebCore::DedicatedWorkerGlobalScope::create): >+ (WebCore::DedicatedWorkerGlobalScope::DedicatedWorkerGlobalScope): >+ * workers/DedicatedWorkerGlobalScope.h: >+ * workers/DedicatedWorkerThread.cpp: >+ (WebCore::DedicatedWorkerThread::DedicatedWorkerThread): >+ (WebCore::DedicatedWorkerThread::createWorkerGlobalScope): >+ * workers/DedicatedWorkerThread.h: >+ * workers/Worker.cpp: >+ (WebCore::Worker::notifyFinished): >+ * workers/WorkerGlobalScope.cpp: >+ (WebCore::WorkerGlobalScope::WorkerGlobalScope): >+ (WebCore::WorkerGlobalScope::navigatorPlatform const): >+ (WebCore::WorkerGlobalScope::navigator): >+ * workers/WorkerGlobalScope.h: >+ * workers/WorkerGlobalScopeProxy.h: >+ * workers/WorkerMessagingProxy.cpp: >+ (WebCore::WorkerMessagingProxy::startWorkerGlobalScope): >+ * workers/WorkerMessagingProxy.h: >+ * workers/WorkerThread.cpp: >+ (WebCore::WorkerThreadStartupData::WorkerThreadStartupData): >+ (WebCore::WorkerThread::WorkerThread): >+ (WebCore::WorkerThread::workerThread): >+ * workers/WorkerThread.h: >+ * workers/service/ServiceWorkerGlobalScope.cpp: >+ (WebCore::ServiceWorkerGlobalScope::create): >+ (WebCore::ServiceWorkerGlobalScope::ServiceWorkerGlobalScope): >+ * workers/service/ServiceWorkerGlobalScope.h: >+ * workers/service/context/ServiceWorkerThread.cpp: >+ (WebCore::ServiceWorkerThread::ServiceWorkerThread): >+ (WebCore::ServiceWorkerThread::createWorkerGlobalScope): >+ * workers/service/context/ServiceWorkerThread.h: >+ * workers/service/context/ServiceWorkerThreadProxy.cpp: >+ (WebCore::ServiceWorkerThreadProxy::ServiceWorkerThreadProxy): >+ * workers/service/context/ServiceWorkerThreadProxy.h: >+ * worklets/WorkletGlobalScope.cpp: >+ (WebCore::WorkletGlobalScope::userAgent const): >+ (WebCore::WorkletGlobalScope::navigatorPlatform const): >+ * worklets/WorkletGlobalScope.h: >+ > 2018-12-13 Eric Carlson <eric.carlson@apple.com> > > [MediaStream] Calculate width or height when constraints contain only the other >diff --git a/Source/WebKit/ChangeLog b/Source/WebKit/ChangeLog >index c9a427397c1ffd3b1433759088f3084c7e825ba3..ad355370286db5e0fe70ebd7431bb6a8b727958b 100644 >--- a/Source/WebKit/ChangeLog >+++ b/Source/WebKit/ChangeLog >@@ -1,3 +1,46 @@ >+2018-12-14 Megan Gardner <megan_gardner@apple.com> >+ >+ Allow clients to set the navigator platform >+ https://bugs.webkit.org/show_bug.cgi?id=192735 >+ >+ Reviewed by NOBODY (OOPS!). >+ >+ Add private API to allow clients to override the default navigator >+ platform. Some websites check for the platform, which >+ interfears with our request desktop site feature. This should >+ help more sites function as expected. >+ >+ * Shared/WebsitePoliciesData.cpp: >+ (WebKit::WebsitePoliciesData::encode const): >+ (WebKit::WebsitePoliciesData::decode): >+ (WebKit::WebsitePoliciesData::applyToDocumentLoader): >+ * Shared/WebsitePoliciesData.h: >+ * UIProcess/API/APIWebsitePolicies.cpp: >+ (API::WebsitePolicies::data): >+ * UIProcess/API/APIWebsitePolicies.h: >+ * UIProcess/API/Cocoa/_WKWebsitePolicies.h: >+ * UIProcess/API/Cocoa/_WKWebsitePolicies.mm: >+ (-[_WKWebsitePolicies setCustomNavigatorPlatform:]): >+ (-[_WKWebsitePolicies customNavigatorPlatform]): >+ * UIProcess/Cocoa/NavigationState.mm: >+ (WebKit::NavigationState::NavigationClient::decidePolicyForNavigationAction): >+ * WebProcess/InjectedBundle/API/c/WKBundlePageLoaderClient.h: >+ * WebProcess/Storage/WebSWContextManagerConnection.cpp: >+ (WebKit::WebSWContextManagerConnection::installServiceWorker): >+ (WebKit::WebSWContextManagerConnection::setNavigatorPlatform): >+ * WebProcess/Storage/WebSWContextManagerConnection.h: >+ * WebProcess/WebCoreSupport/WebFrameLoaderClient.cpp: >+ (WebKit::WebFrameLoaderClient::navigatorPlatform): >+ * WebProcess/WebCoreSupport/WebFrameLoaderClient.h: >+ * WebProcess/WebPage/WebPage.cpp: >+ (WebKit::WebPage::navigatorPlatform const): >+ (WebKit::WebPage::setNavigatorPlatform): >+ * WebProcess/WebPage/WebPage.h: >+ * WebProcess/WebPage/ios/WebPageIOS.mm: >+ (WebKit::WebPage::platformNavigatorPlatform const): >+ * WebProcess/WebPage/mac/WebPageMac.mm: >+ (WebKit::WebPage::platformNavigatorPlatform const): >+ > 2018-12-13 Per Arne Vollan <pvollan@apple.com> > > [macOS] Remove with-report from 3 services that are currently needed on macOS >diff --git a/Source/WebKitLegacy/mac/ChangeLog b/Source/WebKitLegacy/mac/ChangeLog >index 3570259861438dfaf540882c263c9945b1099ea6..a027dc3330ff1568341465f56af60ab75a00bc24 100644 >--- a/Source/WebKitLegacy/mac/ChangeLog >+++ b/Source/WebKitLegacy/mac/ChangeLog >@@ -1,3 +1,16 @@ >+2018-12-14 Megan Gardner <megan_gardner@apple.com> >+ >+ Allow clients to set the navigator platform >+ https://bugs.webkit.org/show_bug.cgi?id=192735 >+ >+ Reviewed by NOBODY (OOPS!). >+ >+ Add stubs to fill out the added functionality in FrameLoaderClient. >+ >+ * WebCoreSupport/WebFrameLoaderClient.h: >+ * WebCoreSupport/WebFrameLoaderClient.mm: >+ (WebFrameLoaderClient::navigatorPlatform): >+ > 2018-12-12 Ryosuke Niwa <rniwa@webkit.org> > > Make TextInputController.legacyAttributedString take DOM nodes and offsets >diff --git a/Source/WebCore/dom/Document.cpp b/Source/WebCore/dom/Document.cpp >index d6be912b123ab17970e88b482146091383aabdda..297b409dc6d0809fe8311c3e8a617a438d51877a 100644 >--- a/Source/WebCore/dom/Document.cpp >+++ b/Source/WebCore/dom/Document.cpp >@@ -3286,6 +3286,11 @@ String Document::userAgent(const URL& url) const > { > return frame() ? frame()->loader().userAgent(url) : String(); > } >+ >+String Document::navigatorPlatform() const >+{ >+ return frame() ? frame()->loader().navigatorPlatform() : String(); >+} > > void Document::disableEval(const String& errorMessage) > { >diff --git a/Source/WebCore/dom/Document.h b/Source/WebCore/dom/Document.h >index 4cca3a1d1204582882ad87238187bc24d8e9b952..7b211447d813892e94fb9d1122ef7ba303b7362d 100644 >--- a/Source/WebCore/dom/Document.h >+++ b/Source/WebCore/dom/Document.h >@@ -697,6 +697,7 @@ public: > WEBCORE_EXPORT PAL::SessionID sessionID() const final; > > String userAgent(const URL&) const final; >+ String navigatorPlatform() const final; > > void disableEval(const String& errorMessage) final; > void disableWebAssembly(const String& errorMessage) final; >diff --git a/Source/WebCore/dom/ScriptExecutionContext.h b/Source/WebCore/dom/ScriptExecutionContext.h >index 5c58527d38be45a0d108f0a3b3d1b8b7b6caab24..d31119f107c4ab431c44726ff305ebb0c40651cc 100644 >--- a/Source/WebCore/dom/ScriptExecutionContext.h >+++ b/Source/WebCore/dom/ScriptExecutionContext.h >@@ -98,6 +98,7 @@ public: > virtual PAL::SessionID sessionID() const = 0; > > virtual String userAgent(const URL&) const = 0; >+ virtual String navigatorPlatform() const = 0; > > virtual void disableEval(const String& errorMessage) = 0; > virtual void disableWebAssembly(const String& errorMessage) = 0; >diff --git a/Source/WebCore/loader/DocumentLoader.h b/Source/WebCore/loader/DocumentLoader.h >index 501a527378f98161166f0a1cbe761425141105e0..7945514d021b2e8012370b1725449ee2fe2205b2 100644 >--- a/Source/WebCore/loader/DocumentLoader.h >+++ b/Source/WebCore/loader/DocumentLoader.h >@@ -266,6 +266,9 @@ public: > > void setCustomUserAgent(const String& customUserAgent) { m_customUserAgent = customUserAgent; } > const String& customUserAgent() const { return m_customUserAgent; } >+ >+ void setCustomNavigatorPlatform(const String& customNavigatorPlatform) { m_customNavigatorPlatform = customNavigatorPlatform; } >+ const String& customNavigatorPlatform() const { return m_customNavigatorPlatform; } > > OptionSet<AutoplayQuirk> allowedAutoplayQuirks() const { return m_allowedAutoplayQuirks; } > void setAllowedAutoplayQuirks(OptionSet<AutoplayQuirk> allowedQuirks) { m_allowedAutoplayQuirks = allowedQuirks; } >@@ -536,6 +539,7 @@ private: > HashMap<String, Vector<std::pair<String, uint32_t>>> m_pendingContentExtensionDisplayNoneSelectors; > #endif > String m_customUserAgent; >+ String m_customNavigatorPlatform; > bool m_userContentExtensionsEnabled { true }; > AutoplayPolicy m_autoplayPolicy { AutoplayPolicy::Default }; > OptionSet<AutoplayQuirk> m_allowedAutoplayQuirks; >diff --git a/Source/WebCore/loader/EmptyFrameLoaderClient.h b/Source/WebCore/loader/EmptyFrameLoaderClient.h >index 4ff8df13ed5516ea8f254e0dbb787b45869291e6..7fc6f7f13530e3be4ecc0962b2be2b78a729fc26 100644 >--- a/Source/WebCore/loader/EmptyFrameLoaderClient.h >+++ b/Source/WebCore/loader/EmptyFrameLoaderClient.h >@@ -150,6 +150,7 @@ class WEBCORE_EXPORT EmptyFrameLoaderClient : public FrameLoaderClient { > void setTitle(const StringWithDirection&, const URL&) final { } > > String userAgent(const URL&) override { return emptyString(); } >+ String navigatorPlatform() override { return emptyString(); } > > void savePlatformDataToCachedFrame(CachedFrame*) final { } > void transitionToCommittedFromCachedFrame(CachedFrame*) final { } >diff --git a/Source/WebCore/loader/FrameLoader.cpp b/Source/WebCore/loader/FrameLoader.cpp >index 8336522a610628b84e3dd1794609bcf2ec12fb11..bc7d6c33411643f4971959eafcb618e6515b4bdf 100644 >--- a/Source/WebCore/loader/FrameLoader.cpp >+++ b/Source/WebCore/loader/FrameLoader.cpp >@@ -2672,6 +2672,16 @@ String FrameLoader::userAgent(const URL& url) const > > return m_client.userAgent(url); > } >+ >+String FrameLoader::navigatorPlatform() const >+{ >+ if (auto* documentLoader = m_frame.mainFrame().loader().activeDocumentLoader()) { >+ auto& customNavigatorPlatform = documentLoader->customNavigatorPlatform(); >+ if (!customNavigatorPlatform.isEmpty()) >+ return customNavigatorPlatform; >+ } >+ return String(); >+} > > void FrameLoader::dispatchOnloadEvents() > { >diff --git a/Source/WebCore/loader/FrameLoader.h b/Source/WebCore/loader/FrameLoader.h >index 2d8295532da1ff34ff5e1ce1316642611a0fc01e..a04aeb46bd9bba0a35ebb02230939cb215ee33ca 100644 >--- a/Source/WebCore/loader/FrameLoader.h >+++ b/Source/WebCore/loader/FrameLoader.h >@@ -234,6 +234,7 @@ public: > > void dispatchOnloadEvents(); > String userAgent(const URL&) const; >+ String navigatorPlatform() const; > > void dispatchDidClearWindowObjectInWorld(DOMWrapperWorld&); > void dispatchDidClearWindowObjectsInAllWorlds(); >diff --git a/Source/WebCore/loader/FrameLoaderClient.h b/Source/WebCore/loader/FrameLoaderClient.h >index 688c6b2528c9d225c6bf8537c0127e67e2e77aba..1363a2bcb0a8a94b21860cbb56539b7164124d3a 100644 >--- a/Source/WebCore/loader/FrameLoaderClient.h >+++ b/Source/WebCore/loader/FrameLoaderClient.h >@@ -269,6 +269,7 @@ public: > virtual void setTitle(const StringWithDirection&, const URL&) = 0; > > virtual String userAgent(const URL&) = 0; >+ virtual String navigatorPlatform() = 0; > > virtual String overrideContentSecurityPolicy() const { return String(); } > >diff --git a/Source/WebCore/page/Navigator.cpp b/Source/WebCore/page/Navigator.cpp >index a40fd22670f3f64197aabe7b4c375716b7404804..5f1c338e1510cae2945e2c71ad1d01db62fed08f 100644 >--- a/Source/WebCore/page/Navigator.cpp >+++ b/Source/WebCore/page/Navigator.cpp >@@ -46,6 +46,28 @@ > #include <wtf/StdLibExtras.h> > #include <wtf/WeakPtr.h> > >+#if OS(LINUX) >+#include "sys/utsname.h" >+#endif >+ >+#if PLATFORM(IOS_FAMILY) >+#include "Device.h" >+#endif >+ >+#ifndef WEBCORE_NAVIGATOR_PLATFORM >+#if PLATFORM(IOS_FAMILY) >+#define WEBCORE_NAVIGATOR_PLATFORM deviceName() >+#elif OS(MAC_OS_X) && (CPU(PPC) || CPU(PPC64)) >+#define WEBCORE_NAVIGATOR_PLATFORM "MacPPC"_s >+#elif OS(MAC_OS_X) && (CPU(X86) || CPU(X86_64)) >+#define WEBCORE_NAVIGATOR_PLATFORM "MacIntel"_s >+#elif OS(WINDOWS) >+#define WEBCORE_NAVIGATOR_PLATFORM "Win32"_s >+#else >+#define WEBCORE_NAVIGATOR_PLATFORM emptyString() >+#endif >+#endif // ifndef WEBCORE_NAVIGATOR_PLATFORM >+ > namespace WebCore { > using namespace WTF; > >@@ -95,6 +117,29 @@ const String& Navigator::userAgent() const > m_userAgent = frame->loader().userAgent(frame->document()->url()); > return m_userAgent; > } >+ >+const String& Navigator::platform() const >+{ >+#if OS(LINUX) >+ static NeverDestroyed<String> defaultPlatform = WEBCORE_NAVIGATOR_PLATFORM; >+ if (!defaultPlatform.isEmpty()) >+ return defaultPlatform; >+ struct utsname osname; >+ static NeverDestroyed<String> platformName(uname(&osname) >= 0 ? String(osname.sysname) + " "_str + String(osname.machine) : emptyString()); >+ return platformName; >+#else >+ auto* frame = this->frame(); >+ if (!frame || !frame->page()) >+ return m_platform; >+ >+ if (m_platform.isNull()) >+ m_platform = frame->loader().navigatorPlatform(); >+ >+ if (m_platform.isNull()) >+ m_platform = WEBCORE_NAVIGATOR_PLATFORM; >+ return m_platform; >+#endif >+} > > void Navigator::userAgentChanged() > { >diff --git a/Source/WebCore/page/Navigator.h b/Source/WebCore/page/Navigator.h >index eb3a058b6d26af85d8969697f28db54ec13bc37a..2a42a199f9e995aff449e40236221b2b0755271a 100644 >--- a/Source/WebCore/page/Navigator.h >+++ b/Source/WebCore/page/Navigator.h >@@ -42,6 +42,7 @@ public: > bool cookieEnabled() const; > bool javaEnabled() const; > const String& userAgent() const final; >+ const String& platform() const final; > void userAgentChanged(); > bool onLine() const final; > void share(ScriptExecutionContext&, ShareData, Ref<DeferredPromise>&&); >@@ -58,6 +59,7 @@ private: > mutable RefPtr<DOMPluginArray> m_plugins; > mutable RefPtr<DOMMimeTypeArray> m_mimeTypes; > mutable String m_userAgent; >+ mutable String m_platform; > }; > > } >diff --git a/Source/WebCore/page/NavigatorBase.cpp b/Source/WebCore/page/NavigatorBase.cpp >index 349552c0a6873575b28cd96d622dfe054f09d6ab..b021baa047abe3b8f10c274991a6625259ebf6fd 100644 >--- a/Source/WebCore/page/NavigatorBase.cpp >+++ b/Source/WebCore/page/NavigatorBase.cpp >@@ -35,29 +35,6 @@ > #include <wtf/NumberOfCores.h> > #include <wtf/text/WTFString.h> > >-#if OS(LINUX) >-#include "sys/utsname.h" >-#include <wtf/StdLibExtras.h> >-#endif >- >-#if PLATFORM(IOS_FAMILY) >-#include "Device.h" >-#endif >- >-#ifndef WEBCORE_NAVIGATOR_PLATFORM >-#if PLATFORM(IOS_FAMILY) >-#define WEBCORE_NAVIGATOR_PLATFORM deviceName() >-#elif OS(MAC_OS_X) && (CPU(PPC) || CPU(PPC64)) >-#define WEBCORE_NAVIGATOR_PLATFORM "MacPPC"_s >-#elif OS(MAC_OS_X) && (CPU(X86) || CPU(X86_64)) >-#define WEBCORE_NAVIGATOR_PLATFORM "MacIntel"_s >-#elif OS(WINDOWS) >-#define WEBCORE_NAVIGATOR_PLATFORM "Win32"_s >-#else >-#define WEBCORE_NAVIGATOR_PLATFORM emptyString() >-#endif >-#endif // ifndef WEBCORE_NAVIGATOR_PLATFORM >- > #ifndef WEBCORE_NAVIGATOR_PRODUCT > #define WEBCORE_NAVIGATOR_PRODUCT "Gecko"_s > #endif // ifndef WEBCORE_NAVIGATOR_PRODUCT >@@ -100,19 +77,6 @@ String NavigatorBase::appVersion() const > return agent.substring(agent.find('/') + 1); > } > >-String NavigatorBase::platform() >-{ >-#if OS(LINUX) >- if (!String(WEBCORE_NAVIGATOR_PLATFORM).isEmpty()) >- return WEBCORE_NAVIGATOR_PLATFORM; >- struct utsname osname; >- static NeverDestroyed<String> platformName(uname(&osname) >= 0 ? String(osname.sysname) + " "_str + String(osname.machine) : emptyString()); >- return platformName; >-#else >- return WEBCORE_NAVIGATOR_PLATFORM; >-#endif >-} >- > String NavigatorBase::appCodeName() > { > return "Mozilla"_s; >diff --git a/Source/WebCore/page/NavigatorBase.h b/Source/WebCore/page/NavigatorBase.h >index d42b39353f22bd1c1c98e56f318bb0a733e79d4b..59a1a8eb575b58e88f0b1a201466102371d8a0bd 100644 >--- a/Source/WebCore/page/NavigatorBase.h >+++ b/Source/WebCore/page/NavigatorBase.h >@@ -43,7 +43,7 @@ public: > static String appName(); > String appVersion() const; > virtual const String& userAgent() const = 0; >- static String platform(); >+ virtual const String& platform() const = 0; > > static String appCodeName(); > static String product(); >diff --git a/Source/WebCore/page/WorkerNavigator.cpp b/Source/WebCore/page/WorkerNavigator.cpp >index 55de004b00044dd3dad3452773480cf8ae1ae457..293caa55a70c7db7d34ec77b8f390c8b4a8c353d 100644 >--- a/Source/WebCore/page/WorkerNavigator.cpp >+++ b/Source/WebCore/page/WorkerNavigator.cpp >@@ -29,10 +29,11 @@ > > namespace WebCore { > >-WorkerNavigator::WorkerNavigator(ScriptExecutionContext& context, const String& userAgent, bool isOnline) >+WorkerNavigator::WorkerNavigator(ScriptExecutionContext& context, const String& userAgent, bool isOnline, const String& navigatorPlatform) > : NavigatorBase(&context) > , m_userAgent(userAgent) > , m_isOnline(isOnline) >+ , m_navigatorPlatform(navigatorPlatform) > { > } > >@@ -40,6 +41,12 @@ const String& WorkerNavigator::userAgent() const > { > return m_userAgent; > } >+ >+const String& WorkerNavigator::platform() const >+{ >+ return m_navigatorPlatform; >+} >+ > > bool WorkerNavigator::onLine() const > { >diff --git a/Source/WebCore/page/WorkerNavigator.h b/Source/WebCore/page/WorkerNavigator.h >index 45ecf66c7d20c82bd52cf55d1fb94a8c32b4b450..704889345776152abcf0236d3b8d224875c785f7 100644 >--- a/Source/WebCore/page/WorkerNavigator.h >+++ b/Source/WebCore/page/WorkerNavigator.h >@@ -33,17 +33,19 @@ namespace WebCore { > > class WorkerNavigator final : public NavigatorBase, public Supplementable<WorkerNavigator> { > public: >- static Ref<WorkerNavigator> create(ScriptExecutionContext& context, const String& userAgent, bool isOnline) { return adoptRef(*new WorkerNavigator(context, userAgent, isOnline)); } >+ static Ref<WorkerNavigator> create(ScriptExecutionContext& context, const String& userAgent, bool isOnline, const String& navigatorPlatform) { return adoptRef(*new WorkerNavigator(context, userAgent, isOnline, navigatorPlatform)); } > > const String& userAgent() const final; >+ const String& platform() const final; > bool onLine() const final; > void setIsOnline(bool isOnline) { m_isOnline = isOnline; } > > private: >- explicit WorkerNavigator(ScriptExecutionContext&, const String&, bool isOnline); >+ explicit WorkerNavigator(ScriptExecutionContext&, const String&, bool isOnline, const String&); > > String m_userAgent; > bool m_isOnline; >+ String m_navigatorPlatform; > }; > > } // namespace WebCore >diff --git a/Source/WebCore/workers/DedicatedWorkerGlobalScope.cpp b/Source/WebCore/workers/DedicatedWorkerGlobalScope.cpp >index db7d7770c445c8dfa6bf0225cb8094cd001e0b88..5dc852bb33c688475e3109754e7f0e22aa3fc13b 100644 >--- a/Source/WebCore/workers/DedicatedWorkerGlobalScope.cpp >+++ b/Source/WebCore/workers/DedicatedWorkerGlobalScope.cpp >@@ -41,16 +41,16 @@ > > namespace WebCore { > >-Ref<DedicatedWorkerGlobalScope> DedicatedWorkerGlobalScope::create(const URL& url, Ref<SecurityOrigin>&& origin, const String& name, const String& identifier, const String& userAgent, bool isOnline, DedicatedWorkerThread& thread, const ContentSecurityPolicyResponseHeaders& contentSecurityPolicyResponseHeaders, bool shouldBypassMainWorldContentSecurityPolicy, Ref<SecurityOrigin>&& topOrigin, MonotonicTime timeOrigin, IDBClient::IDBConnectionProxy* connectionProxy, SocketProvider* socketProvider, PAL::SessionID sessionID) >+Ref<DedicatedWorkerGlobalScope> DedicatedWorkerGlobalScope::create(const URL& url, Ref<SecurityOrigin>&& origin, const String& name, const String& identifier, const String& userAgent, bool isOnline, DedicatedWorkerThread& thread, const ContentSecurityPolicyResponseHeaders& contentSecurityPolicyResponseHeaders, bool shouldBypassMainWorldContentSecurityPolicy, Ref<SecurityOrigin>&& topOrigin, MonotonicTime timeOrigin, IDBClient::IDBConnectionProxy* connectionProxy, SocketProvider* socketProvider, PAL::SessionID sessionID, const String& navigatorPlatform) > { >- auto context = adoptRef(*new DedicatedWorkerGlobalScope(url, WTFMove(origin), name, identifier, userAgent, isOnline, thread, shouldBypassMainWorldContentSecurityPolicy, WTFMove(topOrigin), timeOrigin, connectionProxy, socketProvider, sessionID)); >+ auto context = adoptRef(*new DedicatedWorkerGlobalScope(url, WTFMove(origin), name, identifier, userAgent, isOnline, thread, shouldBypassMainWorldContentSecurityPolicy, WTFMove(topOrigin), timeOrigin, connectionProxy, socketProvider, sessionID, navigatorPlatform)); > if (!shouldBypassMainWorldContentSecurityPolicy) > context->applyContentSecurityPolicyResponseHeaders(contentSecurityPolicyResponseHeaders); > return context; > } > >-DedicatedWorkerGlobalScope::DedicatedWorkerGlobalScope(const URL& url, Ref<SecurityOrigin>&& origin, const String& name, const String& identifier, const String& userAgent, bool isOnline, DedicatedWorkerThread& thread, bool shouldBypassMainWorldContentSecurityPolicy, Ref<SecurityOrigin>&& topOrigin, MonotonicTime timeOrigin, IDBClient::IDBConnectionProxy* connectionProxy, SocketProvider* socketProvider, PAL::SessionID sessionID) >- : WorkerGlobalScope(url, WTFMove(origin), identifier, userAgent, isOnline, thread, shouldBypassMainWorldContentSecurityPolicy, WTFMove(topOrigin), timeOrigin, connectionProxy, socketProvider, sessionID) >+DedicatedWorkerGlobalScope::DedicatedWorkerGlobalScope(const URL& url, Ref<SecurityOrigin>&& origin, const String& name, const String& identifier, const String& userAgent, bool isOnline, DedicatedWorkerThread& thread, bool shouldBypassMainWorldContentSecurityPolicy, Ref<SecurityOrigin>&& topOrigin, MonotonicTime timeOrigin, IDBClient::IDBConnectionProxy* connectionProxy, SocketProvider* socketProvider, PAL::SessionID sessionID, const String& navigatorPlatform) >+ : WorkerGlobalScope(url, WTFMove(origin), identifier, userAgent, isOnline, thread, shouldBypassMainWorldContentSecurityPolicy, WTFMove(topOrigin), timeOrigin, connectionProxy, socketProvider, sessionID, navigatorPlatform) > , m_name(name) > { > } >diff --git a/Source/WebCore/workers/DedicatedWorkerGlobalScope.h b/Source/WebCore/workers/DedicatedWorkerGlobalScope.h >index 55a99e57644c5d7848343546be007b8f307c5960..1d10e7ffaed6986173350fa22379cfc42c00baa3 100644 >--- a/Source/WebCore/workers/DedicatedWorkerGlobalScope.h >+++ b/Source/WebCore/workers/DedicatedWorkerGlobalScope.h >@@ -48,7 +48,7 @@ class SerializedScriptValue; > > class DedicatedWorkerGlobalScope final : public WorkerGlobalScope { > public: >- static Ref<DedicatedWorkerGlobalScope> create(const URL&, Ref<SecurityOrigin>&&, const String& name, const String& identifier, const String& userAgent, bool isOnline, DedicatedWorkerThread&, const ContentSecurityPolicyResponseHeaders&, bool shouldBypassMainWorldContentSecurityPolicy, Ref<SecurityOrigin>&& topOrigin, MonotonicTime timeOrigin, IDBClient::IDBConnectionProxy*, SocketProvider*, PAL::SessionID); >+ static Ref<DedicatedWorkerGlobalScope> create(const URL&, Ref<SecurityOrigin>&&, const String& name, const String& identifier, const String& userAgent, bool isOnline, DedicatedWorkerThread&, const ContentSecurityPolicyResponseHeaders&, bool shouldBypassMainWorldContentSecurityPolicy, Ref<SecurityOrigin>&& topOrigin, MonotonicTime timeOrigin, IDBClient::IDBConnectionProxy*, SocketProvider*, PAL::SessionID, const String& navigatorPlatform); > virtual ~DedicatedWorkerGlobalScope(); > > const String& name() const { return m_name; } >@@ -60,7 +60,7 @@ public: > private: > using Base = WorkerGlobalScope; > >- DedicatedWorkerGlobalScope(const URL&, Ref<SecurityOrigin>&&, const String& name, const String& identifier, const String& userAgent, bool isOnline, DedicatedWorkerThread&, bool shouldBypassMainWorldContentSecurityPolicy, Ref<SecurityOrigin>&& topOrigin, MonotonicTime timeOrigin, IDBClient::IDBConnectionProxy*, SocketProvider*, PAL::SessionID); >+ DedicatedWorkerGlobalScope(const URL&, Ref<SecurityOrigin>&&, const String& name, const String& identifier, const String& userAgent, bool isOnline, DedicatedWorkerThread&, bool shouldBypassMainWorldContentSecurityPolicy, Ref<SecurityOrigin>&& topOrigin, MonotonicTime timeOrigin, IDBClient::IDBConnectionProxy*, SocketProvider*, PAL::SessionID, const String& navigatorPlatform); > > bool isDedicatedWorkerGlobalScope() const final { return true; } > ExceptionOr<void> importScripts(const Vector<String>& urls) final; >diff --git a/Source/WebCore/workers/DedicatedWorkerThread.cpp b/Source/WebCore/workers/DedicatedWorkerThread.cpp >index 73a3da4baaae4981f7db75b3a1598f8a8d4dbee8..4513ce1f353831537ae3083e3fea3a4fcb5c8c6e 100644 >--- a/Source/WebCore/workers/DedicatedWorkerThread.cpp >+++ b/Source/WebCore/workers/DedicatedWorkerThread.cpp >@@ -38,17 +38,17 @@ > > namespace WebCore { > >-DedicatedWorkerThread::DedicatedWorkerThread(const URL& url, const String& name, const String& identifier, const String& userAgent, bool isOnline, const String& sourceCode, WorkerLoaderProxy& workerLoaderProxy, WorkerDebuggerProxy& workerDebuggerProxy, WorkerObjectProxy& workerObjectProxy, WorkerThreadStartMode startMode, const ContentSecurityPolicyResponseHeaders& contentSecurityPolicyResponseHeaders, bool shouldBypassMainWorldContentSecurityPolicy, const SecurityOrigin& topOrigin, MonotonicTime timeOrigin, IDBClient::IDBConnectionProxy* connectionProxy, SocketProvider* socketProvider, JSC::RuntimeFlags runtimeFlags, PAL::SessionID sessionID) >- : WorkerThread(url, name, identifier, userAgent, isOnline, sourceCode, workerLoaderProxy, workerDebuggerProxy, workerObjectProxy, startMode, contentSecurityPolicyResponseHeaders, shouldBypassMainWorldContentSecurityPolicy, topOrigin, timeOrigin, connectionProxy, socketProvider, runtimeFlags, sessionID) >+DedicatedWorkerThread::DedicatedWorkerThread(const URL& url, const String& name, const String& identifier, const String& userAgent, bool isOnline, const String& sourceCode, WorkerLoaderProxy& workerLoaderProxy, WorkerDebuggerProxy& workerDebuggerProxy, WorkerObjectProxy& workerObjectProxy, WorkerThreadStartMode startMode, const ContentSecurityPolicyResponseHeaders& contentSecurityPolicyResponseHeaders, bool shouldBypassMainWorldContentSecurityPolicy, const SecurityOrigin& topOrigin, MonotonicTime timeOrigin, IDBClient::IDBConnectionProxy* connectionProxy, SocketProvider* socketProvider, JSC::RuntimeFlags runtimeFlags, PAL::SessionID sessionID, const String& navigatorPlatform) >+ : WorkerThread(url, name, identifier, userAgent, isOnline, sourceCode, workerLoaderProxy, workerDebuggerProxy, workerObjectProxy, startMode, contentSecurityPolicyResponseHeaders, shouldBypassMainWorldContentSecurityPolicy, topOrigin, timeOrigin, connectionProxy, socketProvider, runtimeFlags, sessionID, navigatorPlatform) > , m_workerObjectProxy(workerObjectProxy) > { > } > > DedicatedWorkerThread::~DedicatedWorkerThread() = default; > >-Ref<WorkerGlobalScope> DedicatedWorkerThread::createWorkerGlobalScope(const URL& url, Ref<SecurityOrigin>&& origin, const String& name, const String& identifier, const String& userAgent, bool isOnline, const ContentSecurityPolicyResponseHeaders& contentSecurityPolicyResponseHeaders, bool shouldBypassMainWorldContentSecurityPolicy, Ref<SecurityOrigin>&& topOrigin, MonotonicTime timeOrigin, PAL::SessionID sessionID) >+Ref<WorkerGlobalScope> DedicatedWorkerThread::createWorkerGlobalScope(const URL& url, Ref<SecurityOrigin>&& origin, const String& name, const String& identifier, const String& userAgent, bool isOnline, const ContentSecurityPolicyResponseHeaders& contentSecurityPolicyResponseHeaders, bool shouldBypassMainWorldContentSecurityPolicy, Ref<SecurityOrigin>&& topOrigin, MonotonicTime timeOrigin, PAL::SessionID sessionID, const String& navigatorPlatform) > { >- return DedicatedWorkerGlobalScope::create(url, WTFMove(origin), name, identifier, userAgent, isOnline, *this, contentSecurityPolicyResponseHeaders, shouldBypassMainWorldContentSecurityPolicy, WTFMove(topOrigin), timeOrigin, idbConnectionProxy(), socketProvider(), sessionID); >+ return DedicatedWorkerGlobalScope::create(url, WTFMove(origin), name, identifier, userAgent, isOnline, *this, contentSecurityPolicyResponseHeaders, shouldBypassMainWorldContentSecurityPolicy, WTFMove(topOrigin), timeOrigin, idbConnectionProxy(), socketProvider(), sessionID, navigatorPlatform); > } > > void DedicatedWorkerThread::runEventLoop() >diff --git a/Source/WebCore/workers/DedicatedWorkerThread.h b/Source/WebCore/workers/DedicatedWorkerThread.h >index f1c9624b18ac1893298846339616352cac0c7dd7..6001cb3984aef0beddd548ac934d7a7e1c7bb167 100644 >--- a/Source/WebCore/workers/DedicatedWorkerThread.h >+++ b/Source/WebCore/workers/DedicatedWorkerThread.h >@@ -49,11 +49,11 @@ public: > WorkerObjectProxy& workerObjectProxy() const { return m_workerObjectProxy; } > > protected: >- Ref<WorkerGlobalScope> createWorkerGlobalScope(const URL&, Ref<SecurityOrigin>&&, const String& name, const String& identifier, const String& userAgent, bool isOnline, const ContentSecurityPolicyResponseHeaders&, bool shouldBypassMainWorldContentSecurityPolicy, Ref<SecurityOrigin>&& topOrigin, MonotonicTime timeOrigin, PAL::SessionID) override; >+ Ref<WorkerGlobalScope> createWorkerGlobalScope(const URL&, Ref<SecurityOrigin>&&, const String& name, const String& identifier, const String& userAgent, bool isOnline, const ContentSecurityPolicyResponseHeaders&, bool shouldBypassMainWorldContentSecurityPolicy, Ref<SecurityOrigin>&& topOrigin, MonotonicTime timeOrigin, PAL::SessionID, const String& navigatorPlatform) override; > void runEventLoop() override; > > private: >- DedicatedWorkerThread(const URL&, const String& name, const String& identifier, const String& userAgent, bool isOnline, const String& sourceCode, WorkerLoaderProxy&, WorkerDebuggerProxy&, WorkerObjectProxy&, WorkerThreadStartMode, const ContentSecurityPolicyResponseHeaders&, bool shouldBypassMainWorldContentSecurityPolicy, const SecurityOrigin& topOrigin, MonotonicTime timeOrigin, IDBClient::IDBConnectionProxy*, SocketProvider*, JSC::RuntimeFlags, PAL::SessionID); >+ DedicatedWorkerThread(const URL&, const String& name, const String& identifier, const String& userAgent, bool isOnline, const String& sourceCode, WorkerLoaderProxy&, WorkerDebuggerProxy&, WorkerObjectProxy&, WorkerThreadStartMode, const ContentSecurityPolicyResponseHeaders&, bool shouldBypassMainWorldContentSecurityPolicy, const SecurityOrigin& topOrigin, MonotonicTime timeOrigin, IDBClient::IDBConnectionProxy*, SocketProvider*, JSC::RuntimeFlags, PAL::SessionID, const String& navigatorPlatform); > > WorkerObjectProxy& m_workerObjectProxy; > }; >diff --git a/Source/WebCore/workers/Worker.cpp b/Source/WebCore/workers/Worker.cpp >index 49474c7042d3f0f9a4ba6fe366a30a383840bd80..6fa2c88dfd0ee6c4eafd1e25ecf80ad70a86598a 100644 >--- a/Source/WebCore/workers/Worker.cpp >+++ b/Source/WebCore/workers/Worker.cpp >@@ -186,7 +186,7 @@ void Worker::notifyFinished() > else { > bool isOnline = platformStrategies()->loaderStrategy()->isOnLine(); > const ContentSecurityPolicyResponseHeaders& contentSecurityPolicyResponseHeaders = m_contentSecurityPolicyResponseHeaders ? m_contentSecurityPolicyResponseHeaders.value() : scriptExecutionContext()->contentSecurityPolicy()->responseHeaders(); >- m_contextProxy.startWorkerGlobalScope(m_scriptLoader->url(), m_name, scriptExecutionContext()->userAgent(m_scriptLoader->url()), isOnline, m_scriptLoader->script(), contentSecurityPolicyResponseHeaders, m_shouldBypassMainWorldContentSecurityPolicy, m_workerCreationTime, m_runtimeFlags, sessionID); >+ m_contextProxy.startWorkerGlobalScope(m_scriptLoader->url(), m_name, scriptExecutionContext()->userAgent(m_scriptLoader->url()), isOnline, m_scriptLoader->script(), contentSecurityPolicyResponseHeaders, m_shouldBypassMainWorldContentSecurityPolicy, m_workerCreationTime, m_runtimeFlags, sessionID, scriptExecutionContext()->navigatorPlatform()); > InspectorInstrumentation::scriptImported(*scriptExecutionContext(), m_scriptLoader->identifier(), m_scriptLoader->script()); > } > m_scriptLoader = nullptr; >diff --git a/Source/WebCore/workers/WorkerGlobalScope.cpp b/Source/WebCore/workers/WorkerGlobalScope.cpp >index 0e2a5091255c6d67ec88a2f657d439edb4d2b3e0..99d8cffbbfad23a70a9fc87b985fd1eceb0d818d 100644 >--- a/Source/WebCore/workers/WorkerGlobalScope.cpp >+++ b/Source/WebCore/workers/WorkerGlobalScope.cpp >@@ -54,7 +54,7 @@ > namespace WebCore { > using namespace Inspector; > >-WorkerGlobalScope::WorkerGlobalScope(const URL& url, Ref<SecurityOrigin>&& origin, const String& identifier, const String& userAgent, bool isOnline, WorkerThread& thread, bool shouldBypassMainWorldContentSecurityPolicy, Ref<SecurityOrigin>&& topOrigin, MonotonicTime timeOrigin, IDBClient::IDBConnectionProxy* connectionProxy, SocketProvider* socketProvider, PAL::SessionID sessionID) >+WorkerGlobalScope::WorkerGlobalScope(const URL& url, Ref<SecurityOrigin>&& origin, const String& identifier, const String& userAgent, bool isOnline, WorkerThread& thread, bool shouldBypassMainWorldContentSecurityPolicy, Ref<SecurityOrigin>&& topOrigin, MonotonicTime timeOrigin, IDBClient::IDBConnectionProxy* connectionProxy, SocketProvider* socketProvider, PAL::SessionID sessionID, const String& navigatorPlatform) > : m_url(url) > , m_identifier(identifier) > , m_userAgent(userAgent) >@@ -72,6 +72,7 @@ WorkerGlobalScope::WorkerGlobalScope(const URL& url, Ref<SecurityOrigin>&& origi > , m_socketProvider(socketProvider) > , m_performance(Performance::create(this, timeOrigin)) > , m_sessionID(sessionID) >+ , m_navigatorPlatform(navigatorPlatform) > { > #if !ENABLE(INDEXED_DATABASE) > UNUSED_PARAM(connectionProxy); >@@ -155,6 +156,11 @@ String WorkerGlobalScope::userAgent(const URL&) const > { > return m_userAgent; > } >+ >+String WorkerGlobalScope::navigatorPlatform() const >+{ >+ return m_navigatorPlatform; >+} > > void WorkerGlobalScope::disableEval(const String& errorMessage) > { >@@ -219,7 +225,7 @@ void WorkerGlobalScope::close() > WorkerNavigator& WorkerGlobalScope::navigator() > { > if (!m_navigator) >- m_navigator = WorkerNavigator::create(*this, m_userAgent, m_isOnline); >+ m_navigator = WorkerNavigator::create(*this, m_userAgent, m_isOnline, m_navigatorPlatform); > return *m_navigator; > } > >diff --git a/Source/WebCore/workers/WorkerGlobalScope.h b/Source/WebCore/workers/WorkerGlobalScope.h >index 8395629d0799591d6b0816d985f51e10bea659e8..837285b83b9eea098aea6fbd8e9f5ec99a2bc504 100644 >--- a/Source/WebCore/workers/WorkerGlobalScope.h >+++ b/Source/WebCore/workers/WorkerGlobalScope.h >@@ -126,7 +126,7 @@ public: > unsigned long createUniqueIdentifier() { return m_uniqueIdentifier++; } > > protected: >- WorkerGlobalScope(const URL&, Ref<SecurityOrigin>&&, const String& identifier, const String& userAgent, bool isOnline, WorkerThread&, bool shouldBypassMainWorldContentSecurityPolicy, Ref<SecurityOrigin>&& topOrigin, MonotonicTime timeOrigin, IDBClient::IDBConnectionProxy*, SocketProvider*, PAL::SessionID); >+ WorkerGlobalScope(const URL&, Ref<SecurityOrigin>&&, const String& identifier, const String& userAgent, bool isOnline, WorkerThread&, bool shouldBypassMainWorldContentSecurityPolicy, Ref<SecurityOrigin>&& topOrigin, MonotonicTime timeOrigin, IDBClient::IDBConnectionProxy*, SocketProvider*, PAL::SessionID, const String& navigatorPlatform); > > void applyContentSecurityPolicyResponseHeaders(const ContentSecurityPolicyResponseHeaders&); > >@@ -150,6 +150,7 @@ private: > URL completeURL(const String&) const final; > PAL::SessionID sessionID() const final { return m_sessionID; } > String userAgent(const URL&) const final; >+ String navigatorPlatform() const final; > void disableEval(const String& errorMessage) final; > void disableWebAssembly(const String& errorMessage) final; > EventTarget* errorEventTarget() final; >@@ -207,6 +208,9 @@ private: > mutable RefPtr<Crypto> m_crypto; > > PAL::SessionID m_sessionID; >+ >+ String m_navigatorPlatform; >+ > RefPtr<WorkerCacheStorageConnection> m_cacheStorageConnection; > > unsigned long m_uniqueIdentifier { 1 }; >diff --git a/Source/WebCore/workers/WorkerGlobalScopeProxy.h b/Source/WebCore/workers/WorkerGlobalScopeProxy.h >index 8585a5bff93b04665de5321ed32b92ffa976a171..c2c009e044a8fc6413dfb28519756c5567ca0158 100644 >--- a/Source/WebCore/workers/WorkerGlobalScopeProxy.h >+++ b/Source/WebCore/workers/WorkerGlobalScopeProxy.h >@@ -49,7 +49,7 @@ class WorkerGlobalScopeProxy { > public: > static WorkerGlobalScopeProxy& create(Worker&); > >- virtual void startWorkerGlobalScope(const URL& scriptURL, const String& name, const String& userAgent, bool isOnline, const String& sourceCode, const ContentSecurityPolicyResponseHeaders&, bool shouldBypassMainWorldContentSecurityPolicy, MonotonicTime timeOrigin, JSC::RuntimeFlags, PAL::SessionID) = 0; >+ virtual void startWorkerGlobalScope(const URL& scriptURL, const String& name, const String& userAgent, bool isOnline, const String& sourceCode, const ContentSecurityPolicyResponseHeaders&, bool shouldBypassMainWorldContentSecurityPolicy, MonotonicTime timeOrigin, JSC::RuntimeFlags, PAL::SessionID, const String& navigatorPlatform) = 0; > virtual void terminateWorkerGlobalScope() = 0; > virtual void postMessageToWorkerGlobalScope(MessageWithMessagePorts&&) = 0; > virtual bool hasPendingActivity() const = 0; >diff --git a/Source/WebCore/workers/WorkerMessagingProxy.cpp b/Source/WebCore/workers/WorkerMessagingProxy.cpp >index a75c0156c59e38dd999d6cec1ddeede23be187b3..893a808285b688a89629e64c696c7e579d99ba70 100644 >--- a/Source/WebCore/workers/WorkerMessagingProxy.cpp >+++ b/Source/WebCore/workers/WorkerMessagingProxy.cpp >@@ -72,7 +72,7 @@ WorkerMessagingProxy::~WorkerMessagingProxy() > || (is<WorkerGlobalScope>(*m_scriptExecutionContext) && downcast<WorkerGlobalScope>(*m_scriptExecutionContext).thread().thread() == &Thread::current())); > } > >-void WorkerMessagingProxy::startWorkerGlobalScope(const URL& scriptURL, const String& name, const String& userAgent, bool isOnline, const String& sourceCode, const ContentSecurityPolicyResponseHeaders& contentSecurityPolicyResponseHeaders, bool shouldBypassMainWorldContentSecurityPolicy, MonotonicTime timeOrigin, JSC::RuntimeFlags runtimeFlags, PAL::SessionID sessionID) >+void WorkerMessagingProxy::startWorkerGlobalScope(const URL& scriptURL, const String& name, const String& userAgent, bool isOnline, const String& sourceCode, const ContentSecurityPolicyResponseHeaders& contentSecurityPolicyResponseHeaders, bool shouldBypassMainWorldContentSecurityPolicy, MonotonicTime timeOrigin, JSC::RuntimeFlags runtimeFlags, PAL::SessionID sessionID, const String& navigatorPlatform) > { > // FIXME: This need to be revisited when we support nested worker one day > ASSERT(m_scriptExecutionContext); >@@ -88,7 +88,7 @@ void WorkerMessagingProxy::startWorkerGlobalScope(const URL& scriptURL, const St > > SocketProvider* socketProvider = document.socketProvider(); > >- auto thread = DedicatedWorkerThread::create(scriptURL, name, identifier, userAgent, isOnline, sourceCode, *this, *this, *this, startMode, contentSecurityPolicyResponseHeaders, shouldBypassMainWorldContentSecurityPolicy, document.topOrigin(), timeOrigin, proxy, socketProvider, runtimeFlags, sessionID); >+ auto thread = DedicatedWorkerThread::create(scriptURL, name, identifier, userAgent, isOnline, sourceCode, *this, *this, *this, startMode, contentSecurityPolicyResponseHeaders, shouldBypassMainWorldContentSecurityPolicy, document.topOrigin(), timeOrigin, proxy, socketProvider, runtimeFlags, sessionID, navigatorPlatform); > > workerThreadCreated(thread.get()); > thread->start(nullptr); >diff --git a/Source/WebCore/workers/WorkerMessagingProxy.h b/Source/WebCore/workers/WorkerMessagingProxy.h >index ecedb483956c121bf86d05f22baba43814bcd306..fdef2fa52730a71f73d78e7930c6fb68145d0e63 100644 >--- a/Source/WebCore/workers/WorkerMessagingProxy.h >+++ b/Source/WebCore/workers/WorkerMessagingProxy.h >@@ -46,7 +46,7 @@ public: > private: > // Implementations of WorkerGlobalScopeProxy. > // (Only use these functions in the worker object thread.) >- void startWorkerGlobalScope(const URL& scriptURL, const String& name, const String& userAgent, bool isOnline, const String& sourceCode, const ContentSecurityPolicyResponseHeaders&, bool shouldBypassMainWorldContentSecurityPolicy, MonotonicTime timeOrigin, JSC::RuntimeFlags, PAL::SessionID) final; >+ void startWorkerGlobalScope(const URL& scriptURL, const String& name, const String& userAgent, bool isOnline, const String& sourceCode, const ContentSecurityPolicyResponseHeaders&, bool shouldBypassMainWorldContentSecurityPolicy, MonotonicTime timeOrigin, JSC::RuntimeFlags, PAL::SessionID, const String& navigatorPlatform) final; > void terminateWorkerGlobalScope() final; > void postMessageToWorkerGlobalScope(MessageWithMessagePorts&&) final; > bool hasPendingActivity() const final; >diff --git a/Source/WebCore/workers/WorkerThread.cpp b/Source/WebCore/workers/WorkerThread.cpp >index 9795543e1bfe588049f36c1f95712a1f02c36bc5..fa4f794ef01bc3f418c5ee7e85f87d125531c930 100644 >--- a/Source/WebCore/workers/WorkerThread.cpp >+++ b/Source/WebCore/workers/WorkerThread.cpp >@@ -72,7 +72,7 @@ unsigned WorkerThread::workerThreadCount() > struct WorkerThreadStartupData { > WTF_MAKE_NONCOPYABLE(WorkerThreadStartupData); WTF_MAKE_FAST_ALLOCATED; > public: >- WorkerThreadStartupData(const URL& scriptURL, const String& name, const String& identifier, const String& userAgent, bool isOnline, const String& sourceCode, WorkerThreadStartMode, const ContentSecurityPolicyResponseHeaders&, bool shouldBypassMainWorldContentSecurityPolicy, const SecurityOrigin& topOrigin, MonotonicTime timeOrigin, PAL::SessionID); >+ WorkerThreadStartupData(const URL& scriptURL, const String& name, const String& identifier, const String& userAgent, bool isOnline, const String& sourceCode, WorkerThreadStartMode, const ContentSecurityPolicyResponseHeaders&, bool shouldBypassMainWorldContentSecurityPolicy, const SecurityOrigin& topOrigin, MonotonicTime timeOrigin, PAL::SessionID, const String& navigatorPlatform); > > URL m_scriptURL; > Ref<SecurityOrigin> m_origin; >@@ -87,9 +87,10 @@ public: > Ref<SecurityOrigin> m_topOrigin; > MonotonicTime m_timeOrigin; > PAL::SessionID m_sessionID; >+ String m_navigatorPlatform; > }; > >-WorkerThreadStartupData::WorkerThreadStartupData(const URL& scriptURL, const String& name, const String& identifier, const String& userAgent, bool isOnline, const String& sourceCode, WorkerThreadStartMode startMode, const ContentSecurityPolicyResponseHeaders& contentSecurityPolicyResponseHeaders, bool shouldBypassMainWorldContentSecurityPolicy, const SecurityOrigin& topOrigin, MonotonicTime timeOrigin, PAL::SessionID sessionID) >+WorkerThreadStartupData::WorkerThreadStartupData(const URL& scriptURL, const String& name, const String& identifier, const String& userAgent, bool isOnline, const String& sourceCode, WorkerThreadStartMode startMode, const ContentSecurityPolicyResponseHeaders& contentSecurityPolicyResponseHeaders, bool shouldBypassMainWorldContentSecurityPolicy, const SecurityOrigin& topOrigin, MonotonicTime timeOrigin, PAL::SessionID sessionID, const String& navigatorPlatform) > : m_scriptURL(scriptURL.isolatedCopy()) > , m_origin(SecurityOrigin::create(m_scriptURL)->isolatedCopy()) > , m_name(name.isolatedCopy()) >@@ -103,15 +104,16 @@ WorkerThreadStartupData::WorkerThreadStartupData(const URL& scriptURL, const Str > , m_topOrigin(topOrigin.isolatedCopy()) > , m_timeOrigin(timeOrigin) > , m_sessionID(sessionID.isolatedCopy()) >+ , m_navigatorPlatform(navigatorPlatform.isolatedCopy()) > { > } > >-WorkerThread::WorkerThread(const URL& scriptURL, const String& name, const String& identifier, const String& userAgent, bool isOnline, const String& sourceCode, WorkerLoaderProxy& workerLoaderProxy, WorkerDebuggerProxy& workerDebuggerProxy, WorkerReportingProxy& workerReportingProxy, WorkerThreadStartMode startMode, const ContentSecurityPolicyResponseHeaders& contentSecurityPolicyResponseHeaders, bool shouldBypassMainWorldContentSecurityPolicy, const SecurityOrigin& topOrigin, MonotonicTime timeOrigin, IDBClient::IDBConnectionProxy* connectionProxy, SocketProvider* socketProvider, JSC::RuntimeFlags runtimeFlags, PAL::SessionID sessionID) >+WorkerThread::WorkerThread(const URL& scriptURL, const String& name, const String& identifier, const String& userAgent, bool isOnline, const String& sourceCode, WorkerLoaderProxy& workerLoaderProxy, WorkerDebuggerProxy& workerDebuggerProxy, WorkerReportingProxy& workerReportingProxy, WorkerThreadStartMode startMode, const ContentSecurityPolicyResponseHeaders& contentSecurityPolicyResponseHeaders, bool shouldBypassMainWorldContentSecurityPolicy, const SecurityOrigin& topOrigin, MonotonicTime timeOrigin, IDBClient::IDBConnectionProxy* connectionProxy, SocketProvider* socketProvider, JSC::RuntimeFlags runtimeFlags, PAL::SessionID sessionID, const String& navigatorPlatform) > : m_workerLoaderProxy(workerLoaderProxy) > , m_workerDebuggerProxy(workerDebuggerProxy) > , m_workerReportingProxy(workerReportingProxy) > , m_runtimeFlags(runtimeFlags) >- , m_startupData(std::make_unique<WorkerThreadStartupData>(scriptURL, name, identifier, userAgent, isOnline, sourceCode, startMode, contentSecurityPolicyResponseHeaders, shouldBypassMainWorldContentSecurityPolicy, topOrigin, timeOrigin, sessionID)) >+ , m_startupData(std::make_unique<WorkerThreadStartupData>(scriptURL, name, identifier, userAgent, isOnline, sourceCode, startMode, contentSecurityPolicyResponseHeaders, shouldBypassMainWorldContentSecurityPolicy, topOrigin, timeOrigin, sessionID, navigatorPlatform)) > #if ENABLE(INDEXED_DATABASE) > , m_idbConnectionProxy(connectionProxy) > #endif >@@ -169,7 +171,7 @@ void WorkerThread::workerThread() > // while WorkerThread::stop() is accessing it. Note that WorkerThread::stop() can > // be called before we've finished creating the WorkerGlobalScope. > LockHolder lock(m_threadCreationAndWorkerGlobalScopeMutex); >- m_workerGlobalScope = createWorkerGlobalScope(m_startupData->m_scriptURL, WTFMove(m_startupData->m_origin), m_startupData->m_name, m_startupData->m_identifier, m_startupData->m_userAgent, m_startupData->m_isOnline, m_startupData->m_contentSecurityPolicyResponseHeaders, m_startupData->m_shouldBypassMainWorldContentSecurityPolicy, WTFMove(m_startupData->m_topOrigin), m_startupData->m_timeOrigin, m_startupData->m_sessionID); >+ m_workerGlobalScope = createWorkerGlobalScope(m_startupData->m_scriptURL, WTFMove(m_startupData->m_origin), m_startupData->m_name, m_startupData->m_identifier, m_startupData->m_userAgent, m_startupData->m_isOnline, m_startupData->m_contentSecurityPolicyResponseHeaders, m_startupData->m_shouldBypassMainWorldContentSecurityPolicy, WTFMove(m_startupData->m_topOrigin), m_startupData->m_timeOrigin, m_startupData->m_sessionID, m_startupData->m_navigatorPlatform); > > scriptController = m_workerGlobalScope->script(); > >diff --git a/Source/WebCore/workers/WorkerThread.h b/Source/WebCore/workers/WorkerThread.h >index 3dc54f6c473db3767525d1ca4103d5d6a56c968d..77576e78a69235add8a2ca57e61321e4bf4b18c6 100644 >--- a/Source/WebCore/workers/WorkerThread.h >+++ b/Source/WebCore/workers/WorkerThread.h >@@ -86,10 +86,10 @@ public: > JSC::RuntimeFlags runtimeFlags() const { return m_runtimeFlags; } > > protected: >- WorkerThread(const URL&, const String& name, const String& identifier, const String& userAgent, bool isOnline, const String& sourceCode, WorkerLoaderProxy&, WorkerDebuggerProxy&, WorkerReportingProxy&, WorkerThreadStartMode, const ContentSecurityPolicyResponseHeaders&, bool shouldBypassMainWorldContentSecurityPolicy, const SecurityOrigin& topOrigin, MonotonicTime timeOrigin, IDBClient::IDBConnectionProxy*, SocketProvider*, JSC::RuntimeFlags, PAL::SessionID); >+ WorkerThread(const URL&, const String& name, const String& identifier, const String& userAgent, bool isOnline, const String& sourceCode, WorkerLoaderProxy&, WorkerDebuggerProxy&, WorkerReportingProxy&, WorkerThreadStartMode, const ContentSecurityPolicyResponseHeaders&, bool shouldBypassMainWorldContentSecurityPolicy, const SecurityOrigin& topOrigin, MonotonicTime timeOrigin, IDBClient::IDBConnectionProxy*, SocketProvider*, JSC::RuntimeFlags, PAL::SessionID, const String& navigatorPlatform); > > // Factory method for creating a new worker context for the thread. >- virtual Ref<WorkerGlobalScope> createWorkerGlobalScope(const URL&, Ref<SecurityOrigin>&&, const String& name, const String& identifier, const String& userAgent, bool isOnline, const ContentSecurityPolicyResponseHeaders&, bool shouldBypassMainWorldContentSecurityPolicy, Ref<SecurityOrigin>&& topOrigin, MonotonicTime timeOrigin, PAL::SessionID) = 0; >+ virtual Ref<WorkerGlobalScope> createWorkerGlobalScope(const URL&, Ref<SecurityOrigin>&&, const String& name, const String& identifier, const String& userAgent, bool isOnline, const ContentSecurityPolicyResponseHeaders&, bool shouldBypassMainWorldContentSecurityPolicy, Ref<SecurityOrigin>&& topOrigin, MonotonicTime timeOrigin, PAL::SessionID, const String& navigatorPlatform) = 0; > > // Executes the event loop for the worker thread. Derived classes can override to perform actions before/after entering the event loop. > virtual void runEventLoop(); >diff --git a/Source/WebCore/workers/service/ServiceWorkerGlobalScope.cpp b/Source/WebCore/workers/service/ServiceWorkerGlobalScope.cpp >index fe429abb92e41ff4ec253301bf5f4bd34ac84bb4..7cee77920b8f5c8a91bae8496abc55c7e34da414 100644 >--- a/Source/WebCore/workers/service/ServiceWorkerGlobalScope.cpp >+++ b/Source/WebCore/workers/service/ServiceWorkerGlobalScope.cpp >@@ -38,15 +38,15 @@ > > namespace WebCore { > >-Ref<ServiceWorkerGlobalScope> ServiceWorkerGlobalScope::create(const ServiceWorkerContextData& data, const URL& url, Ref<SecurityOrigin>&& origin, const String& identifier, const String& userAgent, bool isOnline, ServiceWorkerThread& thread, const ContentSecurityPolicyResponseHeaders& contentSecurityPolicy, bool shouldBypassMainWorldContentSecurityPolicy, Ref<SecurityOrigin>&& topOrigin, MonotonicTime timeOrigin, IDBClient::IDBConnectionProxy* connectionProxy, SocketProvider* socketProvider, PAL::SessionID sessionID) >+Ref<ServiceWorkerGlobalScope> ServiceWorkerGlobalScope::create(const ServiceWorkerContextData& data, const URL& url, Ref<SecurityOrigin>&& origin, const String& identifier, const String& userAgent, bool isOnline, ServiceWorkerThread& thread, const ContentSecurityPolicyResponseHeaders& contentSecurityPolicy, bool shouldBypassMainWorldContentSecurityPolicy, Ref<SecurityOrigin>&& topOrigin, MonotonicTime timeOrigin, IDBClient::IDBConnectionProxy* connectionProxy, SocketProvider* socketProvider, PAL::SessionID sessionID, const String& navigatorPlatform) > { >- auto scope = adoptRef(*new ServiceWorkerGlobalScope { data, url, WTFMove(origin), identifier, userAgent, isOnline, thread, shouldBypassMainWorldContentSecurityPolicy, WTFMove(topOrigin), timeOrigin, connectionProxy, socketProvider, sessionID }); >+ auto scope = adoptRef(*new ServiceWorkerGlobalScope { data, url, WTFMove(origin), identifier, userAgent, isOnline, thread, shouldBypassMainWorldContentSecurityPolicy, WTFMove(topOrigin), timeOrigin, connectionProxy, socketProvider, sessionID, navigatorPlatform }); > scope->applyContentSecurityPolicyResponseHeaders(contentSecurityPolicy); > return scope; > } > >-ServiceWorkerGlobalScope::ServiceWorkerGlobalScope(const ServiceWorkerContextData& data, const URL& url, Ref<SecurityOrigin>&& origin, const String& identifier, const String& userAgent, bool isOnline, ServiceWorkerThread& thread, bool shouldBypassMainWorldContentSecurityPolicy, Ref<SecurityOrigin>&& topOrigin, MonotonicTime timeOrigin, IDBClient::IDBConnectionProxy* connectionProxy, SocketProvider* socketProvider, PAL::SessionID sessionID) >- : WorkerGlobalScope(url, WTFMove(origin), identifier, userAgent, isOnline, thread, shouldBypassMainWorldContentSecurityPolicy, WTFMove(topOrigin), timeOrigin, connectionProxy, socketProvider, sessionID) >+ServiceWorkerGlobalScope::ServiceWorkerGlobalScope(const ServiceWorkerContextData& data, const URL& url, Ref<SecurityOrigin>&& origin, const String& identifier, const String& userAgent, bool isOnline, ServiceWorkerThread& thread, bool shouldBypassMainWorldContentSecurityPolicy, Ref<SecurityOrigin>&& topOrigin, MonotonicTime timeOrigin, IDBClient::IDBConnectionProxy* connectionProxy, SocketProvider* socketProvider, PAL::SessionID sessionID, const String& navigatorPlatform) >+ : WorkerGlobalScope(url, WTFMove(origin), identifier, userAgent, isOnline, thread, shouldBypassMainWorldContentSecurityPolicy, WTFMove(topOrigin), timeOrigin, connectionProxy, socketProvider, sessionID, navigatorPlatform) > , m_contextData(crossThreadCopy(data)) > , m_registration(ServiceWorkerRegistration::getOrCreate(*this, navigator().serviceWorker(), WTFMove(m_contextData.registration))) > , m_clients(ServiceWorkerClients::create()) >diff --git a/Source/WebCore/workers/service/ServiceWorkerGlobalScope.h b/Source/WebCore/workers/service/ServiceWorkerGlobalScope.h >index 0b7f78c7a88ab2bdb7901be25bfcda4eedce8c5b..5f7a8d2c140f8ed2da4b4e572bb8eb7f2012ae96 100644 >--- a/Source/WebCore/workers/service/ServiceWorkerGlobalScope.h >+++ b/Source/WebCore/workers/service/ServiceWorkerGlobalScope.h >@@ -43,7 +43,7 @@ class ServiceWorkerThread; > > class ServiceWorkerGlobalScope final : public WorkerGlobalScope { > public: >- static Ref<ServiceWorkerGlobalScope> create(const ServiceWorkerContextData&, const URL&, Ref<SecurityOrigin>&&, const String& identifier, const String& userAgent, bool isOnline, ServiceWorkerThread&, const ContentSecurityPolicyResponseHeaders&, bool shouldBypassMainWorldContentSecurityPolicy, Ref<SecurityOrigin>&& topOrigin, MonotonicTime timeOrigin, IDBClient::IDBConnectionProxy*, SocketProvider*, PAL::SessionID); >+ static Ref<ServiceWorkerGlobalScope> create(const ServiceWorkerContextData&, const URL&, Ref<SecurityOrigin>&&, const String& identifier, const String& userAgent, bool isOnline, ServiceWorkerThread&, const ContentSecurityPolicyResponseHeaders&, bool shouldBypassMainWorldContentSecurityPolicy, Ref<SecurityOrigin>&& topOrigin, MonotonicTime timeOrigin, IDBClient::IDBConnectionProxy*, SocketProvider*, PAL::SessionID, const String& navigatorPlatform); > > ~ServiceWorkerGlobalScope(); > >@@ -68,7 +68,7 @@ public: > void setScriptResource(const URL&, ServiceWorkerContextData::ImportedScript&&); > > private: >- ServiceWorkerGlobalScope(const ServiceWorkerContextData&, const URL&, Ref<SecurityOrigin>&&, const String& identifier, const String& userAgent, bool isOnline, ServiceWorkerThread&, bool shouldBypassMainWorldContentSecurityPolicy, Ref<SecurityOrigin>&& topOrigin, MonotonicTime timeOrigin, IDBClient::IDBConnectionProxy*, SocketProvider*, PAL::SessionID); >+ ServiceWorkerGlobalScope(const ServiceWorkerContextData&, const URL&, Ref<SecurityOrigin>&&, const String& identifier, const String& userAgent, bool isOnline, ServiceWorkerThread&, bool shouldBypassMainWorldContentSecurityPolicy, Ref<SecurityOrigin>&& topOrigin, MonotonicTime timeOrigin, IDBClient::IDBConnectionProxy*, SocketProvider*, PAL::SessionID, const String& navigatorPlatform); > > bool hasPendingEvents() const { return !m_extendedEvents.isEmpty(); } > >diff --git a/Source/WebCore/workers/service/context/ServiceWorkerThread.cpp b/Source/WebCore/workers/service/context/ServiceWorkerThread.cpp >index 51760aa79678d2b7ba6f771c622206be03f5de6d..3f8341fe3028be8436d513eb68b8bf5878c32746 100644 >--- a/Source/WebCore/workers/service/context/ServiceWorkerThread.cpp >+++ b/Source/WebCore/workers/service/context/ServiceWorkerThread.cpp >@@ -71,8 +71,8 @@ private: > // FIXME: Use a valid WorkerObjectProxy > // FIXME: Use valid runtime flags > >-ServiceWorkerThread::ServiceWorkerThread(const ServiceWorkerContextData& data, PAL::SessionID, String&& userAgent, WorkerLoaderProxy& loaderProxy, WorkerDebuggerProxy& debuggerProxy, IDBClient::IDBConnectionProxy* idbConnectionProxy, SocketProvider* socketProvider) >- : WorkerThread(data.scriptURL, emptyString(), "serviceworker:" + Inspector::IdentifiersFactory::createIdentifier(), WTFMove(userAgent), platformStrategies()->loaderStrategy()->isOnLine(), data.script, loaderProxy, debuggerProxy, DummyServiceWorkerThreadProxy::shared(), WorkerThreadStartMode::Normal, data.contentSecurityPolicy, false, data.registration.key.topOrigin().securityOrigin().get(), MonotonicTime::now(), idbConnectionProxy, socketProvider, JSC::RuntimeFlags::createAllEnabled(), data.sessionID) >+ServiceWorkerThread::ServiceWorkerThread(const ServiceWorkerContextData& data, PAL::SessionID, String&& userAgent, WorkerLoaderProxy& loaderProxy, WorkerDebuggerProxy& debuggerProxy, IDBClient::IDBConnectionProxy* idbConnectionProxy, SocketProvider* socketProvider, String&& navigatorPlatform) >+ : WorkerThread(data.scriptURL, emptyString(), "serviceworker:" + Inspector::IdentifiersFactory::createIdentifier(), WTFMove(userAgent), platformStrategies()->loaderStrategy()->isOnLine(), data.script, loaderProxy, debuggerProxy, DummyServiceWorkerThreadProxy::shared(), WorkerThreadStartMode::Normal, data.contentSecurityPolicy, false, data.registration.key.topOrigin().securityOrigin().get(), MonotonicTime::now(), idbConnectionProxy, socketProvider, JSC::RuntimeFlags::createAllEnabled(), data.sessionID, navigatorPlatform) > , m_data(data.isolatedCopy()) > , m_workerObjectProxy(DummyServiceWorkerThreadProxy::shared()) > { >@@ -81,10 +81,10 @@ ServiceWorkerThread::ServiceWorkerThread(const ServiceWorkerContextData& data, P > > ServiceWorkerThread::~ServiceWorkerThread() = default; > >-Ref<WorkerGlobalScope> ServiceWorkerThread::createWorkerGlobalScope(const URL& url, Ref<SecurityOrigin>&& origin, const String& name, const String& identifier, const String& userAgent, bool isOnline, const ContentSecurityPolicyResponseHeaders& contentSecurityPolicy, bool shouldBypassMainWorldContentSecurityPolicy, Ref<SecurityOrigin>&& topOrigin, MonotonicTime timeOrigin, PAL::SessionID sessionID) >+Ref<WorkerGlobalScope> ServiceWorkerThread::createWorkerGlobalScope(const URL& url, Ref<SecurityOrigin>&& origin, const String& name, const String& identifier, const String& userAgent, bool isOnline, const ContentSecurityPolicyResponseHeaders& contentSecurityPolicy, bool shouldBypassMainWorldContentSecurityPolicy, Ref<SecurityOrigin>&& topOrigin, MonotonicTime timeOrigin, PAL::SessionID sessionID, const String& navigatorPlatform) > { > UNUSED_PARAM(name); >- return ServiceWorkerGlobalScope::create(m_data, url, WTFMove(origin), identifier, userAgent, isOnline, *this, contentSecurityPolicy, shouldBypassMainWorldContentSecurityPolicy, WTFMove(topOrigin), timeOrigin, idbConnectionProxy(), socketProvider(), sessionID); >+ return ServiceWorkerGlobalScope::create(m_data, url, WTFMove(origin), identifier, userAgent, isOnline, *this, contentSecurityPolicy, shouldBypassMainWorldContentSecurityPolicy, WTFMove(topOrigin), timeOrigin, idbConnectionProxy(), socketProvider(), sessionID, navigatorPlatform); > } > > void ServiceWorkerThread::runEventLoop() >diff --git a/Source/WebCore/workers/service/context/ServiceWorkerThread.h b/Source/WebCore/workers/service/context/ServiceWorkerThread.h >index 3492a39fe0bfbc00ef6c48a7e1cf6260ad324e92..d11ac31fc3d30fe5a0225111d10b26a8a01ea046 100644 >--- a/Source/WebCore/workers/service/context/ServiceWorkerThread.h >+++ b/Source/WebCore/workers/service/context/ServiceWorkerThread.h >@@ -66,11 +66,11 @@ public: > ServiceWorkerIdentifier identifier() const { return m_data.serviceWorkerIdentifier; } > > protected: >- Ref<WorkerGlobalScope> createWorkerGlobalScope(const URL&, Ref<SecurityOrigin>&&, const String& name, const String& identifier, const String& userAgent, bool isOnline, const ContentSecurityPolicyResponseHeaders&, bool shouldBypassMainWorldContentSecurityPolicy, Ref<SecurityOrigin>&& topOrigin, MonotonicTime timeOrigin, PAL::SessionID) final; >+ Ref<WorkerGlobalScope> createWorkerGlobalScope(const URL&, Ref<SecurityOrigin>&&, const String& name, const String& identifier, const String& userAgent, bool isOnline, const ContentSecurityPolicyResponseHeaders&, bool shouldBypassMainWorldContentSecurityPolicy, Ref<SecurityOrigin>&& topOrigin, MonotonicTime timeOrigin, PAL::SessionID, const String& navigatorPlatform) final; > void runEventLoop() override; > > private: >- WEBCORE_EXPORT ServiceWorkerThread(const ServiceWorkerContextData&, PAL::SessionID, String&& userAgent, WorkerLoaderProxy&, WorkerDebuggerProxy&, IDBClient::IDBConnectionProxy*, SocketProvider*); >+ WEBCORE_EXPORT ServiceWorkerThread(const ServiceWorkerContextData&, PAL::SessionID, String&& userAgent, WorkerLoaderProxy&, WorkerDebuggerProxy&, IDBClient::IDBConnectionProxy*, SocketProvider*, String&& navigatorPlatform); > > bool isServiceWorkerThread() const final { return true; } > >diff --git a/Source/WebCore/workers/service/context/ServiceWorkerThreadProxy.cpp b/Source/WebCore/workers/service/context/ServiceWorkerThreadProxy.cpp >index 72da981eb91d0527f6e6bc1dac0a012f0d3ac70e..d733ceba4f13facd02ab3396eccf8d8fa5b81f3d 100644 >--- a/Source/WebCore/workers/service/context/ServiceWorkerThreadProxy.cpp >+++ b/Source/WebCore/workers/service/context/ServiceWorkerThreadProxy.cpp >@@ -88,10 +88,10 @@ static HashSet<ServiceWorkerThreadProxy*>& allServiceWorkerThreadProxies() > return set; > } > >-ServiceWorkerThreadProxy::ServiceWorkerThreadProxy(PageConfiguration&& pageConfiguration, const ServiceWorkerContextData& data, PAL::SessionID sessionID, String&& userAgent, CacheStorageProvider& cacheStorageProvider, SecurityOrigin::StorageBlockingPolicy storageBlockingPolicy) >+ServiceWorkerThreadProxy::ServiceWorkerThreadProxy(PageConfiguration&& pageConfiguration, const ServiceWorkerContextData& data, PAL::SessionID sessionID, String&& userAgent, CacheStorageProvider& cacheStorageProvider, SecurityOrigin::StorageBlockingPolicy storageBlockingPolicy, String&& navigatorPlatform) > : m_page(createPageForServiceWorker(WTFMove(pageConfiguration), data, storageBlockingPolicy, data.sessionID)) > , m_document(*m_page->mainFrame().document()) >- , m_serviceWorkerThread(ServiceWorkerThread::create(data, sessionID, WTFMove(userAgent), *this, *this, idbConnectionProxy(m_document), m_document->socketProvider())) >+ , m_serviceWorkerThread(ServiceWorkerThread::create(data, sessionID, WTFMove(userAgent), *this, *this, idbConnectionProxy(m_document), m_document->socketProvider(), WTFMove(navigatorPlatform))) > , m_cacheStorageProvider(cacheStorageProvider) > , m_sessionID(sessionID) > , m_inspectorProxy(*this) >diff --git a/Source/WebCore/workers/service/context/ServiceWorkerThreadProxy.h b/Source/WebCore/workers/service/context/ServiceWorkerThreadProxy.h >index 49628299c845175faca66ff404e33d8e86bb3d46..25e58fbe5662402fb704b03b6f75861ce84785f8 100644 >--- a/Source/WebCore/workers/service/context/ServiceWorkerThreadProxy.h >+++ b/Source/WebCore/workers/service/context/ServiceWorkerThreadProxy.h >@@ -76,7 +76,7 @@ public: > WEBCORE_EXPORT void removeFetch(SWServerConnectionIdentifier, FetchIdentifier); > > private: >- WEBCORE_EXPORT ServiceWorkerThreadProxy(PageConfiguration&&, const ServiceWorkerContextData&, PAL::SessionID, String&& userAgent, CacheStorageProvider&, SecurityOrigin::StorageBlockingPolicy); >+ WEBCORE_EXPORT ServiceWorkerThreadProxy(PageConfiguration&&, const ServiceWorkerContextData&, PAL::SessionID, String&& userAgent, CacheStorageProvider&, SecurityOrigin::StorageBlockingPolicy, String&& navigatorPlatform); > > WEBCORE_EXPORT static void networkStateChanged(bool isOnLine); > >diff --git a/Source/WebCore/worklets/WorkletGlobalScope.cpp b/Source/WebCore/worklets/WorkletGlobalScope.cpp >index 7234031570fe305e8e934c75a57d66d487e28853..7a38173d1bee3b20e4be40e72ab277561c71704b 100644 >--- a/Source/WebCore/worklets/WorkletGlobalScope.cpp >+++ b/Source/WebCore/worklets/WorkletGlobalScope.cpp >@@ -100,6 +100,13 @@ String WorkletGlobalScope::userAgent(const URL& url) const > return ""; > return m_document->userAgent(url); > } >+ >+String WorkletGlobalScope::navigatorPlatform() const >+{ >+ if (!m_document) >+ return ""; >+ return m_document->navigatorPlatform(); >+} > > void WorkletGlobalScope::evaluate() > { >diff --git a/Source/WebCore/worklets/WorkletGlobalScope.h b/Source/WebCore/worklets/WorkletGlobalScope.h >index 7bb8e0f0ebea15b4335540a951ef2f840e00aa15..bec3d03c0ef7141764fd50b7b2d2ac39c60358e2 100644 >--- a/Source/WebCore/worklets/WorkletGlobalScope.h >+++ b/Source/WebCore/worklets/WorkletGlobalScope.h >@@ -121,6 +121,7 @@ private: > URL completeURL(const String&) const final; > PAL::SessionID sessionID() const final { return m_sessionID; } > String userAgent(const URL&) const final; >+ String navigatorPlatform() const final; > void disableEval(const String&) final; > void disableWebAssembly(const String&) final; > >diff --git a/Source/WebKit/Shared/WebsitePoliciesData.cpp b/Source/WebKit/Shared/WebsitePoliciesData.cpp >index df6d3ae2c187da405b548d6774a85d295edada1e..aab10e85e127765263beb9ac601ea22ff724b19b 100644 >--- a/Source/WebKit/Shared/WebsitePoliciesData.cpp >+++ b/Source/WebKit/Shared/WebsitePoliciesData.cpp >@@ -43,6 +43,7 @@ void WebsitePoliciesData::encode(IPC::Encoder& encoder) const > encoder << popUpPolicy; > encoder << websiteDataStoreParameters; > encoder << customUserAgent; >+ encoder << customNavigatorPlatform; > } > > std::optional<WebsitePoliciesData> WebsitePoliciesData::decode(IPC::Decoder& decoder) >@@ -81,6 +82,11 @@ std::optional<WebsitePoliciesData> WebsitePoliciesData::decode(IPC::Decoder& dec > decoder >> customUserAgent; > if (!customUserAgent) > return std::nullopt; >+ >+ std::optional<String> customNavigatorPlatform; >+ decoder >> customNavigatorPlatform; >+ if (!customNavigatorPlatform) >+ return std::nullopt; > > return { { > WTFMove(*contentBlockersEnabled), >@@ -90,6 +96,7 @@ std::optional<WebsitePoliciesData> WebsitePoliciesData::decode(IPC::Decoder& dec > WTFMove(*popUpPolicy), > WTFMove(*websiteDataStoreParameters), > WTFMove(*customUserAgent), >+ WTFMove(*customNavigatorPlatform), > } }; > } > >@@ -97,6 +104,7 @@ void WebsitePoliciesData::applyToDocumentLoader(WebsitePoliciesData&& websitePol > { > documentLoader.setCustomHeaderFields(WTFMove(websitePolicies.customHeaderFields)); > documentLoader.setCustomUserAgent(websitePolicies.customUserAgent); >+ documentLoader.setCustomNavigatorPlatform(websitePolicies.customNavigatorPlatform); > > // Only setUserContentExtensionsEnabled if it hasn't already been disabled by reloading without content blockers. > if (documentLoader.userContentExtensionsEnabled()) >diff --git a/Source/WebKit/Shared/WebsitePoliciesData.h b/Source/WebKit/Shared/WebsitePoliciesData.h >index 7944c466ec60e1637a5a93428a17fa6da64d2427..d05eb43f0f65b882fa88a1cc45dbf0f1d31bec6f 100644 >--- a/Source/WebKit/Shared/WebsitePoliciesData.h >+++ b/Source/WebKit/Shared/WebsitePoliciesData.h >@@ -53,6 +53,7 @@ struct WebsitePoliciesData { > WebsitePopUpPolicy popUpPolicy { WebsitePopUpPolicy::Default }; > std::optional<WebsiteDataStoreParameters> websiteDataStoreParameters; > String customUserAgent; >+ String customNavigatorPlatform; > > void encode(IPC::Encoder&) const; > static std::optional<WebsitePoliciesData> decode(IPC::Decoder&); >diff --git a/Source/WebKit/UIProcess/API/APIWebsitePolicies.cpp b/Source/WebKit/UIProcess/API/APIWebsitePolicies.cpp >index f4414425a9d4abfacbba3876fe7c4c29cc45100c..e70a5f062bcd48e571e336d494dcc5958c123331 100644 >--- a/Source/WebKit/UIProcess/API/APIWebsitePolicies.cpp >+++ b/Source/WebKit/UIProcess/API/APIWebsitePolicies.cpp >@@ -56,7 +56,7 @@ WebKit::WebsitePoliciesData WebsitePolicies::data() > std::optional<WebKit::WebsiteDataStoreParameters> parameters; > if (m_websiteDataStore) > parameters = m_websiteDataStore->websiteDataStore().parameters(); >- return { contentBlockersEnabled(), allowedAutoplayQuirks(), autoplayPolicy(), customHeaderFields(), popUpPolicy(), WTFMove(parameters), m_customUserAgent }; >+ return { contentBlockersEnabled(), allowedAutoplayQuirks(), autoplayPolicy(), customHeaderFields(), popUpPolicy(), WTFMove(parameters), m_customUserAgent, m_customNavigatorPlatform }; > } > > } >diff --git a/Source/WebKit/UIProcess/API/APIWebsitePolicies.h b/Source/WebKit/UIProcess/API/APIWebsitePolicies.h >index 5f66abeba614b8a515676cf0afc7a00196d9e606..3f7aa061bf182c0c66f79ad997fa7ed9a3a320ad 100644 >--- a/Source/WebKit/UIProcess/API/APIWebsitePolicies.h >+++ b/Source/WebKit/UIProcess/API/APIWebsitePolicies.h >@@ -71,6 +71,9 @@ public: > > void setCustomUserAgent(const WTF::String& customUserAgent) { m_customUserAgent = customUserAgent; } > const WTF::String& customUserAgent() const { return m_customUserAgent; } >+ >+ void setCustomNavigatorPlatform(const WTF::String& customNavigatorPlatform) { m_customNavigatorPlatform = customNavigatorPlatform; } >+ const WTF::String& customNavigatorPlatform() const { return m_customNavigatorPlatform; } > > private: > WebsitePolicies(bool contentBlockersEnabled, OptionSet<WebKit::WebsiteAutoplayQuirk>, WebKit::WebsiteAutoplayPolicy, Vector<WebCore::HTTPHeaderField>&&, WebKit::WebsitePopUpPolicy, RefPtr<WebsiteDataStore>&&); >@@ -82,6 +85,7 @@ private: > WebKit::WebsitePopUpPolicy m_popUpPolicy { WebKit::WebsitePopUpPolicy::Default }; > RefPtr<WebsiteDataStore> m_websiteDataStore; > WTF::String m_customUserAgent; >+ WTF::String m_customNavigatorPlatform; > }; > > } // namespace API >diff --git a/Source/WebKit/UIProcess/API/Cocoa/_WKWebsitePolicies.h b/Source/WebKit/UIProcess/API/Cocoa/_WKWebsitePolicies.h >index ead50191863079a944d56bf7e1d992f07a9502fa..621a1564bf648f1ae265038a9553bbb92df393d6 100644 >--- a/Source/WebKit/UIProcess/API/Cocoa/_WKWebsitePolicies.h >+++ b/Source/WebKit/UIProcess/API/Cocoa/_WKWebsitePolicies.h >@@ -58,6 +58,7 @@ WK_CLASS_AVAILABLE(macosx(10.12.3), ios(10.3)) > @property (nonatomic) _WKWebsitePopUpPolicy popUpPolicy WK_API_AVAILABLE(macosx(10.14), ios(12.0)); > @property (nonatomic, strong) WKWebsiteDataStore *websiteDataStore WK_API_AVAILABLE(macosx(10.13.4), ios(11.3)); > @property (nonatomic, copy) NSString *customUserAgent WK_API_AVAILABLE(macosx(WK_MAC_TBA), ios(WK_IOS_TBA)); >+@property (nonatomic, copy) NSString *customNavigatorPlatform WK_API_AVAILABLE(macosx(WK_MAC_TBA), ios(WK_IOS_TBA)); > > @end > >diff --git a/Source/WebKit/UIProcess/API/Cocoa/_WKWebsitePolicies.mm b/Source/WebKit/UIProcess/API/Cocoa/_WKWebsitePolicies.mm >index 03bd177942e5baa91d5d69b08a607153d815cd45..7f3c8225449a78e9e15482846874f2464016c805 100644 >--- a/Source/WebKit/UIProcess/API/Cocoa/_WKWebsitePolicies.mm >+++ b/Source/WebKit/UIProcess/API/Cocoa/_WKWebsitePolicies.mm >@@ -193,6 +193,16 @@ - (NSString *)customUserAgent > return _websitePolicies->customUserAgent(); > } > >+- (void)setCustomNavigatorPlatform:(NSString *)customNavigatorPlatform >+{ >+ _websitePolicies->setCustomNavigatorPlatform(customNavigatorPlatform); >+} >+ >+- (NSString *)customNavigatorPlatform >+{ >+ return _websitePolicies->customNavigatorPlatform(); >+} >+ > - (NSString *)description > { > return [NSString stringWithFormat:@"<%@: %p; contentBlockersEnabled = %d>", NSStringFromClass(self.class), self, self.contentBlockersEnabled]; >diff --git a/Source/WebKit/UIProcess/Cocoa/NavigationState.mm b/Source/WebKit/UIProcess/Cocoa/NavigationState.mm >index f5ee4df18043d3b5a64b10d4c2e63740d9939772..e30b03f5f4c4cdc8b27dc6ac6c555ab89c9db8b7 100644 >--- a/Source/WebKit/UIProcess/Cocoa/NavigationState.mm >+++ b/Source/WebKit/UIProcess/Cocoa/NavigationState.mm >@@ -549,6 +549,8 @@ void NavigationState::NavigationClient::decidePolicyForNavigationAction(WebPageP > } > if (!apiWebsitePolicies->customUserAgent().isNull() && subframeNavigation) > [NSException raise:NSInvalidArgumentException format:@"_WKWebsitePolicies.customUserAgent must be nil for subframe navigations."]; >+ if (!apiWebsitePolicies->customNavigatorPlatform().isNull() && subframeNavigation) >+ [NSException raise:NSInvalidArgumentException format:@"_WKWebsitePolicies.customNavigatorPlatform must be nil for subframe navigations."]; > } > > switch (actionPolicy) { >diff --git a/Source/WebKit/WebProcess/InjectedBundle/API/c/WKBundlePageLoaderClient.h b/Source/WebKit/WebProcess/InjectedBundle/API/c/WKBundlePageLoaderClient.h >index 040f591b7e5be431686ec2a960d15cd47ef7ac49..c33bc5c7caa08956fbfe9bed54de1a50198737dd 100644 >--- a/Source/WebKit/WebProcess/InjectedBundle/API/c/WKBundlePageLoaderClient.h >+++ b/Source/WebKit/WebProcess/InjectedBundle/API/c/WKBundlePageLoaderClient.h >@@ -63,6 +63,7 @@ typedef void (*WKBundlePageFeaturesUsedInPageCallback)(WKBundlePageRef page, WKA > typedef void (*WKBundlePageWillLoadURLRequestCallback)(WKBundlePageRef page, WKURLRequestRef request, WKTypeRef userData, const void *clientInfo); > typedef void (*WKBundlePageWillLoadDataRequestCallback)(WKBundlePageRef page, WKURLRequestRef request, WKDataRef data, WKStringRef MIMEType, WKStringRef encodingName, WKURLRef unreachableURL, WKTypeRef userData, const void *clientInfo); > typedef WKStringRef (*WKBundlePageUserAgentForURLCallback)(WKBundleFrameRef frame, WKURLRef url, const void *clientInfo); >+typedef WKDictionaryRef (*WKBundleNavigatorPropertiesForURLCallback)(WKBundleFrameRef frame, WKURLRef url, const void *clientInfo); > > typedef struct WKBundlePageLoaderClientBase { > int version; >@@ -526,4 +527,9 @@ typedef struct WKBundlePageLoaderClientV9 { > WKBundlePageWillInjectUserScriptForFrameCallback willInjectUserScriptForFrame; > } WKBundlePageLoaderClientV9; > >+ >+ >+ >+ >+ > #endif // WKBundlePageLoaderClient_h >diff --git a/Source/WebKit/WebProcess/Storage/WebSWContextManagerConnection.cpp b/Source/WebKit/WebProcess/Storage/WebSWContextManagerConnection.cpp >index 04e9aa7d9977a6f076aef6ccd0bce16a411fb358..11a22ecf2dcaec760ddd5972c0f5e4a575d38e60 100644 >--- a/Source/WebKit/WebProcess/Storage/WebSWContextManagerConnection.cpp >+++ b/Source/WebKit/WebProcess/Storage/WebSWContextManagerConnection.cpp >@@ -72,16 +72,18 @@ static const Seconds syncWorkerTerminationTimeout { 100_ms }; // Only used by la > > class ServiceWorkerFrameLoaderClient final : public EmptyFrameLoaderClient { > public: >- ServiceWorkerFrameLoaderClient(WebSWContextManagerConnection& connection, PAL::SessionID sessionID, uint64_t pageID, uint64_t frameID, const String& userAgent) >+ ServiceWorkerFrameLoaderClient(WebSWContextManagerConnection& connection, PAL::SessionID sessionID, uint64_t pageID, uint64_t frameID, const String& userAgent, const String& navigatorPlatform) > : m_connection(connection) > , m_sessionID(sessionID) > , m_pageID(pageID) > , m_frameID(frameID) > , m_userAgent(userAgent) >+ , m_navigatorPlatform(navigatorPlatform) > { > } > > void setUserAgent(String&& userAgent) { m_userAgent = WTFMove(userAgent); } >+ void setNavigatorPlatform(String&& navigatorPlatform) { m_navigatorPlatform = WTFMove(navigatorPlatform); } > > private: > Ref<DocumentLoader> createDocumentLoader(const ResourceRequest& request, const SubstituteData& substituteData) final >@@ -103,6 +105,7 @@ private: > uint64_t m_pageID { 0 }; > uint64_t m_frameID { 0 }; > String m_userAgent; >+ String m_navigatorPlatform; > }; > > WebSWContextManagerConnection::WebSWContextManagerConnection(Ref<IPC::Connection>&& connection, uint64_t pageGroupID, uint64_t pageID, const WebPreferencesStore& store) >@@ -147,11 +150,11 @@ void WebSWContextManagerConnection::installServiceWorker(const ServiceWorkerCont > > // FIXME: This method should be moved directly to WebCore::SWContextManager::Connection > // If it weren't for ServiceWorkerFrameLoaderClient's dependence on WebDocumentLoader, this could already happen. >- auto frameLoaderClient = std::make_unique<ServiceWorkerFrameLoaderClient>(*this, sessionID, m_pageID, ++m_previousServiceWorkerID, m_userAgent); >+ auto frameLoaderClient = std::make_unique<ServiceWorkerFrameLoaderClient>(*this, sessionID, m_pageID, ++m_previousServiceWorkerID, m_userAgent, m_navigatorPlatform); > pageConfiguration.loaderClientForMainFrame = frameLoaderClient.get(); > m_loaders.add(WTFMove(frameLoaderClient)); > >- auto serviceWorkerThreadProxy = ServiceWorkerThreadProxy::create(WTFMove(pageConfiguration), data, sessionID, String { m_userAgent }, WebProcess::singleton().cacheStorageProvider(), m_storageBlockingPolicy); >+ auto serviceWorkerThreadProxy = ServiceWorkerThreadProxy::create(WTFMove(pageConfiguration), data, sessionID, String { m_userAgent }, WebProcess::singleton().cacheStorageProvider(), m_storageBlockingPolicy, String { m_navigatorPlatform}); > SWContextManager::singleton().registerServiceWorkerThreadForInstall(WTFMove(serviceWorkerThreadProxy)); > > LOG(ServiceWorker, "Context process PID: %i created worker thread\n", getCurrentProcessID()); >@@ -161,6 +164,11 @@ void WebSWContextManagerConnection::setUserAgent(String&& userAgent) > { > m_userAgent = WTFMove(userAgent); > } >+ >+void WebSWContextManagerConnection::setNavigatorPlatform(String&& navigatorPlatform) >+{ >+ m_navigatorPlatform = WTFMove(navigatorPlatform); >+} > > void WebSWContextManagerConnection::removeFrameLoaderClient(ServiceWorkerFrameLoaderClient& client) > { >diff --git a/Source/WebKit/WebProcess/Storage/WebSWContextManagerConnection.h b/Source/WebKit/WebProcess/Storage/WebSWContextManagerConnection.h >index d9794699c91dc5d756dc33bdb2545c5f5dc0414d..f6d530db309de68f0d7391d1583edb330b2584c3 100644 >--- a/Source/WebKit/WebProcess/Storage/WebSWContextManagerConnection.h >+++ b/Source/WebKit/WebProcess/Storage/WebSWContextManagerConnection.h >@@ -89,6 +89,7 @@ private: > void claimCompleted(uint64_t claimRequestIdentifier); > void didFinishSkipWaiting(uint64_t callbackID); > void setUserAgent(String&& userAgent); >+ void setNavigatorPlatform(String&&); > void terminateProcess(); > > Ref<IPC::Connection> m_connectionToNetworkProcess; >@@ -105,6 +106,7 @@ private: > HashMap<uint64_t, WTF::Function<void()>> m_skipWaitingRequests; > uint64_t m_previousRequestIdentifier { 0 }; > String m_userAgent; >+ String m_navigatorPlatform; > }; > > } // namespace WebKit >diff --git a/Source/WebKit/WebProcess/WebCoreSupport/WebFrameLoaderClient.cpp b/Source/WebKit/WebProcess/WebCoreSupport/WebFrameLoaderClient.cpp >index 3e6f31a59ecd0bcdeab205c32533ccae9c1b25e5..9a4903f8ab5b12ecb4bae006d3e2b2b321c67a09 100644 >--- a/Source/WebKit/WebProcess/WebCoreSupport/WebFrameLoaderClient.cpp >+++ b/Source/WebKit/WebProcess/WebCoreSupport/WebFrameLoaderClient.cpp >@@ -1361,6 +1361,15 @@ String WebFrameLoaderClient::userAgent(const URL& url) > > return webPage->userAgent(m_frame, url); > } >+ >+String WebFrameLoaderClient::navigatorPlatform() >+{ >+ WebPage* webPage = m_frame->page(); >+ if (!webPage) >+ return String(); >+ >+ return webPage->navigatorPlatform(m_frame); >+} > > String WebFrameLoaderClient::overrideContentSecurityPolicy() const > { >diff --git a/Source/WebKit/WebProcess/WebCoreSupport/WebFrameLoaderClient.h b/Source/WebKit/WebProcess/WebCoreSupport/WebFrameLoaderClient.h >index 7fb514770128e73f4c2eef4301bbcae9a6985e01..0ad5e6f4e304f1208eec744ea541707f1312596c 100644 >--- a/Source/WebKit/WebProcess/WebCoreSupport/WebFrameLoaderClient.h >+++ b/Source/WebKit/WebProcess/WebCoreSupport/WebFrameLoaderClient.h >@@ -192,6 +192,7 @@ private: > void setTitle(const WebCore::StringWithDirection&, const URL&) final; > > String userAgent(const URL&) final; >+ String navigatorPlatform() final; > > String overrideContentSecurityPolicy() const final; > >diff --git a/Source/WebKit/WebProcess/WebPage/WebPage.cpp b/Source/WebKit/WebProcess/WebPage/WebPage.cpp >index cb719d405c43adaee4f2c538afaa821b1abdc61c..582b43f5c889153e65ebe11a2b763aea2ea0fda6 100644 >--- a/Source/WebKit/WebProcess/WebPage/WebPage.cpp >+++ b/Source/WebKit/WebProcess/WebPage/WebPage.cpp >@@ -3098,6 +3098,30 @@ void WebPage::setUserAgent(const String& userAgent) > if (m_page) > m_page->userAgentChanged(); > } >+ >+String WebPage::navigatorPlatform() const >+{ >+ return navigatorPlatform(nullptr); >+} >+ >+String WebPage::navigatorPlatform(WebFrame* frame) const >+{ >+ String platform = platformNavigatorPlatform(); >+ if (!platform.isEmpty()) >+ return platform; >+ return m_navigatorPlatform; >+} >+ >+void WebPage::setNavigatorPlatform(const String& navigatorPlatform) >+{ >+ if (m_navigatorPlatform == navigatorPlatform) >+ return; >+ >+ m_navigatorPlatform = navigatorPlatform; >+ >+ if (m_page) >+ m_page->userAgentChanged(); >+} > > void WebPage::suspendActiveDOMObjectsAndAnimations() > { >diff --git a/Source/WebKit/WebProcess/WebPage/WebPage.h b/Source/WebKit/WebProcess/WebPage/WebPage.h >index e0af2f636866d4beb4a9c5e9e0ba1d0684871004..b4773872868779f0b6c3329e4e0aa8cdb5660f66 100644 >--- a/Source/WebKit/WebProcess/WebPage/WebPage.h >+++ b/Source/WebKit/WebProcess/WebPage/WebPage.h >@@ -344,6 +344,9 @@ public: > String userAgent(const URL&) const; > String userAgent(WebFrame*, const URL&) const; > String platformUserAgent(const URL&) const; >+ String navigatorPlatform() const; >+ String navigatorPlatform(WebFrame*) const; >+ String platformNavigatorPlatform() const; > WebCore::KeyboardUIMode keyboardUIMode(); > > void didInsertMenuElement(WebCore::HTMLMenuElement&); >@@ -1293,6 +1296,7 @@ private: > void didReceivePolicyDecision(uint64_t frameID, uint64_t listenerID, WebCore::PolicyAction, uint64_t navigationID, const DownloadID&, std::optional<WebsitePoliciesData>&&); > void continueWillSubmitForm(uint64_t frameID, uint64_t listenerID); > void setUserAgent(const String&); >+ void setNavigatorPlatform(const String&); > void setCustomTextEncodingName(const String&); > void suspendActiveDOMObjectsAndAnimations(); > void resumeActiveDOMObjectsAndAnimations(); >@@ -1481,6 +1485,7 @@ private: > RefPtr<WebPageGroupProxy> m_pageGroup; > > String m_userAgent; >+ String m_navigatorPlatform; > > WebCore::IntSize m_viewSize; > std::unique_ptr<DrawingArea> m_drawingArea; >diff --git a/Source/WebKit/WebProcess/WebPage/ios/WebPageIOS.mm b/Source/WebKit/WebProcess/WebPage/ios/WebPageIOS.mm >index 9df618a4d9ad8e9b1d63206c60051dafb76db235..bf451ff8107ed8a68176ad93ea7b23f10771003e 100644 >--- a/Source/WebKit/WebProcess/WebPage/ios/WebPageIOS.mm >+++ b/Source/WebKit/WebProcess/WebPage/ios/WebPageIOS.mm >@@ -3124,6 +3124,11 @@ String WebPage::platformUserAgent(const URL&) const > { > return String(); > } >+ >+String WebPage::platformNavigatorPlatform() const >+{ >+ return String(); >+} > > void WebPage::hardwareKeyboardAvailabilityChanged() > { >diff --git a/Source/WebKit/WebProcess/WebPage/mac/WebPageMac.mm b/Source/WebKit/WebProcess/WebPage/mac/WebPageMac.mm >index fa7a6aaf1b60bda90dcd079ba1a9436f1216b0dc..46c546a14784b2145c471da06d31d1c0c8d3437a 100644 >--- a/Source/WebKit/WebProcess/WebPage/mac/WebPageMac.mm >+++ b/Source/WebKit/WebProcess/WebPage/mac/WebPageMac.mm >@@ -826,6 +826,10 @@ String WebPage::platformUserAgent(const URL&) const > { > return String(); > } >+String WebPage::platformNavigatorPlatform() const >+{ >+ return String(); >+} > > void WebPage::performImmediateActionHitTestAtLocation(WebCore::FloatPoint locationInViewCoordinates) > { >diff --git a/Source/WebKitLegacy/mac/WebCoreSupport/WebFrameLoaderClient.h b/Source/WebKitLegacy/mac/WebCoreSupport/WebFrameLoaderClient.h >index 99910382b4fea44bb8584fafab9fbeccedf6d712..52e0eeaa49cd9bc04eb124da26705532398e3b4b 100644 >--- a/Source/WebKitLegacy/mac/WebCoreSupport/WebFrameLoaderClient.h >+++ b/Source/WebKitLegacy/mac/WebCoreSupport/WebFrameLoaderClient.h >@@ -177,6 +177,7 @@ private: > bool shouldFallBack(const WebCore::ResourceError&) final; > > WTF::String userAgent(const URL&) final; >+ WTF::String navigatorPlatform() final; > > void savePlatformDataToCachedFrame(WebCore::CachedFrame*) final; > void transitionToCommittedFromCachedFrame(WebCore::CachedFrame*) final; >diff --git a/Source/WebKitLegacy/mac/WebCoreSupport/WebFrameLoaderClient.mm b/Source/WebKitLegacy/mac/WebCoreSupport/WebFrameLoaderClient.mm >index ec8e58cf207bbcb04822ed2b15dead06762a567d..d165c81e88117eb5860f1241a68765e06b2deeeb 100644 >--- a/Source/WebKitLegacy/mac/WebCoreSupport/WebFrameLoaderClient.mm >+++ b/Source/WebKitLegacy/mac/WebCoreSupport/WebFrameLoaderClient.mm >@@ -1548,6 +1548,11 @@ String WebFrameLoaderClient::userAgent(const URL& url) > return [webView _userAgentString]; > } > >+String WebFrameLoaderClient::navigatorPlatform() >+{ >+ return emptyString(); >+} >+ > NSDictionary *WebFrameLoaderClient::actionDictionary(const NavigationAction& action, FormState* formState) const > { > unsigned modifierFlags = 0; >diff --git a/Tools/ChangeLog b/Tools/ChangeLog >index 43b1b3099d17a311042ffea1bfa0bd7c2584dc73..ddce8366ba5f2d638deba66fa3a05ee088be270a 100644 >--- a/Tools/ChangeLog >+++ b/Tools/ChangeLog >@@ -1,3 +1,16 @@ >+2018-12-14 Megan Gardner <megan_gardner@apple.com> >+ >+ Allow clients to set the navigator platform >+ https://bugs.webkit.org/show_bug.cgi?id=192735 >+ >+ Reviewed by NOBODY (OOPS!). >+ >+ Add a test for setting a custom navigator platform. >+ >+ * TestWebKitAPI/Tests/WebKitCocoa/WebsitePolicies.mm: >+ (-[CustomNavigatorPlatformDelegate _webView:decidePolicyForNavigationAction:userInfo:decisionHandler:]): >+ (-[CustomNavigatorPlatformDelegate webView:didFinishNavigation:]): >+ > 2018-12-13 Ross Kirsling <ross.kirsling@sony.com> > > Unreviewed -- update my status to "reviewer". >diff --git a/Tools/TestWebKitAPI/Tests/WebKitCocoa/WebsitePolicies.mm b/Tools/TestWebKitAPI/Tests/WebKitCocoa/WebsitePolicies.mm >index 88c4af4c04345c44ca0d39947b8d819c518ff1b5..503c3f7a83cc2071e52750313d1857978e2859e5 100644 >--- a/Tools/TestWebKitAPI/Tests/WebKitCocoa/WebsitePolicies.mm >+++ b/Tools/TestWebKitAPI/Tests/WebKitCocoa/WebsitePolicies.mm >@@ -974,6 +974,41 @@ TEST(WebKit, WebsitePoliciesCustomUserAgent) > loadCount = 0; > } > >+@interface CustomNavigatorPlatformDelegate : NSObject <WKNavigationDelegate> { >+} >+@end >+ >+@implementation CustomNavigatorPlatformDelegate >+ >+- (void)_webView:(WKWebView *)webView decidePolicyForNavigationAction:(WKNavigationAction *)navigationAction userInfo:(id <NSSecureCoding>)userInfo decisionHandler:(void (^)(WKNavigationActionPolicy, _WKWebsitePolicies *))decisionHandler >+{ >+ _WKWebsitePolicies *websitePolicies = [[[_WKWebsitePolicies alloc] init] autorelease]; >+ if (navigationAction.targetFrame.mainFrame) >+ [websitePolicies setCustomNavigatorPlatform:@"Test Custom Platform"]; >+ >+ decisionHandler(WKNavigationActionPolicyAllow, websitePolicies); >+} >+ >+- (void)webView:(WKWebView *)webView didFinishNavigation:(WKNavigation *)navigation >+{ >+ finishedNavigation = true; >+} >+ >+@end >+ >+TEST(WebKit, WebsitePoliciesCustomNavigatorPlatform) >+{ >+ auto configuration = adoptNS([[WKWebViewConfiguration alloc] init]); >+ >+ auto webView = adoptNS([[TestWKWebView alloc] initWithFrame:NSMakeRect(0, 0, 800, 600) configuration:configuration.get()]); >+ >+ auto delegate = adoptNS([[CustomNavigatorPlatformDelegate alloc] init]); >+ [webView setNavigationDelegate:delegate.get()]; >+ >+ EXPECT_STREQ("Test Custom Platform", [[webView stringByEvaluatingJavaScript:@"navigator.platform"] UTF8String]); >+} >+ >+ > @interface PopUpPoliciesDelegate : NSObject <WKNavigationDelegate, WKUIDelegatePrivate> > @property (nonatomic, copy) _WKWebsitePopUpPolicy(^popUpPolicyForURL)(NSURL *); > @end
You cannot view the attachment while viewing its details because your browser does not support IFRAMEs.
View the attachment on a separate page
.
View Attachment As Diff
View Attachment As Raw
Actions:
View
|
Formatted Diff
|
Diff
Attachments on
bug 192735
:
357380
|
357387
|
357388
|
357389
|
357390
|
357618
|
357631
|
357634
|
357636
|
357646
|
357706