browser_aboutdebugging_addons_manifest_url.js (2591B)
1 /* Any copyright is dedicated to the Public Domain. 2 http://creativecommons.org/publicdomain/zero/1.0/ */ 3 4 "use strict"; 5 6 const { 7 adbAddon, 8 } = require("resource://devtools/client/shared/remote-debugging/adb/adb-addon.js"); 9 10 const ABD_ADDON_NAME = "Firefox DevTools ADB Extension"; 11 12 /* import-globals-from helper-adb.js */ 13 Services.scriptloader.loadSubScript(CHROME_URL_ROOT + "helper-adb.js", this); 14 15 // Test that manifest URLs for addon targets show the manifest correctly in a new tab. 16 // This test reuses the ADB extension to be sure to have a valid manifest URL to open. 17 add_task(async function () { 18 await pushPref( 19 "devtools.remote.adb.extensionURL", 20 CHROME_URL_ROOT + "resources/test-adb-extension/adb-extension-#OS#.xpi" 21 ); 22 await checkAdbNotRunning(); 23 24 const { document, tab, window } = await openAboutDebugging(); 25 await selectThisFirefoxPage(document, window.AboutDebugging.store); 26 const usbStatusElement = document.querySelector(".qa-sidebar-usb-status"); 27 28 info("Install ADB"); 29 adbAddon.install("internal"); 30 await waitUntil(() => usbStatusElement.textContent.includes("USB enabled")); 31 await waitForAdbStart(); 32 33 info("Wait until the debug target for ADB appears"); 34 await waitUntil(() => findDebugTargetByText(ABD_ADDON_NAME, document)); 35 const adbExtensionItem = findDebugTargetByText(ABD_ADDON_NAME, document); 36 37 const manifestUrlElement = adbExtensionItem.querySelector(".qa-manifest-url"); 38 ok(manifestUrlElement, "A link to the manifest is displayed"); 39 40 info("Click on the manifest URL and wait for the new tab to open"); 41 const onTabOpened = once(gBrowser.tabContainer, "TabOpen"); 42 manifestUrlElement.click(); 43 const { target } = await onTabOpened; 44 await BrowserTestUtils.browserLoaded(target.linkedBrowser); 45 46 info("Retrieve the text content of the new tab"); 47 const textContent = await SpecialPowers.spawn( 48 target.linkedBrowser, 49 [], 50 function () { 51 return content.wrappedJSObject.document.body.textContent; 52 } 53 ); 54 55 const manifestObject = JSON.parse(textContent); 56 ok(manifestObject, "The displayed content is a valid JSON object"); 57 is( 58 manifestObject.name, 59 ABD_ADDON_NAME, 60 "Manifest tab shows the expected content" 61 ); 62 63 info("Close the manifest.json tab"); 64 await removeTab(target); 65 66 info("Uninstall the adb extension and wait for the message to udpate"); 67 adbAddon.uninstall(); 68 await waitUntil(() => usbStatusElement.textContent.includes("USB disabled")); 69 await stopAdbProcess(); 70 71 await waitForAboutDebuggingRequests(window.AboutDebugging.store); 72 await removeTab(tab); 73 });