summaryrefslogtreecommitdiffstats
path: root/devtools/client/aboutdebugging/test/browser/browser_aboutdebugging_sidebar_usb_runtime_connect.js
diff options
context:
space:
mode:
Diffstat (limited to 'devtools/client/aboutdebugging/test/browser/browser_aboutdebugging_sidebar_usb_runtime_connect.js')
-rw-r--r--devtools/client/aboutdebugging/test/browser/browser_aboutdebugging_sidebar_usb_runtime_connect.js54
1 files changed, 54 insertions, 0 deletions
diff --git a/devtools/client/aboutdebugging/test/browser/browser_aboutdebugging_sidebar_usb_runtime_connect.js b/devtools/client/aboutdebugging/test/browser/browser_aboutdebugging_sidebar_usb_runtime_connect.js
new file mode 100644
index 0000000000..f4978b0495
--- /dev/null
+++ b/devtools/client/aboutdebugging/test/browser/browser_aboutdebugging_sidebar_usb_runtime_connect.js
@@ -0,0 +1,54 @@
+/* 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_NAME = "test runtime name";
+const RUNTIME_DEVICE_NAME = "test device name";
+const RUNTIME_SHORT_NAME = "test short name";
+
+// Test that USB runtimes appear and disappear from the sidebar,
+// as well as their connect button.
+// Also checks whether the label of item is updated after connecting.
+add_task(async function () {
+ const mocks = new Mocks();
+
+ const { document, tab } = await openAboutDebugging();
+
+ mocks.createUSBRuntime(RUNTIME_ID, {
+ name: RUNTIME_NAME,
+ deviceName: RUNTIME_DEVICE_NAME,
+ shortName: RUNTIME_SHORT_NAME,
+ });
+ mocks.emitUSBUpdate();
+
+ info("Wait until the USB sidebar item appears");
+ await waitUntil(() => findSidebarItemByText(RUNTIME_DEVICE_NAME, document));
+ const usbRuntimeSidebarItem = findSidebarItemByText(
+ RUNTIME_DEVICE_NAME,
+ document
+ );
+ const connectButton =
+ usbRuntimeSidebarItem.querySelector(".qa-connect-button");
+ ok(connectButton, "Connect button is displayed for the USB runtime");
+
+ info("Click on the connect button and wait until it disappears");
+ connectButton.click();
+ await waitUntil(
+ () => !usbRuntimeSidebarItem.querySelector(".qa-connect-button")
+ );
+
+ info("Check whether the label of item is updated after connecting");
+ ok(
+ usbRuntimeSidebarItem.textContent.includes(RUNTIME_NAME),
+ "Label of item updated"
+ );
+
+ info("Remove all USB runtimes");
+ mocks.removeUSBRuntime(RUNTIME_ID);
+ mocks.emitUSBUpdate();
+ await waitUntilUsbDeviceIsUnplugged(RUNTIME_DEVICE_NAME, document);
+
+ await removeTab(tab);
+});