browser_aboutdebugging_sidebar_usb_unavailable_runtime.js (2068B)
1 /* Any copyright is dedicated to the Public Domain. 2 http://creativecommons.org/publicdomain/zero/1.0/ */ 3 4 "use strict"; 5 6 const RUNTIME_NAME = "Firefox 123"; 7 const DEVICE_NAME = "DEVICE_NAME"; 8 const DEVICE_ID = "DEVICE_ID"; 9 const RUNTIME_ID = "RUNTIME_ID"; 10 11 // Test that unavailable runtimes: 12 // - are displayed without a connect button. 13 // - cannot be selected 14 // - display a specific text ("Waiting for runtime") instead of the runtime name 15 add_task(async function () { 16 const mocks = new Mocks(); 17 const { document, tab } = await openAboutDebugging(); 18 19 info("Create a device without a corresponding runtime"); 20 mocks.addDevice(DEVICE_ID, DEVICE_NAME); 21 mocks.emitUSBUpdate(); 22 23 info("Wait until the USB sidebar item appears"); 24 await waitUntil(() => findSidebarItemByText(DEVICE_NAME, document)); 25 26 const usbRuntimeSidebarItem = findSidebarItemByText(DEVICE_NAME, document); 27 28 ok( 29 usbRuntimeSidebarItem.querySelector(".qa-runtime-item-waiting-for-browser"), 30 "Sidebar item shows as `Waiting for browser`" 31 ); 32 33 const hasConnectButton = 34 usbRuntimeSidebarItem.querySelector(".qa-connect-button"); 35 ok(!hasConnectButton, "Connect button is not displayed"); 36 37 const hasLink = usbRuntimeSidebarItem.querySelector(".qa-sidebar-link"); 38 ok(!hasLink, "Unavailable runtime is not selectable"); 39 40 info("Add a valid runtime for the same device id and emit update event"); 41 mocks.createUSBRuntime(RUNTIME_ID, { 42 deviceId: DEVICE_ID, 43 deviceName: DEVICE_NAME, 44 shortName: RUNTIME_NAME, 45 }); 46 mocks.removeDevice(DEVICE_ID); 47 mocks.emitUSBUpdate(); 48 49 info("Wait until connect button appears for the USB runtime"); 50 let updatedSidebarItem = null; 51 await waitUntil(() => { 52 updatedSidebarItem = findSidebarItemByText(DEVICE_NAME, document); 53 return ( 54 updatedSidebarItem && 55 updatedSidebarItem.querySelector(".qa-connect-button") 56 ); 57 }); 58 59 ok( 60 updatedSidebarItem.querySelector(".qa-runtime-item-standard"), 61 "Sidebar item for the USB runtime is now a standard sidebar item" 62 ); 63 64 await removeTab(tab); 65 });