From 26a029d407be480d791972afb5975cf62c9360a6 Mon Sep 17 00:00:00 2001 From: Daniel Baumann Date: Fri, 19 Apr 2024 02:47:55 +0200 Subject: Adding upstream version 124.0.1. Signed-off-by: Daniel Baumann --- ...tdebugging_runtime_disconnect_remote_runtime.js | 65 ++++++++++++++++++++++ 1 file changed, 65 insertions(+) create mode 100644 devtools/client/aboutdebugging/test/browser/browser_aboutdebugging_runtime_disconnect_remote_runtime.js (limited to 'devtools/client/aboutdebugging/test/browser/browser_aboutdebugging_runtime_disconnect_remote_runtime.js') diff --git a/devtools/client/aboutdebugging/test/browser/browser_aboutdebugging_runtime_disconnect_remote_runtime.js b/devtools/client/aboutdebugging/test/browser/browser_aboutdebugging_runtime_disconnect_remote_runtime.js new file mode 100644 index 0000000000..e7cae28d29 --- /dev/null +++ b/devtools/client/aboutdebugging/test/browser/browser_aboutdebugging_runtime_disconnect_remote_runtime.js @@ -0,0 +1,65 @@ +/* Any copyright is dedicated to the Public Domain. + http://creativecommons.org/publicdomain/zero/1.0/ */ + +"use strict"; + +const USB_RUNTIME_ID = "1337id"; +const USB_DEVICE_NAME = "Fancy Phone"; +const USB_APP_NAME = "Lorem ipsum"; + +const DEFAULT_PAGE = "#/runtime/this-firefox"; + +/** + * Check if the disconnect button disconnects the remote runtime + * and redirects to the default page. + */ +add_task(async function () { + // Create a real local client and use it as the remote USB client for this + // test. + const clientWrapper = await createLocalClientWrapper(); + + // enable USB devices mocks + const mocks = new Mocks(); + mocks.createUSBRuntime(USB_RUNTIME_ID, { + clientWrapper, + deviceName: USB_DEVICE_NAME, + name: USB_APP_NAME, + }); + + const { document, tab, window } = await openAboutDebugging(); + await selectThisFirefoxPage(document, window.AboutDebugging.store); + + mocks.emitUSBUpdate(); + + const onRequestSuccess = waitForRequestsSuccess(window.AboutDebugging.store); + await connectToRuntime(USB_DEVICE_NAME, document); + await selectRuntime(USB_DEVICE_NAME, USB_APP_NAME, document); + await onRequestSuccess; + + const disconnectRemoteRuntimeButton = document.querySelector( + ".qa-runtime-info__action" + ); + + info("Check whether disconnect remote runtime button exists"); + ok(!!disconnectRemoteRuntimeButton, "Runtime contains the disconnect button"); + + info("Click on the disconnect button"); + disconnectRemoteRuntimeButton.click(); + + info("Wait until the runtime is disconnected"); + await waitUntil(() => document.querySelector(".qa-connect-button")); + + is( + document.location.hash, + DEFAULT_PAGE, + "Redirection to the default page (this-firefox)" + ); + + info("Wait until the Runtime name is displayed"); + await waitUntil(() => { + const runtimeInfo = document.querySelector(".qa-runtime-name"); + return runtimeInfo && runtimeInfo.textContent.includes("Firefox"); + }); + + await removeTab(tab); +}); -- cgit v1.2.3