diff options
Diffstat (limited to 'devtools/client/aboutdebugging/test/browser/browser_aboutdebugging_sidebar_usb_runtime_refresh.js')
-rw-r--r-- | devtools/client/aboutdebugging/test/browser/browser_aboutdebugging_sidebar_usb_runtime_refresh.js | 50 |
1 files changed, 50 insertions, 0 deletions
diff --git a/devtools/client/aboutdebugging/test/browser/browser_aboutdebugging_sidebar_usb_runtime_refresh.js b/devtools/client/aboutdebugging/test/browser/browser_aboutdebugging_sidebar_usb_runtime_refresh.js new file mode 100644 index 0000000000..47ecc03239 --- /dev/null +++ b/devtools/client/aboutdebugging/test/browser/browser_aboutdebugging_sidebar_usb_runtime_refresh.js @@ -0,0 +1,50 @@ +/* Any copyright is dedicated to the Public Domain. + http://creativecommons.org/publicdomain/zero/1.0/ */ + +"use strict"; + +const RUNTIME_ID = "test-runtime-id"; +const RUNTIME_DEVICE_NAME = "test device name"; +const RUNTIME_APP_NAME = "TestApp"; + +const OTHER_RUNTIME_ID = "other-runtime-id"; +const OTHER_RUNTIME_APP_NAME = "OtherApp"; + +// Test that USB runtimes are not disconnected on refresh. +add_task(async function () { + const mocks = new Mocks(); + + const { document, tab } = await openAboutDebugging(); + + info("Create a first runtime and connect to it"); + mocks.createUSBRuntime(RUNTIME_ID, { + deviceName: RUNTIME_DEVICE_NAME, + name: RUNTIME_APP_NAME, + }); + mocks.emitUSBUpdate(); + + await connectToRuntime(RUNTIME_DEVICE_NAME, document); + await selectRuntime(RUNTIME_DEVICE_NAME, RUNTIME_APP_NAME, document); + + info("Create a second runtime and click on Refresh Devices"); + mocks.createUSBRuntime(OTHER_RUNTIME_ID, { + deviceName: OTHER_RUNTIME_APP_NAME, + }); + + // adb.updateRuntimes should ultimately fire the "runtime-list-updated" event. + mocks.adbMock.adb.updateRuntimes = () => mocks.emitUSBUpdate(); + document.querySelector(".qa-refresh-devices-button").click(); + + info(`Wait until the sidebar item for ${OTHER_RUNTIME_APP_NAME} appears`); + await waitUntil(() => + findSidebarItemByText(OTHER_RUNTIME_APP_NAME, document) + ); + + const sidebarItem = findSidebarItemByText(RUNTIME_DEVICE_NAME, document); + ok( + !sidebarItem.querySelector(".qa-connect-button"), + "Original USB runtime is still connected" + ); + + await removeTab(tab); +}); |