[WebDriver:Release Actions] Fix wrong comments and Improve codestyle (#37585)

[Spec](https://w3c.github.io/webdriver/#release-actions)
Testing: No behaviour change.

Signed-off-by: Euclid Ye <yezhizhenjiakang@gmail.com>
This commit is contained in:
Euclid Ye 2025-06-22 02:31:19 +08:00 committed by GitHub
parent d2a688d798
commit 3feec90528
No known key found for this signature in database
GPG key ID: B5690EEEBB952194

View file

@ -218,8 +218,6 @@ impl WebDriverSession {
} }
} }
/// The `Handler` for the WebDriver server.
/// Currently, only 1 session is supported.
struct Handler { struct Handler {
/// The threaded receiver on which we can block for a load-status. /// The threaded receiver on which we can block for a load-status.
/// It will receive messages sent on the load_status_sender, /// It will receive messages sent on the load_status_sender,
@ -1751,22 +1749,21 @@ impl Handler {
self.verify_browsing_context_is_open(session.browsing_context_id)?; self.verify_browsing_context_is_open(session.browsing_context_id)?;
// TODO: Step 2. User prompts. No user prompt implemented yet. // TODO: Step 2. User prompts. No user prompt implemented yet.
// TODO: Step 3. Skip for now because webdriver holds only one session.
// Skip: Step 3. We don't support "browsing context input state map" yet.
// TODO: Step 4. Actions options are not used yet. // TODO: Step 4. Actions options are not used yet.
// TODO: Step 5. Skip for now because webdriver holds only one session.
// Step 5. Not needed because "In a session that is only a HTTP session
// only one command can run at a time, so this will never block."
// Step 6. Let undo actions be input cancel list in reverse order. // Step 6. Let undo actions be input cancel list in reverse order.
let mut input_cancel_list = session.input_cancel_list.borrow_mut(); let mut input_cancel_list = session.input_cancel_list.borrow_mut();
let undo_actions: ActionsByTick = input_cancel_list let undo_actions: ActionsByTick = input_cancel_list
.drain(..) .drain(..)
.rev() .rev()
.map(|action| { .map(|(id, action_item)| HashMap::from([(id, action_item)]))
let mut map = HashMap::new();
map.insert(action.0, action.1);
map
})
.collect(); .collect();
// Step 7. Dispatch undo actions with current browsing context. // Step 7. Dispatch undo actions with current browsing context.
if let Err(err) = self.dispatch_actions(undo_actions, session.browsing_context_id) { if let Err(err) = self.dispatch_actions(undo_actions, session.browsing_context_id) {
return Err(WebDriverError::new(err, "Failed to dispatch undo actions")); return Err(WebDriverError::new(err, "Failed to dispatch undo actions"));