Repository navigation
Conversation
|
EWS run on previous version of this PR (hash 0776bbd) Details |
0776bbd to
ddace51
Compare
|
EWS run on previous version of this PR (hash ddace51) Details |
|
Reviewer orientation: https://gist.github.com/sergedeh/ce446ae00f89dd0a6cff975b11dc9a2a |
ddace51 to
e981b78
Compare
|
EWS run on previous version of this PR (hash e981b78) Details |
burg
left a comment
There was a problem hiding this comment.
I think we are almost there, just readability and a few more cleanups in this batch of feedback. Thanks for the patience.
| std::nullopt, | ||
| { }, | ||
| { }, | ||
| emitCreatedEvent, |
There was a problem hiding this comment.
getRealms is a second registration path that validates less than the event path. The reply calls registerDedicatedWorkerRealm(..., false); unlike the event path it does not MESSAGE_CHECK the sender's connection. A BiDi client can get a worker realm that was never announced by script.realmCreated (and later get realmDestroyed for it), and a compromised WebContent process can report forged realm tuples indefinitely without being killed.
If you make getRealms read-only by looking up worker realms already registered and skip any that aren't, so there's one source of truth. emitCreatedEvent/creationNotified bookkeeping can then come out of registerDedicatedWorkerRealm.
| }, | ||
| "test_dedicated_worker": { | ||
| "expected": { "all": { "status": ["TIMEOUT"], "bug": "webkit.org/b/282981"}} | ||
| "expected": { "all": { "status": ["FAIL"], "bug": "webkit.org/b/304300", "note": "The imported WPT expects the worker script URL instead of the serialized worker origin"}} |
There was a problem hiding this comment.
This FAIL cites b/304300, the bug this PR closes. Consider filing an upstream WPT bug so the origin/URL mismatch stays tracked after 304300 resolves.
There was a problem hiding this comment.
i added an issue in the WPT repo: web-platform-tests/wpt#63009
| if (currentOwnerRealmIterator == m_browsingContextToRealmId.end() || currentOwnerRealmIterator->value != ownerRealmIdentifier) | ||
| return std::nullopt; | ||
|
|
||
| auto ownerRealmIterator = m_activeRealms.find(ownerRealmIdentifier); |
There was a problem hiding this comment.
Between the chained inline comparisons and the many iterators, this is hard to follow. I'd prefer these checks pulled into named helper methods to keep it readable; below this it gets more familiar.
| if (activeRealmIterator != m_activeRealms.end()) { | ||
| if (emitCreatedEvent && !activeRealmIterator->value.creationNotified) { | ||
| activeRealmIterator->value.creationNotified = true; | ||
| sendRealmCreatedEvent(realmIdentifier, activeRealmIterator->value); |
There was a problem hiding this comment.
Might be better to use a stack vector as a worklist so the code that actually sends the event and updates bookkeeping lives in one place.
| AutomationInstrumentation::scriptDedicatedWorkerRealmDestroyed(m_identifier, m_automationOwner->frameIdentifier, m_automationOwner->documentIdentifier); | ||
| } | ||
|
|
||
| if (m_wasTerminatedBeforeExecutionReady) { |
There was a problem hiding this comment.
It'd help to group the automation-related flags into an m_automationStateFlags bitset (or similar), to make clear they're instrumentation state and not determinative of how workers are implemented.
https://bugs.webkit.org/show_bug.cgi?id=304300 Reviewed by NOBODY (OOPS!). Report script.realmCreated and script.realmDestroyed for dedicated workers directly owned by automated top-level documents. A dedicated worker becomes observable only after its global scope is ready. Capture SecurityOriginData when the scope is created, then post readiness to the worker object's ScriptExecutionContext. Retain WorkerMessagingProxy while the startup callback is stored or queued, and clear the callback on startup failure. Navigation can replace the owner document while readiness or destruction is in flight. Capture the owner frame and document at worker startup, require that owner to remain current before reporting creation, and retain an accepted association until destruction. When the captured owner remains valid, termination before readiness produces one ordered realmCreated and realmDestroyed pair when the readiness callback arrives. Realm identifiers use process-local counters. Generating worker identifiers in UIProcess could therefore collide with window identifiers from WebProcess. Generate worker identifiers in WebProcess instead and qualify every realm identifier with its ProcessIdentifier. Serialize both components in IPC and in protocol realm strings. Validate lifecycle messages against the sending connection, frame process, automation-controlled page, current owner realm, and cached worker ownership. Tie worker state to its exact owner realm so delayed destruction for an old realm cannot remove its replacement or the replacement's workers. Treat unknown late destruction as an idempotent no-op. BidiScriptAgent stores worker metadata by realm identifier, applies session and context event filtering, and replays active realms to new subscribers. It removes worker metadata during worker, owner-realm, or browsing-context teardown, including metadata whose active realm is already gone. Iframe-owned and nested dedicated workers remain follow-up work because their owner realms are not yet registered. script.getRealms does not yet enumerate dedicated-worker realms. The imported realmCreated WPT remains expected-failing because it expects the full worker script URL instead of the serialized worker origin. The dedicated worker realmDestroyed test and navigation lifecycle tests pass. * Source/WebCore/automation/AutomationInstrumentation.cpp: * Source/WebCore/automation/AutomationInstrumentation.h: * Source/WebCore/workers/WorkerInspectorProxy.cpp: * Source/WebCore/workers/WorkerInspectorProxy.h: * Source/WebCore/workers/WorkerMessagingProxy.cpp: * Source/WebCore/workers/WorkerMessagingProxy.h: * Source/WebCore/workers/WorkerOrWorkletThread.cpp: * Source/WebCore/workers/WorkerOrWorkletThread.h: * Source/WebKit/Scripts/webkit/messages.py: * Source/WebKit/Scripts/webkit/tests/MessageArgumentDescriptions.cpp: * Source/WebKit/Shared/IdentifierTypes.h: * Source/WebKit/Shared/ProcessQualified.serialization.in: * Source/WebKit/UIProcess/Automation/BidiScriptAgent.cpp: * Source/WebKit/UIProcess/Automation/BidiScriptAgent.h: * Source/WebKit/UIProcess/Automation/WebAutomationSession.cpp: * Source/WebKit/UIProcess/Automation/WebAutomationSession.h: * Source/WebKit/UIProcess/Automation/WebAutomationSession.messages.in: * Source/WebKit/UIProcess/Automation/protocol/BidiScript.json: * Source/WebKit/WebProcess/Automation/WebAutomationSessionProxy.cpp: * Source/WebKit/WebProcess/Automation/WebAutomationSessionProxy.h: * WebDriverTests/TestExpectations.json:
e981b78 to
d4bd029
Compare
|
EWS run on previous version of this PR (hash d4bd029) Details |
d4bd029 to
0b405dd
Compare
|
EWS run on previous version of this PR (hash 0b405dd) Details |
https://bugs.webkit.org/show_bug.cgi?id=304300 Reviewed by NOBODY (OOPS!). Teach script.getRealms to enumerate execution-ready dedicated workers that are owned directly by automated top-level documents. Keep lifecycle notifications as the only worker-realm registration path. Use the WebProcess lifecycle registry to report candidate worker and owner identities after verifying that the owner document and owner realm are still current. The snapshot contains identity only; it neither supplies realm metadata nor creates UIProcess state. In UIProcess, treat lifecycle registration as the source of truth. Enumerate each controlled main page once, retain the page and its main-frame process across the asynchronous reply, and then revalidate the context-to-page mapping, owner frame, process, and process-qualified worker and owner realm identifiers. Return only candidates that exactly match an already registered dedicated-worker realm, and deduplicate repeated candidates. Enumeration never registers a realm or changes lifecycle bookkeeping. Extract named helpers for current owner-window validation and exact dedicated worker matching. Treat an identical duplicate lifecycle notification as an idempotent no-op after validating its ownership, so it cannot emit a second creation event or replace the registered origin. Group WorkerInspectorProxy's automation state in an OptionSet. Keep the owner frame, process-qualified document identifier, and eventual origin together in AutomationOwnerData while preserving the ordered create/destroy pair for a worker that terminates before becoming execution-ready. Apply the context and realm-type filters before serializing protocol RealmInfo values. Serialize origin and owner information from the registered lifecycle RealmInfo. Dedicated-worker realms have no browsing context. Extend the WebKitAutomationSession request-session test with a local dedicated worker and a second controlled browsing context. The test verifies type and context filtering, non-empty stable realm identifiers, serialized origin, owner linkage, unfiltered enumeration without duplicates, and removal after the owner navigates to a new document. Imported WPT files are unchanged. The current upstream realmCreated worker test expects the full worker script URL rather than the serialized worker origin. Keep that test expected-failing with an explanatory note, but remove b/304300 from the expectation because this patch resolves the WebKit bug. Iframe-owned and nested dedicated workers, shared workers, service workers, worklets, and worker-realm script execution remain follow-up work. * Source/WebCore/workers/WorkerInspectorProxy.cpp: (WebCore::WorkerInspectorProxy::automationOwnerData): (WebCore::WorkerInspectorProxy::automationOwnerIsCurrent): (WebCore::WorkerInspectorProxy::workerStarted): (WebCore::WorkerInspectorProxy::workerBecameExecutionReady): (WebCore::WorkerInspectorProxy::workerTerminated): * Source/WebCore/workers/WorkerInspectorProxy.h: * Source/WebKit/UIProcess/Automation/BidiScriptAgent.cpp: (WebKit::BidiScriptAgent::getRealms): (WebKit::BidiScriptAgent::createProtocolRealmInfo): (WebKit::BidiScriptAgent::DedicatedWorkerRealmInfo::matches): (WebKit::BidiScriptAgent::isCurrentWindowRealm): (WebKit::BidiScriptAgent::findRegisteredDedicatedWorkerRealm): (WebKit::BidiScriptAgent::registerDedicatedWorkerRealm): (WebKit::BidiScriptAgent::processRealmsForPagesAsync): (WebKit::BidiScriptAgent::collectExecutionReadyFrameRealms): (WebKit::BidiScriptAgent::emitEventsForActiveRealms): * Source/WebKit/UIProcess/Automation/BidiScriptAgent.h: * Source/WebKit/UIProcess/Automation/WebAutomationSession.cpp: (WebKit::WebAutomationSession::scriptDedicatedWorkerRealmCreated): * Source/WebKit/WebProcess/Automation/WebAutomationSessionProxy.cpp: (WebKit::WebAutomationSessionProxy::getDedicatedWorkerRealms): * Source/WebKit/WebProcess/Automation/WebAutomationSessionProxy.h: * Source/WebKit/WebProcess/Automation/WebAutomationSessionProxy.messages.in: * Tools/TestWebKitAPI/Tests/WebKit/WKWebView/glib/TestAutomationSession.cpp: (dedicatedWorkerRealmServerCallback): (AutomationTest::receivedMessage): (AutomationTest::browsingContextHandleFromLastResponse): (AutomationTest::loadPageAndWaitForTitle): (AutomationTest::getRealms): (verifyDedicatedWorkerRealmEnumeration): (testAutomationSessionRequestSession): (beforeAll): (afterAll): * WebDriverTests/TestExpectations.json:
0b405dd to
768b1f6
Compare
|
EWS run on current version of this PR (hash 768b1f6) Details |
burg
left a comment
There was a problem hiding this comment.
r=me, it's just smaller issues now. Please rebase and I'll set merge-queue. Thanks.
| }, | ||
| "test_dedicated_worker": { | ||
| "expected": { "all": { "status": ["TIMEOUT"], "bug": "webkit.org/b/282981"}} | ||
| "expected": { "all": { "status": ["FAIL"], "note": "Upstream WPT compares RealmInfo.origin with the full worker script URL; WebDriver BiDi requires the serialized worker origin."}} |
There was a problem hiding this comment.
Thanks for filing web-platform-tests/wpt#63009. Please put it in the bug field here. Right now this entry has only a note and no bug at all, so nothing will prompt us to revisit it when upstream fixes the test.
|
|
||
| RefPtr session = protectedThis->m_session.get(); | ||
| if (!session) | ||
| return; |
There was a problem hiding this comment.
This drops callback without replying, so the client never gets a response to script.getRealms if the session goes away mid-command. Please reply with an error here instead.
| return; | ||
| } | ||
|
|
||
| Ref workerProcess = currentPage->legacyMainFrameProcess(); |
There was a problem hiding this comment.
Since the reply is only used to filter realms that are already registered, it can only hide realms, never add them. Is the round trip needed? Filtering m_dedicatedWorkerRealms by owner browsing context would avoid an IPC per page and the legacyMainFrameProcess() dependency, which the iframe follow-ups will have to undo anyway. If there's an ordering case it covers, a comment explaining it would help.
| #if ENABLE(WEBDRIVER_BIDI) | ||
| auto WorkerInspectorProxy::automationOwnerData() const -> std::optional<AutomationOwnerData> | ||
| { | ||
| // FIXME: Support dedicated workers owned by iframes and other workers once |
🛠 🧪 jsc-debug-arm64
[WebDriver][BiDi] Enumerate dedicated worker realms in script.getRealms
https://bugs.webkit.org/show_bug.cgi?id=304300
Reviewed by NOBODY (OOPS!).
Teach script.getRealms to enumerate execution-ready dedicated workers that
are owned directly by automated top-level documents.
Keep lifecycle notifications as the only worker-realm registration path. Use
the WebProcess lifecycle registry to report candidate worker and owner
identities after verifying that the owner document and owner realm are still
current. The snapshot contains identity only; it neither supplies realm
metadata nor creates UIProcess state.
In UIProcess, treat lifecycle registration as the source of truth. Enumerate
each controlled main page once, retain the page and its main-frame process
across the asynchronous reply, and then revalidate the context-to-page
mapping, owner frame, process, and process-qualified worker and owner realm
identifiers. Return only candidates that exactly match an already registered
dedicated-worker realm, and deduplicate repeated candidates. Enumeration never
registers a realm or changes lifecycle bookkeeping.
Extract named helpers for current owner-window validation and exact dedicated
worker matching. Treat an identical duplicate lifecycle notification as an
idempotent no-op after validating its ownership, so it cannot emit a second
creation event or replace the registered origin.
Group WorkerInspectorProxy's automation state in an OptionSet. Keep the owner
frame, process-qualified document identifier, and eventual origin together in
AutomationOwnerData while preserving the ordered create/destroy pair for a
worker that terminates before becoming execution-ready.
Apply the context and realm-type filters before serializing protocol
RealmInfo values. Serialize origin and owner information from the registered
lifecycle RealmInfo. Dedicated-worker realms have no browsing context.
Extend the WebKitAutomationSession request-session test with a local dedicated
worker and a second controlled browsing context. The test verifies type and
context filtering, non-empty stable realm identifiers, serialized origin,
owner linkage, unfiltered enumeration without duplicates, and removal after
the owner navigates to a new document.
Imported WPT files are unchanged. The current upstream realmCreated worker
test expects the full worker script URL rather than the serialized worker
origin. Keep that test expected-failing with an explanatory note, but remove
b/304300 from the expectation because this patch resolves the WebKit bug.
Iframe-owned and nested dedicated workers, shared workers, service workers,
worklets, and worker-realm script execution remain follow-up work.
(WebCore::WorkerInspectorProxy::automationOwnerData):
(WebCore::WorkerInspectorProxy::automationOwnerIsCurrent):
(WebCore::WorkerInspectorProxy::workerStarted):
(WebCore::WorkerInspectorProxy::workerBecameExecutionReady):
(WebCore::WorkerInspectorProxy::workerTerminated):
(WebKit::BidiScriptAgent::getRealms):
(WebKit::BidiScriptAgent::createProtocolRealmInfo):
(WebKit::BidiScriptAgent::DedicatedWorkerRealmInfo::matches):
(WebKit::BidiScriptAgent::isCurrentWindowRealm):
(WebKit::BidiScriptAgent::findRegisteredDedicatedWorkerRealm):
(WebKit::BidiScriptAgent::registerDedicatedWorkerRealm):
(WebKit::BidiScriptAgent::processRealmsForPagesAsync):
(WebKit::BidiScriptAgent::collectExecutionReadyFrameRealms):
(WebKit::BidiScriptAgent::emitEventsForActiveRealms):
(WebKit::WebAutomationSession::scriptDedicatedWorkerRealmCreated):
(WebKit::WebAutomationSessionProxy::getDedicatedWorkerRealms):
(dedicatedWorkerRealmServerCallback):
(AutomationTest::receivedMessage):
(AutomationTest::browsingContextHandleFromLastResponse):
(AutomationTest::loadPageAndWaitForTitle):
(AutomationTest::getRealms):
(verifyDedicatedWorkerRealmEnumeration):
(testAutomationSessionRequestSession):
(beforeAll):
(afterAll):
768b1f6
🛠 playstation