web-platform-tests / wpt

Test suites for Web platform specs — including WHATWG, W3C, and others
https://web-platform-tests.org/
Other
4.94k stars 3.08k forks source link

Specify what `.pointerMove(0, 0, {origin: foo})` supposed to do #26266

Open saschanaz opened 3 years ago

saschanaz commented 3 years ago

Gecko interprets the zero coordination as the center of the foo element while Blink seems to do it differently.

This difference has been quite painful to me, so it would be great if we document this. Currently testdriver.md does not say anything about it.

stephenmcgruer commented 3 years ago

cc @LanWei22

stephenmcgruer commented 3 years ago

.pointerMove is part of the testdriver-actions.js helper library I think - is this difference coming from that wrapper, or is there an actual different in the testdriver.js or webdriver layers?

There are various tests in webdriver/ that call pointer_move, do we know if any of them have differing results on Chrome/Firefox that show this off?

jgraham commented 3 years ago

The WebDriver spec is the authority here: https://w3c.github.io/webdriver/#pointer-actions

When required to dispatch a pointerMove action 
[...]
An object that represents a web element

        Let element be equal to the result of trying to get a known connected element with argument origin.

        Let x element and y element be the result of calculating the in-view center point of element.

        Let x equal x element + x offset, and y equal y element + y offset. 

So I'm pretty sure Gecko's behaviour is correct unless there's some weirdness with the element not being in view.

stephenmcgruer commented 3 years ago

At a stab, https://wpt.fyi/results/webdriver/tests/perform_actions/pointer_origin.py?label=experimental&label=master&aligned would probably be the right test if a test existed, and its 10/10 in Chrome and Firefox.

@saschanaz - can you explain what you've seen in terms of 'Blink seems to do it differently' ?

saschanaz commented 3 years ago

Given this DOM tree:

<div class="test">
  <span id="foo">foo</span><br>
  <input id="input"><br>
  <span id="bar">bar</span>
</div>

and this script:

      await new test_driver.Actions()
        .pointerMove(0, 0, {origin: foo})
        .pointerDown()
        .pointerMove(0, 0, {origin: input})
        .pointerMove(0, 0, {origin: bar})
        .pointerUp()
        .send();

I see Gecko moves from the center of the foo to the center of the bar (as expected) but Chrome moves from the start of the foo to somewhere beyond bar.

stephenmcgruer commented 3 years ago

I may be holding it wrong, but I don't visually see a difference for me (Linux, Chrome 88.0.4292.2 dev and Firefox 84.0a1):

$ cat css/test.html 
<!doctype HTML>
<meta charset="utf8">
<title>My Test</title>
<script src="/resources/testharness.js"></script>
<script src="/resources/testharnessreport.js"></script>
<script src="/resources/testdriver.js"></script>
<script src="/resources/testdriver-actions.js"></script>
<script src="/resources/testdriver-vendor.js"></script>

<div class="test">
  <span id="foo">foo</span><br>
  <input id="input"><br>
  <span id="bar">bar</span>
</div>

<script>
promise_test(async t => {
  await new test_driver.Actions()
    .pointerMove(0, 0, {origin: foo})
    .pointerDown()
    .pointerMove(0, 0, {origin: input})
    .pointerMove(0, 0, {origin: bar})
    .pointerUp()
    .send();
}, "My test");
</script>

./wpt run --log-mach=- --channel=dev chrome css/test.html

Screenshot 2020-10-23 at 15 53 49

./wpt run --log-mach=- --no-headless --channel=nightly --binary=$HOME/firefox-nightly/firefox firefox css/test.html

Screenshot 2020-10-23 at 15 55 57

saschanaz commented 3 years ago

That's weird, could it be Windows-only thing? 🤔

I just uploaded the full patch so you can access it here: https://hg.mozilla.org/try/rev/1bbb16e55d5e8b65b74767c885b140941a274827 (should be visible soon)

stephenmcgruer commented 3 years ago

Assuming https://github.com/web-platform-tests/wpt/pull/26278 is the patch, it looks like it passed 22/22 on Chrome + Safari? Can this issue be closed then?

saschanaz commented 3 years ago

It still fails hard on my Windows machine, using Chrome 88.0.4302.0 dev channel.

image

Which suggests this is a Windows-specific Chrome bug. Could someone from Google confirm this?

Anyhow, I think we should still specify it, at least a link to webdriver spec.

stephenmcgruer commented 3 years ago

Which suggests this is a Windows-specific Chrome bug. Could someone from Google confirm this?

I am unable to reproduce on Windows, using Chrome Dev 88.0.4315.5 :(. html/semantics/forms/the-input-element/selection-pointer.html passes all subtests.

Anyhow, I think we should still specify it, at least a link to webdriver spec.

Seems reasonable, happy to review a doc PR to wherever seems reasonable (code comment, or https://web-platform-tests.org/writing-tests/testdriver.html ?)