forked from mirrors/gecko-dev
Differential Revision: https://phabricator.services.mozilla.com/D23763 --HG-- extra : moz-landing-system : lando
72 lines
2.4 KiB
JavaScript
72 lines
2.4 KiB
JavaScript
/* Any copyright is dedicated to the Public Domain.
|
|
http://creativecommons.org/publicdomain/zero/1.0/ */
|
|
|
|
"use strict";
|
|
|
|
const NETWORK_RUNTIME_HOST = "localhost:6080";
|
|
const NETWORK_RUNTIME_APP_NAME = "TestNetworkApp";
|
|
const USB_RUNTIME_ID = "test-runtime-id";
|
|
const USB_DEVICE_NAME = "test device name";
|
|
const USB_APP_NAME = "TestApp";
|
|
|
|
// Test that remote runtime connections are persisted across about:debugging reloads.
|
|
add_task(async function() {
|
|
const mocks = new Mocks();
|
|
|
|
info("Test with a USB runtime");
|
|
const usbClient = mocks.createUSBRuntime(USB_RUNTIME_ID, {
|
|
name: USB_APP_NAME,
|
|
deviceName: USB_DEVICE_NAME,
|
|
});
|
|
|
|
await testRemoteClientPersistConnection(mocks, {
|
|
client: usbClient,
|
|
id: USB_RUNTIME_ID,
|
|
runtimeName: USB_APP_NAME,
|
|
sidebarName: USB_DEVICE_NAME,
|
|
});
|
|
|
|
info("Test with a network runtime");
|
|
const networkClient = mocks.createNetworkRuntime(NETWORK_RUNTIME_HOST, {
|
|
name: NETWORK_RUNTIME_APP_NAME,
|
|
});
|
|
|
|
await testRemoteClientPersistConnection(mocks, {
|
|
client: networkClient,
|
|
id: NETWORK_RUNTIME_HOST,
|
|
runtimeName: NETWORK_RUNTIME_APP_NAME,
|
|
sidebarName: NETWORK_RUNTIME_HOST,
|
|
});
|
|
});
|
|
|
|
async function testRemoteClientPersistConnection(mocks,
|
|
{ client, id, runtimeName, sidebarName }) {
|
|
info("Open about:debugging and connect to the test runtime");
|
|
let { document, tab, window } = await openAboutDebugging();
|
|
await selectThisFirefoxPage(document, window.AboutDebugging.store);
|
|
|
|
await connectToRuntime(sidebarName, document);
|
|
await selectRuntime(sidebarName, runtimeName, document);
|
|
|
|
info("Reload about:debugging");
|
|
document = await reloadAboutDebugging(tab);
|
|
|
|
info("Wait until the remote runtime appears as connected");
|
|
await waitUntil(() => {
|
|
const sidebarItem = findSidebarItemByText(sidebarName, document);
|
|
return sidebarItem && !sidebarItem.querySelector(".js-connect-button");
|
|
});
|
|
|
|
// Remove the runtime without emitting an update.
|
|
// This is what happens today when we simply close Firefox for Android.
|
|
info("Remove the runtime from the list of remote runtimes");
|
|
mocks.removeRuntime(id);
|
|
|
|
info("Emit 'closed' on the client and wait for the sidebar item to disappear");
|
|
client._eventEmitter.emit("closed");
|
|
await waitUntil(() => !findSidebarItemByText(sidebarName, document) &&
|
|
!findSidebarItemByText(runtimeName, document));
|
|
|
|
info("Remove the tab");
|
|
await removeTab(tab);
|
|
}
|