browser_touch_event_should_bubble.js (1450B)
1 /* Any copyright is dedicated to the Public Domain. 2 http://creativecommons.org/publicdomain/zero/1.0/ */ 3 4 "use strict"; 5 6 // Test that simulated touch events bubble. 7 8 const TEST_URL = `${URL_ROOT}touch_event_bubbles.html`; 9 10 addRDMTask(TEST_URL, async function ({ ui }) { 11 info("Toggling on touch simulation."); 12 reloadOnTouchChange(true); 13 await toggleTouchSimulation(ui); 14 15 info("Test that touch event bubbles."); 16 await SpecialPowers.spawn(ui.getViewportBrowser(), [], async function () { 17 const outerDiv = content.document.getElementById("outer"); 18 const span = content.document.querySelector("span"); 19 20 outerDiv.addEventListener("touchstart", () => { 21 span.style["background-color"] = "green"; // rgb(0, 128, 0) 22 }); 23 24 const touchStartPromise = ContentTaskUtils.waitForEvent(span, "touchstart"); 25 await EventUtils.synthesizeMouseAtCenter( 26 span, 27 { type: "mousedown", isSynthesized: false }, 28 content 29 ); 30 await touchStartPromise; 31 32 const bg = content 33 .getComputedStyle(span) 34 .getPropertyValue("background-color"); 35 36 is( 37 bg, 38 "rgb(0, 128, 0)", 39 `span's background color should be rgb(0, 128, 0): got ${bg}` 40 ); 41 42 await EventUtils.synthesizeMouseAtCenter( 43 span, 44 { type: "mouseup", isSynthesized: false }, 45 content 46 ); 47 }); 48 49 info("Toggling off touch simulation."); 50 await toggleTouchSimulation(ui); 51 reloadOnTouchChange(false); 52 });