browser_aboutdebugging_sidebar_usb_runtime_refresh.js (1564B)
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_ID = "test-runtime-id"; 7 const RUNTIME_DEVICE_NAME = "test device name"; 8 const RUNTIME_APP_NAME = "TestApp"; 9 10 const OTHER_RUNTIME_ID = "other-runtime-id"; 11 const OTHER_RUNTIME_APP_NAME = "OtherApp"; 12 13 // Test that USB runtimes are not disconnected on refresh. 14 add_task(async function () { 15 const mocks = new Mocks(); 16 17 const { document, tab } = await openAboutDebugging(); 18 19 info("Create a first runtime and connect to it"); 20 mocks.createUSBRuntime(RUNTIME_ID, { 21 deviceName: RUNTIME_DEVICE_NAME, 22 name: RUNTIME_APP_NAME, 23 }); 24 mocks.emitUSBUpdate(); 25 26 await connectToRuntime(RUNTIME_DEVICE_NAME, document); 27 await waitForRuntimePage(RUNTIME_APP_NAME, document); 28 29 info("Create a second runtime and click on Refresh Devices"); 30 mocks.createUSBRuntime(OTHER_RUNTIME_ID, { 31 deviceName: OTHER_RUNTIME_APP_NAME, 32 }); 33 34 // adb.updateRuntimes should ultimately fire the "runtime-list-updated" event. 35 mocks.adbMock.adb.updateRuntimes = () => mocks.emitUSBUpdate(); 36 document.querySelector(".qa-refresh-devices-button").click(); 37 38 info(`Wait until the sidebar item for ${OTHER_RUNTIME_APP_NAME} appears`); 39 await waitUntil(() => 40 findSidebarItemByText(OTHER_RUNTIME_APP_NAME, document) 41 ); 42 43 const sidebarItem = findSidebarItemByText(RUNTIME_DEVICE_NAME, document); 44 ok( 45 !sidebarItem.querySelector(".qa-connect-button"), 46 "Original USB runtime is still connected" 47 ); 48 49 await removeTab(tab); 50 });