Diff
Modified: trunk/LayoutTests/ChangeLog (292104 => 292105)
--- trunk/LayoutTests/ChangeLog 2022-03-30 12:58:38 UTC (rev 292104)
+++ trunk/LayoutTests/ChangeLog 2022-03-30 13:28:05 UTC (rev 292105)
@@ -1,3 +1,13 @@
+2022-03-30 Youenn Fablet <[email protected]>
+
+ Implement ServiceWorker WindowClient.ancestorOrigins
+ https://bugs.webkit.org/show_bug.cgi?id=238441
+
+ Reviewed by Chris Dumez.
+
+ * http/wpt/service-workers/resources/third-party-worker.js:
+ * http/wpt/service-workers/third-party-registration.html:
+
2022-03-29 Fujii Hironori <[email protected]>
[WinCairo] Unreviewed test gardening
Modified: trunk/LayoutTests/http/wpt/service-workers/resources/third-party-worker.js (292104 => 292105)
--- trunk/LayoutTests/http/wpt/service-workers/resources/third-party-worker.js 2022-03-30 12:58:38 UTC (rev 292104)
+++ trunk/LayoutTests/http/wpt/service-workers/resources/third-party-worker.js 2022-03-30 13:28:05 UTC (rev 292105)
@@ -23,6 +23,10 @@
e.source.postMessage('cookie-is-set');
return;
}
+ if (e.data ="" 'ancestorOrigins') {
+ e.source.postMessage(e.source.ancestorOrigins);
+ return;
+ }
e.source.postMessage('error');
} catch (e) {
e.source.postMessage('Got error:' + e);
Modified: trunk/LayoutTests/http/wpt/service-workers/third-party-registration.html (292104 => 292105)
--- trunk/LayoutTests/http/wpt/service-workers/third-party-registration.html 2022-03-30 12:58:38 UTC (rev 292104)
+++ trunk/LayoutTests/http/wpt/service-workers/third-party-registration.html 2022-03-30 13:28:05 UTC (rev 292105)
@@ -10,23 +10,40 @@
testRunner.dumpAsText();
}
+function logAndFinishTest(msg)
+{
+ document.body.innerHTML = msg;
+ if (window.testRunner)
+ testRunner.notifyDone();
+}
+
var shouldTest = !!window.location.hash;
async function doTest()
{
- var iframe = await with_iframe("http://127.0.0.1:8801/WebKit/service-workers/resources/third-party-registration-frame.html");
- var result = await new Promise((resolve) => {
- window._onmessage_ = (e) => {
- resolve(e.data);
- };
- iframe.contentWindow.postMessage(shouldTest ? "read" : "write", '*');
- });
+ const iframe = await with_iframe("http://127.0.0.1:8801/WebKit/service-workers/resources/third-party-registration-frame.html");
+
if (shouldTest) {
+ iframe.contentWindow.postMessage("ancestorOrigins", '*');
+ const ancestorOriginsData = await new Promise(resolve => window._onmessage_ = (e) => resolve(e.data));
+ if (ancestorOriginsData.length !== 1) {
+ logAndFinishTest("FAIL ancestorOriginsData length is not 1");
+ return;
+ }
+ if (ancestorOriginsData[0] !== "http://localhost:8801") {
+ logAndFinishTest("FAIL ancestorOriginsData length is not 1");
+ return;
+ }
+ }
+
+ iframe.contentWindow.postMessage(shouldTest ? "read" : "write", '*');
+ const result = await new Promise(resolve => window._onmessage_ = (e) => resolve(e.data));
+
+ if (shouldTest) {
var expected = '{\"cache\":[],\"db\":null}';
- document.body.innerHTML = result === expected ? "PASS" : ("FAIL: got " + result);
- if (window.testRunner)
- testRunner.notifyDone();
+ logAndFinishTest(result === expected ? "PASS" : ("FAIL: got " + result));
return;
}
+
iframe.remove();
window.location = "http://localhost:8801/WebKit/service-workers/third-party-registration.html#second";
}
Modified: trunk/LayoutTests/imported/w3c/ChangeLog (292104 => 292105)
--- trunk/LayoutTests/imported/w3c/ChangeLog 2022-03-30 12:58:38 UTC (rev 292104)
+++ trunk/LayoutTests/imported/w3c/ChangeLog 2022-03-30 13:28:05 UTC (rev 292105)
@@ -1,3 +1,12 @@
+2022-03-30 Youenn Fablet <[email protected]>
+
+ Implement ServiceWorker WindowClient.ancestorOrigins
+ https://bugs.webkit.org/show_bug.cgi?id=238441
+
+ Reviewed by Chris Dumez.
+
+ * web-platform-tests/service-workers/idlharness.https.any.serviceworker-expected.txt:
+
2022-03-29 Fujii Hironori <[email protected]>
drop-shadow filter doesn't work correctly in tiled backing layer
Modified: trunk/LayoutTests/imported/w3c/web-platform-tests/service-workers/idlharness.https.any.serviceworker-expected.txt (292104 => 292105)
--- trunk/LayoutTests/imported/w3c/web-platform-tests/service-workers/idlharness.https.any.serviceworker-expected.txt 2022-03-30 12:58:38 UTC (rev 292104)
+++ trunk/LayoutTests/imported/w3c/web-platform-tests/service-workers/idlharness.https.any.serviceworker-expected.txt 2022-03-30 13:28:05 UTC (rev 292105)
@@ -171,7 +171,7 @@
PASS WindowClient interface: existence and properties of interface prototype object's @@unscopables property
PASS WindowClient interface: attribute visibilityState
PASS WindowClient interface: attribute focused
-FAIL WindowClient interface: attribute ancestorOrigins assert_true: The prototype object must have a property "ancestorOrigins" expected true got false
+PASS WindowClient interface: attribute ancestorOrigins
PASS WindowClient interface: operation focus()
PASS WindowClient interface: operation navigate(USVString)
PASS Clients interface: existence and properties of interface object
Modified: trunk/Source/WTF/ChangeLog (292104 => 292105)
--- trunk/Source/WTF/ChangeLog 2022-03-30 12:58:38 UTC (rev 292104)
+++ trunk/Source/WTF/ChangeLog 2022-03-30 13:28:05 UTC (rev 292105)
@@ -1,3 +1,15 @@
+2022-03-30 Youenn Fablet <[email protected]>
+
+ Implement ServiceWorker WindowClient.ancestorOrigins
+ https://bugs.webkit.org/show_bug.cgi?id=238441
+
+ Reviewed by Chris Dumez.
+
+ Update UniqueRef and HashTraits to not use a private constructor when creating empty values.
+
+ * wtf/HashTraits.h:
+ * wtf/UniqueRef.h:
+
2022-03-28 Sihui Liu <[email protected]>
Disable custom storage paths for IndexedDB and LocalStorage by default
Modified: trunk/Source/WTF/wtf/HashTraits.h (292104 => 292105)
--- trunk/Source/WTF/wtf/HashTraits.h 2022-03-30 12:58:38 UTC (rev 292104)
+++ trunk/Source/WTF/wtf/HashTraits.h 2022-03-30 13:28:05 UTC (rev 292105)
@@ -182,6 +182,12 @@
typedef std::nullptr_t EmptyValueType;
static EmptyValueType emptyValue() { return nullptr; }
+ template <typename>
+ static void constructEmptyValue(UniqueRef<T>& slot)
+ {
+ new (NotNull, std::addressof(slot)) UniqueRef<T>(HashTableEmptyValue);
+ }
+
static void constructDeletedValue(UniqueRef<T>& slot) { new (NotNull, std::addressof(slot)) UniqueRef<T> { reinterpret_cast<T*>(-1) }; }
static bool isDeletedValue(const UniqueRef<T>& value) { return value.get() == reinterpret_cast<T*>(-1); }
Modified: trunk/Source/WTF/wtf/UniqueRef.h (292104 => 292105)
--- trunk/Source/WTF/wtf/UniqueRef.h 2022-03-30 12:58:38 UTC (rev 292104)
+++ trunk/Source/WTF/wtf/UniqueRef.h 2022-03-30 13:28:05 UTC (rev 292105)
@@ -86,6 +86,8 @@
std::unique_ptr<T> moveToUniquePtr() { return WTFMove(m_ref); }
+ explicit UniqueRef(HashTableEmptyValueType) { }
+
private:
template<class U, class... Args> friend UniqueRef<U> makeUniqueRefWithoutFastMallocCheck(Args&&...);
template<class U> friend UniqueRef<U> makeUniqueRefFromNonNullUniquePtr(std::unique_ptr<U>&&);
Modified: trunk/Source/WebCore/ChangeLog (292104 => 292105)
--- trunk/Source/WebCore/ChangeLog 2022-03-30 12:58:38 UTC (rev 292104)
+++ trunk/Source/WebCore/ChangeLog 2022-03-30 13:28:05 UTC (rev 292105)
@@ -1,3 +1,22 @@
+2022-03-30 Youenn Fablet <[email protected]>
+
+ Implement ServiceWorker WindowClient.ancestorOrigins
+ https://bugs.webkit.org/show_bug.cgi?id=238441
+
+ Reviewed by Chris Dumez.
+
+ Add ancestorOrigins to ServiceWorkerClientData.
+ Migrate client map to UniqueRef since ServiceWorkerClientData size goes above 128.
+
+ Covered by updated tests.
+
+ * workers/service/ServiceWorkerClientData.cpp:
+ * workers/service/ServiceWorkerClientData.h:
+ * workers/service/ServiceWorkerWindowClient.h:
+ * workers/service/ServiceWorkerWindowClient.idl:
+ * workers/service/server/SWServer.cpp:
+ * workers/service/server/SWServer.h:
+
2022-03-30 Zan Dobersek <[email protected]>
Slim down ANGLEHeaders.h
Modified: trunk/Source/WebCore/workers/service/ServiceWorkerClientData.cpp (292104 => 292105)
--- trunk/Source/WebCore/workers/service/ServiceWorkerClientData.cpp 2022-03-30 12:58:38 UTC (rev 292104)
+++ trunk/Source/WebCore/workers/service/ServiceWorkerClientData.cpp 2022-03-30 13:28:05 UTC (rev 292105)
@@ -33,6 +33,7 @@
#include "DocumentLoader.h"
#include "Frame.h"
#include "SWClientConnection.h"
+#include <wtf/CrossThreadCopier.h>
namespace WebCore {
@@ -58,12 +59,12 @@
ServiceWorkerClientData ServiceWorkerClientData::isolatedCopy() const &
{
- return { identifier, type, frameType, url.isolatedCopy(), pageIdentifier, lastNavigationWasAppInitiated, isVisible, isFocused, focusOrder };
+ return { identifier, type, frameType, url.isolatedCopy(), pageIdentifier, lastNavigationWasAppInitiated, isVisible, isFocused, focusOrder, crossThreadCopy(ancestorOrigins) };
}
ServiceWorkerClientData ServiceWorkerClientData::isolatedCopy() &&
{
- return { identifier, type, frameType, WTFMove(url).isolatedCopy(), pageIdentifier, lastNavigationWasAppInitiated, isVisible, isFocused, focusOrder };
+ return { identifier, type, frameType, WTFMove(url).isolatedCopy(), pageIdentifier, lastNavigationWasAppInitiated, isVisible, isFocused, focusOrder, crossThreadCopy(WTFMove(ancestorOrigins)) };
}
ServiceWorkerClientData ServiceWorkerClientData::from(ScriptExecutionContext& context)
@@ -74,6 +75,12 @@
auto& document = downcast<Document>(context);
auto lastNavigationWasAppInitiated = document.loader() && document.loader()->lastNavigationWasAppInitiated() ? LastNavigationWasAppInitiated::Yes : LastNavigationWasAppInitiated::No;
+ Vector<String> ancestorOrigins;
+ if (auto* frame = document.frame()) {
+ for (auto* ancestor = frame->tree().parent(); ancestor; ancestor = ancestor->tree().parent())
+ ancestorOrigins.append(ancestor->document()->securityOrigin().toString());
+ }
+
return {
context.identifier(),
isDocument ? ServiceWorkerClientType::Window : ServiceWorkerClientType::Worker,
@@ -83,7 +90,8 @@
lastNavigationWasAppInitiated,
!document.hidden(),
document.hasFocus(),
- 0
+ 0,
+ WTFMove(ancestorOrigins)
};
}
Modified: trunk/Source/WebCore/workers/service/ServiceWorkerClientData.h (292104 => 292105)
--- trunk/Source/WebCore/workers/service/ServiceWorkerClientData.h 2022-03-30 12:58:38 UTC (rev 292104)
+++ trunk/Source/WebCore/workers/service/ServiceWorkerClientData.h 2022-03-30 13:28:05 UTC (rev 292105)
@@ -42,6 +42,8 @@
enum class LastNavigationWasAppInitiated : bool { No, Yes };
struct ServiceWorkerClientData {
+ WTF_MAKE_STRUCT_FAST_ALLOCATED;
+
ScriptExecutionContextIdentifier identifier;
ServiceWorkerClientType type;
ServiceWorkerClientFrameType frameType;
@@ -51,6 +53,7 @@
bool isVisible { false };
bool isFocused { false };
uint64_t focusOrder { 0 };
+ Vector<String> ancestorOrigins;
ServiceWorkerClientData isolatedCopy() const &;
ServiceWorkerClientData isolatedCopy() &&;
@@ -64,7 +67,7 @@
template<class Encoder>
void ServiceWorkerClientData::encode(Encoder& encoder) const
{
- encoder << identifier << type << frameType << url << pageIdentifier << lastNavigationWasAppInitiated << isVisible << isFocused << focusOrder;
+ encoder << identifier << type << frameType << url << pageIdentifier << lastNavigationWasAppInitiated << isVisible << isFocused << focusOrder << ancestorOrigins;
}
template<class Decoder>
@@ -115,7 +118,12 @@
if (!focusOrder)
return std::nullopt;
- return { { WTFMove(*identifier), WTFMove(*type), WTFMove(*frameType), WTFMove(*url), WTFMove(*pageIdentifier), WTFMove(*lastNavigationWasAppInitiated), WTFMove(*isVisible), WTFMove(*isFocused), WTFMove(*focusOrder) } };
+ std::optional<Vector<String>> ancestorOrigins;
+ decoder >> ancestorOrigins;
+ if (!ancestorOrigins)
+ return std::nullopt;
+
+ return { { WTFMove(*identifier), WTFMove(*type), WTFMove(*frameType), WTFMove(*url), WTFMove(*pageIdentifier), WTFMove(*lastNavigationWasAppInitiated), WTFMove(*isVisible), WTFMove(*isFocused), WTFMove(*focusOrder), WTFMove(*ancestorOrigins) } };
}
using ServiceWorkerClientsMatchAllCallback = CompletionHandler<void(Vector<ServiceWorkerClientData>&&)>;
Modified: trunk/Source/WebCore/workers/service/ServiceWorkerWindowClient.h (292104 => 292105)
--- trunk/Source/WebCore/workers/service/ServiceWorkerWindowClient.h 2022-03-30 12:58:38 UTC (rev 292104)
+++ trunk/Source/WebCore/workers/service/ServiceWorkerWindowClient.h 2022-03-30 13:28:05 UTC (rev 292105)
@@ -43,7 +43,8 @@
}
VisibilityState visibilityState() const { return data().isVisible ? VisibilityState::Visible : VisibilityState::Hidden; }
- bool isFocused() const { return data().isFocused; }
+ bool focused() const { return data().isFocused; }
+ const Vector<String>& ancestorOrigins() const { return data().ancestorOrigins; }
void focus(ScriptExecutionContext&, Ref<DeferredPromise>&&);
void navigate(ScriptExecutionContext&, const String& url, Ref<DeferredPromise>&&);
Modified: trunk/Source/WebCore/workers/service/ServiceWorkerWindowClient.idl (292104 => 292105)
--- trunk/Source/WebCore/workers/service/ServiceWorkerWindowClient.idl 2022-03-30 12:58:38 UTC (rev 292104)
+++ trunk/Source/WebCore/workers/service/ServiceWorkerWindowClient.idl 2022-03-30 13:28:05 UTC (rev 292105)
@@ -30,7 +30,8 @@
InterfaceName=WindowClient,
] interface ServiceWorkerWindowClient : ServiceWorkerClient {
readonly attribute VisibilityState visibilityState;
- [ImplementedAs=isFocused] readonly attribute boolean focused;
+ readonly attribute boolean focused;
+ [SameObject] readonly attribute FrozenArray<USVString> ancestorOrigins;
[NewObject, CallWith=CurrentScriptExecutionContext] Promise<ServiceWorkerWindowClient> focus();
[NewObject, CallWith=CurrentScriptExecutionContext] Promise<ServiceWorkerWindowClient> navigate(USVString url);
Modified: trunk/Source/WebCore/workers/service/server/SWServer.cpp (292104 => 292105)
--- trunk/Source/WebCore/workers/service/server/SWServer.cpp 2022-03-30 12:58:38 UTC (rev 292104)
+++ trunk/Source/WebCore/workers/service/server/SWServer.cpp 2022-03-30 13:28:05 UTC (rev 292105)
@@ -696,7 +696,7 @@
for (auto& client : clientsForRegistrableDomain) {
auto data = ""
ASSERT(data != m_clientsById.end());
- if (data->value.lastNavigationWasAppInitiated == LastNavigationWasAppInitiated::Yes)
+ if (data->value->lastNavigationWasAppInitiated == LastNavigationWasAppInitiated::Yes)
return LastNavigationWasAppInitiated::Yes;
}
@@ -967,12 +967,12 @@
ASSERT(m_clientsById.contains(clientIdentifier));
if (data.isFocused)
data.focusOrder = ++m_focusOrder;
- m_clientsById.set(clientIdentifier, WTFMove(data));
+ m_clientsById.set(clientIdentifier, makeUniqueRef<ServiceWorkerClientData>(WTFMove(data)));
return;
}
ASSERT(!m_clientsById.contains(clientIdentifier));
- m_clientsById.add(clientIdentifier, WTFMove(data));
+ m_clientsById.add(clientIdentifier, makeUniqueRef<ServiceWorkerClientData>(WTFMove(data)));
auto& clientIdentifiersForOrigin = m_clientIdentifiersPerOrigin.ensure(clientOrigin, [] {
return Clients { };
Modified: trunk/Source/WebCore/workers/service/server/SWServer.h (292104 => 292105)
--- trunk/Source/WebCore/workers/service/server/SWServer.h 2022-03-30 12:58:38 UTC (rev 292104)
+++ trunk/Source/WebCore/workers/service/server/SWServer.h 2022-03-30 13:28:05 UTC (rev 292105)
@@ -280,7 +280,7 @@
};
HashMap<ClientOrigin, Clients> m_clientIdentifiersPerOrigin;
HashMap<ScriptExecutionContextIdentifier, WeakPtr<SWServerRegistration>> m_serviceWorkerPageIdentifierToRegistrationMap;
- HashMap<ScriptExecutionContextIdentifier, ServiceWorkerClientData> m_clientsById;
+ HashMap<ScriptExecutionContextIdentifier, UniqueRef<ServiceWorkerClientData>> m_clientsById;
HashMap<ScriptExecutionContextIdentifier, ServiceWorkerRegistrationIdentifier> m_clientToControllingRegistration;
HashMap<String, ScriptExecutionContextIdentifier> m_visibleClientIdToInternalClientIdMap;
Modified: trunk/Source/WebKit/ChangeLog (292104 => 292105)
--- trunk/Source/WebKit/ChangeLog 2022-03-30 12:58:38 UTC (rev 292104)
+++ trunk/Source/WebKit/ChangeLog 2022-03-30 13:28:05 UTC (rev 292105)
@@ -1,3 +1,13 @@
+2022-03-30 Youenn Fablet <[email protected]>
+
+ Implement ServiceWorker WindowClient.ancestorOrigins
+ https://bugs.webkit.org/show_bug.cgi?id=238441
+
+ Reviewed by Chris Dumez.
+
+ * NetworkProcess/ServiceWorker/WebSWServerConnection.cpp:
+ (WebKit::WebSWServerConnection::controlClient):
+
2022-03-30 Kimmo Kinnunen <[email protected]>
Move AuxiliaryProcess::createIPCConnectionPair to IPC::Connection
Modified: trunk/Source/WebKit/NetworkProcess/ServiceWorker/WebSWServerConnection.cpp (292104 => 292105)
--- trunk/Source/WebKit/NetworkProcess/ServiceWorker/WebSWServerConnection.cpp 2022-03-30 12:58:38 UTC (rev 292104)
+++ trunk/Source/WebKit/NetworkProcess/ServiceWorker/WebSWServerConnection.cpp 2022-03-30 13:28:05 UTC (rev 292105)
@@ -164,7 +164,7 @@
send(Messages::WebSWClientConnection::UpdateWorkerState(worker, state));
}
-void WebSWServerConnection::controlClient(ScriptExecutionContextIdentifier clientIdentifier, SWServerRegistration& registration, const ResourceRequest& request)
+void WebSWServerConnection::controlClient(const Vector<RefPtr<SecurityOrigin>>& frameAncestorOrigins, ScriptExecutionContextIdentifier clientIdentifier, SWServerRegistration& registration, const ResourceRequest& request)
{
// As per step 12 of https://w3c.github.io/ServiceWorker/#on-fetch-request-algorithm, the active service worker should be controlling the document.
// We register a temporary service worker client using the identifier provided by DocumentLoader and notify DocumentLoader about it.
@@ -175,7 +175,8 @@
unregisterServiceWorkerClient(clientIdentifier);
});
- ServiceWorkerClientData data { clientIdentifier, ServiceWorkerClientType::Window, ServiceWorkerClientFrameType::None, request.url(), { }, request.isAppInitiated() ? WebCore::LastNavigationWasAppInitiated::Yes : WebCore::LastNavigationWasAppInitiated::No };
+ auto ancestorOrigins = map(frameAncestorOrigins, [](auto& origin) { return origin->toString(); });
+ ServiceWorkerClientData data { clientIdentifier, ServiceWorkerClientType::Window, ServiceWorkerClientFrameType::None, request.url(), { }, request.isAppInitiated() ? WebCore::LastNavigationWasAppInitiated::Yes : WebCore::LastNavigationWasAppInitiated::No, false, false, 0, WTFMove(ancestorOrigins) };
registerServiceWorkerClient(SecurityOriginData { registration.key().topOrigin() }, WTFMove(data), registration.identifier(), request.httpUserAgent());
}
@@ -200,7 +201,7 @@
return nullptr;
serviceWorkerRegistrationIdentifier = registration->identifier();
- controlClient(*loader.parameters().options.clientIdentifier, *registration, request);
+ controlClient(loader.parameters().frameAncestorOrigins, *loader.parameters().options.clientIdentifier, *registration, request);
loader.setResultingClientIdentifier(loader.parameters().options.clientIdentifier->toString());
} else {
if (!loader.parameters().serviceWorkerRegistrationIdentifier)
Modified: trunk/Source/WebKit/NetworkProcess/ServiceWorker/WebSWServerConnection.h (292104 => 292105)
--- trunk/Source/WebKit/NetworkProcess/ServiceWorker/WebSWServerConnection.h 2022-03-30 12:58:38 UTC (rev 292104)
+++ trunk/Source/WebKit/NetworkProcess/ServiceWorker/WebSWServerConnection.h 2022-03-30 13:28:05 UTC (rev 292105)
@@ -129,7 +129,7 @@
void getPushPermissionState(WebCore::ServiceWorkerRegistrationIdentifier, CompletionHandler<void(Expected<uint8_t, WebCore::ExceptionData>&&)>&&);
void postMessageToServiceWorker(WebCore::ServiceWorkerIdentifier destination, WebCore::MessageWithMessagePorts&&, const WebCore::ServiceWorkerOrClientIdentifier& source);
- void controlClient(WebCore::ScriptExecutionContextIdentifier, WebCore::SWServerRegistration&, const WebCore::ResourceRequest&);
+ void controlClient(const Vector<RefPtr<WebCore::SecurityOrigin>>&, WebCore::ScriptExecutionContextIdentifier, WebCore::SWServerRegistration&, const WebCore::ResourceRequest&);
using ExceptionOrVoidCallback = CompletionHandler<void(std::optional<WebCore::ExceptionData>&&)>;
void enableNavigationPreload(WebCore::ServiceWorkerRegistrationIdentifier, ExceptionOrVoidCallback&&);