A press that only brings the window to the front draws nothing

From the development repository at 62e0967.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
This commit is contained in:
ackandClaude Opus 4.8 committed 2026-10-11 19:32:13 +02:00
1 parent 2de843143d
commit 51e66db9a1
5 files changed
+78 -10

No files matched your search

+41 -6
View File
@@ -570,12 +570,17 @@ class EndToEndTest(unittest.TestCase):
cls.stop()
raise
def address(self, name, join=None):
def address(self, name, join=None, focus_settle=False):
"""The Kokkoja address of a participant's own local program, with
its token, and an invitation to join if given."""
its token, and an invitation to join if given. By default it
carries `?no_focus_settle`, which turns off the focusing-click
rule: a driven browser gains focus on the first draw after a load
or tab switch, which the rule would take for a focusing click
(see test_a_focusing_click_draws_nothing, which keeps it on)."""
base, token = self.programs[name]
query = "" if focus_settle else "?no_focus_settle"
joining = "" if join is None else f"&join={urllib.parse.quote(join, safe='')}"
return f"{base}#token={token}{joining}"
return f"{base}{query}#token={token}{joining}"
@classmethod
def start(cls, command):
@@ -708,7 +713,7 @@ class EndToEndTest(unittest.TestCase):
# filled in, says where the notebooks are, and offers the installed
# program to anyone who has it.
guest_tab = firefox.new_tab()
firefox.go(link)
firefox.go(link.replace("#", "?no_focus_settle#", 1))
self.wait_until_true(lambda: firefox.run("return document.getElementById('invitation_entry').value;"),
lambda v: v and v.startswith("ws://"), "the invitation in the start screen")
self.assertEqual(firefox.run("return document.getElementById('invitation_entry').value;"),
@@ -1063,6 +1068,33 @@ class EndToEndTest(unittest.TestCase):
firefox.switch_to(host_tab)
firefox.go("about:blank")
def test_a_focusing_click_draws_nothing(self):
"""Andy, 2026-10-11: clicking the page to bring the browser to the
front from the terminal, with the Pen chosen, left a stray dot. A
press within 250 ms of the window gaining focus draws nothing.
(The window focus is dispatched here: the test harness raises the
real window on the first draw after a tab switch, so a two-tab
test cannot feign the terminal case; this does it in one tab.)"""
firefox = self.firefox
firefox.go(self.address("Late", focus_settle=True))
self.enter_name("Focuser", "start_session")
self.wait_until(lambda s: s["page"]["number"] == 1, "the page")
strokes = lambda: len(self.state()["layers"].get("Focuser", []))
# The window gains focus, then a press right after: nothing drawn.
firefox.run("window.dispatchEvent(new Event('focus'));")
firefox.drag("#page", 200, 300, 400, 320)
time.sleep(0.4)
self.assertEqual(strokes(), 0)
self.assertIn("refused: it brought the window to the front",
firefox.run("return window.kokkoja.logText();"))
# Once the window has been focused a while, a stroke draws.
firefox.run("window.dispatchEvent(new Event('focus'));")
time.sleep(0.4)
firefox.drag("#page", 200, 400, 400, 420)
self.wait_until(lambda s: len(s["layers"].get("Focuser", [])) == 1,
"a stroke once the window had been focused a while")
firefox.go("about:blank")
def test_undo(self):
"""Andy, 2026-10-11: one's latest gesture is taken back, then the
one before, by the Undo button, Ctrl+Z, or two quick taps of the
@@ -2024,8 +2056,11 @@ class EndToEndTest(unittest.TestCase):
self.assertEqual(len(self.kept_pages("Teacher notebook")), 2)
# A new session in the same notebook: the page the last session
# left there is kept, without anyone having asked.
firefox.go(self.programs["Teacher"][0])
# left there is kept, without anyone having asked. (The param
# that turns off the focusing-click rule, as address() adds, so
# that drawing after this navigation is not taken for a focusing
# click by the driven browser.)
firefox.go(self.programs["Teacher"][0] + "?no_focus_settle")
firefox.run("location.reload();")
time.sleep(0.5)
self.enter_name("Teacher", "start_session")