browser_aboutdebugging_sidebar_usb_status.js (1646B)
1 /* Any copyright is dedicated to the Public Domain. 2 http://creativecommons.org/publicdomain/zero/1.0/ */ 3 4 "use strict"; 5 6 const { 7 adbAddon, 8 } = require("resource://devtools/client/shared/remote-debugging/adb/adb-addon.js"); 9 10 /** 11 * This test asserts that the sidebar shows a message describing the status of the USB 12 * devices scanning. 13 */ 14 add_task(async function () { 15 const mocks = new Mocks(); 16 17 await pushPref( 18 "devtools.remote.adb.extensionURL", 19 CHROME_URL_ROOT + "resources/test-adb-extension/adb-extension-#OS#.xpi" 20 ); 21 const { document, tab } = await openAboutDebugging(); 22 23 const usbStatusElement = document.querySelector(".qa-sidebar-usb-status"); 24 ok(usbStatusElement, "Sidebar shows the USB status element"); 25 ok( 26 usbStatusElement.textContent.includes("USB disabled"), 27 "USB status element has 'disabled' content" 28 ); 29 30 info("Install the adb extension and wait for the message to udpate"); 31 // Use "internal" as the install source to avoid triggering telemetry. 32 adbAddon.install("internal"); 33 // When using mocks, we manually control the .start() call 34 await mocks.adbProcessMock.adbProcess.start(); 35 36 info("Wait till the USB status element has 'enabled' content"); 37 await waitUntil(() => { 38 const el = document.querySelector(".qa-sidebar-usb-status"); 39 return el.textContent.includes("USB enabled"); 40 }); 41 42 info("Uninstall the adb extension and wait for USB status element to update"); 43 adbAddon.uninstall(); 44 await waitUntil(() => { 45 const el = document.querySelector(".qa-sidebar-usb-status"); 46 return el.textContent.includes("USB disabled"); 47 }); 48 49 await removeTab(tab); 50 });