diff --git a/devtools/client/aboutdebugging-new/test/browser/browser_aboutdebugging_sidebar_usb_runtime.js b/devtools/client/aboutdebugging-new/test/browser/browser_aboutdebugging_sidebar_usb_runtime.js index 264f7e923215..404727b9f364 100644 --- a/devtools/client/aboutdebugging-new/test/browser/browser_aboutdebugging_sidebar_usb_runtime.js +++ b/devtools/client/aboutdebugging-new/test/browser/browser_aboutdebugging_sidebar_usb_runtime.js @@ -1,36 +1,22 @@ /* Any copyright is dedicated to the Public Domain. http://creativecommons.org/publicdomain/zero/1.0/ */ -/* import-globals-from mocks/head-usb-runtimes-mock.js */ - "use strict"; -// Load USB Runtimes mock module -Services.scriptloader.loadSubScript( - CHROME_URL_ROOT + "mocks/head-usb-runtimes-mock.js", this); +/* import-globals-from head-mocks.js */ +Services.scriptloader.loadSubScript(CHROME_URL_ROOT + "head-mocks.js", this); // Test that USB runtimes appear and disappear from the sidebar. add_task(async function() { - const usbRuntimesMock = createUsbRuntimesMock(); - const observerMock = addObserverMock(usbRuntimesMock); - enableUsbRuntimesMock(usbRuntimesMock); - - // Disable our mock when the test ends. - registerCleanupFunction(() => { - disableUsbRuntimesMock(); - }); + const mocks = new Mocks(); const { document, tab } = await openAboutDebugging(); - usbRuntimesMock.getUSBRuntimes = function() { - return [{ - id: "test_device_id", - _socketPath: "test/path", - deviceName: "test device name", - shortName: "testshort", - }]; - }; - observerMock.emit("runtime-list-updated"); + mocks.createUSBRuntime("test_device_id", { + deviceName: "test device name", + shortName: "testshort", + }); + mocks.emitUSBUpdate(); info("Wait until the USB sidebar item appears"); await waitUntil(() => findSidebarItemByText("test device name", document)); @@ -38,10 +24,8 @@ add_task(async function() { ok(usbRuntimeSidebarItem.textContent.includes("testshort"), "The short name of the usb runtime is visible"); - usbRuntimesMock.getUSBRuntimes = function() { - return []; - }; - observerMock.emit("runtime-list-updated"); + mocks.removeUSBRuntime("test_device_id"); + mocks.emitUSBUpdate(); info("Wait until the USB sidebar item disappears"); await waitUntil(() => !findSidebarItemByText("test device name", document));