From 0695aa49fe0b7ae2a87fddedab958efb62dd98f9 Mon Sep 17 00:00:00 2001 From: Masayuki Nakano Date: Tue, 23 Jan 2024 11:35:22 +0000 Subject: [PATCH] Bug 1781618 - Make `test_bug620906.html` try to click scrollbar multiple times r=smaug Differential Revision: https://phabricator.services.mozilla.com/D199303 --- editor/libeditor/tests/mochitest.toml | 6 ++-- ...lbar_toggled_designMode_on_mousedown.html} | 34 +++++++++++++------ 2 files changed, 27 insertions(+), 13 deletions(-) rename editor/libeditor/tests/{test_bug620906.html => test_doc_scrollbar_toggled_designMode_on_mousedown.html} (58%) diff --git a/editor/libeditor/tests/mochitest.toml b/editor/libeditor/tests/mochitest.toml index c7fe6a06f238..2d2348077f69 100644 --- a/editor/libeditor/tests/mochitest.toml +++ b/editor/libeditor/tests/mochitest.toml @@ -165,9 +165,6 @@ support-files = [ ["test_bug612447.html"] -["test_bug620906.html"] -skip-if = ["os == 'android'"] #TIMED_OUT - ["test_bug622371.html"] ["test_bug625452.html"] @@ -430,6 +427,9 @@ skip-if = ["os == 'android'"] #Bug 1575739 ["test_defaultParagraphSeparatorBR_between_blocks.html"] +["test_doc_scrollbar_toggled_designMode_on_mousedown.html"] +skip-if = ["os == 'android'"] # Needs interaction with the scrollbar + ["test_dom_input_event_on_htmleditor.html"] ["test_dom_input_event_on_texteditor.html"] diff --git a/editor/libeditor/tests/test_bug620906.html b/editor/libeditor/tests/test_doc_scrollbar_toggled_designMode_on_mousedown.html similarity index 58% rename from editor/libeditor/tests/test_bug620906.html rename to editor/libeditor/tests/test_doc_scrollbar_toggled_designMode_on_mousedown.html index e5a7138e18e6..860e87424a1a 100644 --- a/editor/libeditor/tests/test_bug620906.html +++ b/editor/libeditor/tests/test_doc_scrollbar_toggled_designMode_on_mousedown.html @@ -29,19 +29,33 @@ https://bugzilla.mozilla.org/show_bug.cgi?id=620906 /** Test for Bug 620906 **/ SimpleTest.waitForExplicitFinish(); -addLoadEvent(function() { - var iframe = document.querySelector("iframe"); +SimpleTest.waitForFocus(async () => { + const iframe = document.querySelector("iframe"); is(iframe.contentWindow.scrollY, 0, "Sanity check"); - var rect = iframe.getBoundingClientRect(); - setTimeout(function() { - var onscroll = function() { - iframe.contentWindow.removeEventListener("scroll", onscroll); + const rect = iframe.getBoundingClientRect(); + const waitForTick = () => { + return new Promise(resolve => requestAnimationFrame( + () => requestAnimationFrame(resolve)) + ); + }; + await waitForTick(); + let scrollEventFired = false; + iframe.contentWindow.addEventListener("scroll", () => { + scrollEventFired = true; + }, {once: true}); + for (let i = 0; i < 10; i++) { + synthesizeMouse(iframe, rect.width - 4, rect.height / 2, { type: "mousemove" }); + synthesizeMouse(iframe, rect.width - 5, rect.height / 2, { type: "mousemove" }); + synthesizeMouse(iframe, rect.width - 5, rect.height / 2, {}); + await waitForTick(); + if (scrollEventFired) { isnot(iframe.contentWindow.scrollY, 0, "The scrollbar should work"); SimpleTest.finish(); - }; - iframe.contentWindow.addEventListener("scroll", onscroll); - synthesizeMouse(iframe, rect.width - 5, rect.height / 2, {}); - }, 0); + return; + } + } + ok(false, "The scrollbar didn't work"); + SimpleTest.finish(); });