Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Raise "no such window" error in "dispatching actions" when browsing context (navigable) does no longer exist #1861

Merged

Conversation

whimboo
Copy link
Contributor

@whimboo whimboo commented Nov 27, 2024

Basically any single action could cause the current (top-level) browsing context to get closed eg. clicking or pressing a key for an element that calls window.close(). The following action in the sequence needs to fail with a no such window error.

I'm going to add tests for classic and BiDi over on https://bugzilla.mozilla.org/show_bug.cgi?id=1932916.


Preview | Diff

Copy link
Contributor

@OrKoN OrKoN left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is there a reason for doing it in the tick action loop and not in https://pr-preview.s3.amazonaws.com/whimboo/webdriver/pull/1861.html#dfn-dispatch-actions ?

@whimboo
Copy link
Contributor Author

whimboo commented Nov 27, 2024

Is there a reason for doing it in the tick action loop and not in https://pr-preview.s3.amazonaws.com/whimboo/webdriver/pull/1861.html#dfn-dispatch-actions ?

That is run only once at the beginning but doesn't cover a discarded navigable due to a single action like key press or mouse click as described in my initial comment.

@OrKoN
Copy link
Contributor

OrKoN commented Nov 27, 2024

@whimboo right, but in our implementation, for example, dispatch does not wait for the effects to propagate and all actions are dispatched at once so this change is practically no-op (same as checking the navigable existence before all actions).

@OrKoN
Copy link
Contributor

OrKoN commented Nov 27, 2024

@whimboo
Copy link
Contributor Author

whimboo commented Nov 27, 2024

@whimboo right, but in our implementation, for example, dispatch does not wait for the effects to propagate and all actions are dispatched at once so this change is practically no-op (same as checking the navigable existence before all actions).

I think that we should take a view from the users perspective and not how individual browsers have it currently implemented or not.

What should be an appropriate response for such a situation? Should actions only be performed up to the action that caused the navigable to close, and all the rest is ignored? I assume that this is what you currently have. Safari's implementation currently fails as well with no such window error at the moment. So it's Chrome behaving differently.

Perhaps, checking it in https://pr-preview.s3.amazonaws.com/whimboo/webdriver/pull/1861.html#dfn-dispatch-actions-inner before dispatch tick actions is called would be better.

I understand the point regarding a "pointerMove" action with a duration not equal to 0 triggering the window to close, for example, on the first tick. If the platform handles this directly, we indeed have no way to intercept it. Perhaps that’s the approach we should take.

@OrKoN
Copy link
Contributor

OrKoN commented Nov 27, 2024

I think we want to align here we should specify that after dispatching each of the tick actions implementations should wait until the results of the action have propagated (similarly how it is done for different ticks I believe). The current specification text only says that actions from one tick have to be dispatched at once.

@OrKoN
Copy link
Contributor

OrKoN commented Nov 27, 2024

Should actions only be performed up to the action that caused the navigable to close, and all the rest is ignored?

IIUC the current spec says that actions (in a single tick) have to be dispatched at once, that means if an action closes the navigable, the rest of the actions is either ignored or applies to the remaining content (I think the browsing context is not necessarily a top-level one in this spec).

For example, in this test page:

<script>
  var iframe = document.createElement('iframe');
  var sameOriginURL = 'iframe-navigations.html';
  window.onmessage = () => {
    iframe.remove();
  }
  window.addEventListener('mousedown', e => console.log('mousedown'), true);
  window.addEventListener('mouseup', e => console.log('mouseup'), true);
</script>
<header>
  <button onclick="iframe.src = sameOriginURL; document.body.append(iframe)">
    Append iframe with a same-origin URL
  </button>
  <button onmousedown="parent.postMessage('test');">
    Post message
  </button>
</header>

when testing in the browser manually, the mouseup event seems to be still dispatched even if the iframe is gone. So I think the user action here succeeds but the equivalent WebDriver gesture would be failing (which might be fine).

@whimboo whimboo force-pushed the actions_check_browsing_context_in_dispatch branch from 9d9404f to c58363c Compare November 27, 2024 15:48
@jgraham
Copy link
Member

jgraham commented Nov 28, 2024

I don't quite understand your proposal @OrKoN.

We can't wait for actions in each tick; the entire model is based around wanting gestures like pinch to work; in that case the two pointerMove actions running concurrently is the entire point.

I think the way the spec is currently written it's clear that once the target browsing context is gone, the action should fail.

Assuming we adopt the proposal to route all actions via the top level browsing context, that continues to be true for the top-level browsing context. I agree it isn't necessarily true for iframes in that model; we'd only need to fail if we were trying to resolve coordinates relative to a now-missing iframe (or an element in that iframe).

However I think this change is ~correct per the current spec and we need to do more work in #1847 to make things work correctly with the dispatch-via-top-level proposal. In particular I think we need to be explicit about the expected event flow; the change there is making the spec inconsistent about where events are actually dispatched. I also think we should consider adding the ability to explicitly specify the context used for each action in that model; if the action chain can interact with multiple documents across multiple iframes, we shouldn't just have a single global context as the target.

@OrKoN
Copy link
Contributor

OrKoN commented Nov 28, 2024

@jgraham I believe the current version is fine but the previous one was confusing precisely due to the We can't wait for actions in each tick as there would be no way for implementations to reliably detect if the navigable got destroyed as the result of dispatching tick actions.

@whimboo
Copy link
Contributor Author

whimboo commented Nov 28, 2024

Thank you for the review! I'm going to merge this PR now. I don’t think we need feedback from Safari (CC @gsnedders) since it already exhibits the expected behavior introduced by this PR.

@whimboo whimboo changed the title Raise "no such window" error in "dispatch tick actions" when browsing context (navigable) does no longer exist Raise "no such window" error in "dispatching actions" when browsing context (navigable) does no longer exist Nov 28, 2024
@whimboo whimboo merged commit 0ac18fa into w3c:master Nov 28, 2024
2 checks passed
@whimboo whimboo deleted the actions_check_browsing_context_in_dispatch branch November 28, 2024 12:51
github-actions bot added a commit that referenced this pull request Nov 28, 2024
…ontext (navigable) does no longer exist (#1861)

SHA: 0ac18fa
Reason: push, by whimboo

Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com>
github-actions bot added a commit to ZRDKPoWeR/webdriver that referenced this pull request Nov 28, 2024
…ontext (navigable) does no longer exist (w3c#1861)

SHA: 0ac18fa
Reason: push, by pull[bot]

Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com>
github-actions bot added a commit to soloinovator/webdriver that referenced this pull request Nov 28, 2024
…ontext (navigable) does no longer exist (w3c#1861)

SHA: 0ac18fa
Reason: push, by pull[bot]

Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com>
github-actions bot added a commit to xjc90s/webdriver that referenced this pull request Nov 29, 2024
…ontext (navigable) does no longer exist (w3c#1861)

SHA: 0ac18fa
Reason: push, by pull[bot]

Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants