browser_max_touchpoints.js (4084B)
1 /* Any copyright is dedicated to the Public Domain. 2 http://creativecommons.org/publicdomain/zero/1.0/ */ 3 4 "use strict"; 5 6 // Verify that maxTouchPoints is updated when touch simulation is toggled. 7 8 // TODO: This test should also check that maxTouchPoints is set properly on the iframe. 9 // This is currently not working and should be worked on in Bug 1706066. 10 11 const TEST_DOCUMENT = `doc_with_remote_iframe_and_isolated_cross_origin_capabilities.sjs`; 12 const TEST_COM_URL = URL_ROOT_COM_SSL + TEST_DOCUMENT; 13 14 addRDMTask(TEST_COM_URL, async function ({ ui, browser, tab }) { 15 reloadOnTouchChange(true); 16 info("Test initial value for maxTouchPoints."); 17 is( 18 await getMaxTouchPoints(browser), 19 0, 20 "navigator.maxTouchPoints is 0 when touch simulation is not enabled" 21 ); 22 is( 23 await getMaxTouchPoints(browser.browsingContext.children[0]), 24 0, 25 "navigator.maxTouchPoints in the iframe is 0 when touch simulation is not enabled" 26 ); 27 28 info( 29 "Test value maxTouchPoints is non-zero when touch simulation is enabled." 30 ); 31 await toggleTouchSimulation(ui); 32 is( 33 await getMaxTouchPoints(browser), 34 1, 35 "navigator.maxTouchPoints should be 1 after enabling touch simulation" 36 ); 37 is( 38 await getMaxTouchPoints(browser.browsingContext.children[0]), 39 1, 40 "navigator.maxTouchPoints in the iframe should be 1 after enabling touch simulation" 41 ); 42 43 info("Toggling off touch simulation."); 44 await toggleTouchSimulation(ui); 45 is( 46 await getMaxTouchPoints(browser), 47 0, 48 "navigator.maxTouchPoints should be 0 after turning off touch simulation" 49 ); 50 51 is( 52 await getMaxTouchPoints(browser.browsingContext.children[0]), 53 0, 54 "navigator.maxTouchPoints in the iframe should be 0 after turning off touch simulation" 55 ); 56 57 info("Enabling touch simulation again"); 58 await toggleTouchSimulation(ui); 59 is( 60 await getMaxTouchPoints(browser), 61 1, 62 "navigator.maxTouchPoints should be 1 after enabling touch simulation again" 63 ); 64 is( 65 await getMaxTouchPoints(browser.browsingContext.children[0]), 66 1, 67 "navigator.maxTouchPoints in the iframe should be 1 after enabling touch simulation again" 68 ); 69 70 info("Check maxTouchPoints override persists after reload"); 71 await reloadBrowser(); 72 73 is( 74 await getMaxTouchPoints(browser), 75 1, 76 "navigator.maxTouchPoints is still 1 after reloading" 77 ); 78 is( 79 await getMaxTouchPoints(browser.browsingContext.children[0]), 80 1, 81 "navigator.maxTouchPoints in the iframe is still 1 after reloading" 82 ); 83 84 info( 85 "Check that maxTouchPoints persist after navigating to a page that forces the creation of a new browsing context" 86 ); 87 const previousBrowsingContextId = browser.browsingContext.id; 88 89 const waitForDevToolsReload = await watchForDevToolsReload(browser); 90 BrowserTestUtils.startLoadingURIString( 91 browser, 92 URL_ROOT_ORG_SSL + TEST_DOCUMENT + "?crossOriginIsolated=true" 93 ); 94 await waitForDevToolsReload(); 95 96 isnot( 97 browser.browsingContext.id, 98 previousBrowsingContextId, 99 "A new browsing context was created" 100 ); 101 102 is( 103 await getMaxTouchPoints(browser), 104 1, 105 "navigator.maxTouchPoints is still 1 after navigating to a new browsing context" 106 ); 107 is( 108 await getMaxTouchPoints(browser.browsingContext.children[0]), 109 1, 110 "navigator.maxTouchPoints in the iframe is still 1 after navigating to a new browsing context" 111 ); 112 113 info("Check that the value is reset when closing RDM"); 114 // Closing RDM trigers a reload 115 const onPageReloaded = BrowserTestUtils.browserLoaded(browser, true); 116 await closeRDM(tab); 117 await onPageReloaded; 118 119 is( 120 await getMaxTouchPoints(browser), 121 0, 122 "navigator.maxTouchPoints is 0 after closing RDM" 123 ); 124 is( 125 await getMaxTouchPoints(browser.browsingContext.children[0]), 126 0, 127 "navigator.maxTouchPoints in the iframe is 0 after closing RDM" 128 ); 129 130 reloadOnTouchChange(false); 131 }); 132 133 function getMaxTouchPoints(browserOrBrowsingContext) { 134 return SpecialPowers.spawn( 135 browserOrBrowsingContext, 136 [], 137 () => content.navigator.maxTouchPoints 138 ); 139 }