browser_aboutdebugging_addons_debug_nobg.js (2673B)
1 /* Any copyright is dedicated to the Public Domain. 2 http://creativecommons.org/publicdomain/zero/1.0/ */ 3 "use strict"; 4 5 /* import-globals-from helper-addons.js */ 6 Services.scriptloader.loadSubScript(CHROME_URL_ROOT + "helper-addons.js", this); 7 8 // There are shutdown issues for which multiple rejections are left uncaught. 9 // See bug 1018184 for resolving these issues. 10 const { PromiseTestUtils } = ChromeUtils.importESModule( 11 "resource://testing-common/PromiseTestUtils.sys.mjs" 12 ); 13 PromiseTestUtils.allowMatchingRejectionsGlobally(/File closed/); 14 15 const ADDON_NOBG_ID = "test-devtools-webextension-nobg@mozilla.org"; 16 const ADDON_NOBG_NAME = "test-devtools-webextension-nobg"; 17 18 /** 19 * This test file ensures that the webextension addon developer toolbox: 20 * - the webextension developer toolbox is connected to a fallback page when the 21 * background page is not available (and in the fallback page document body contains 22 * the expected message, which warns the user that the current page is not a real 23 * webextension context); 24 */ 25 add_task(async function testWebExtensionsToolboxNoBackgroundPage() { 26 await enableExtensionDebugging(); 27 const { document, tab, window } = await openAboutDebugging(); 28 await selectThisFirefoxPage(document, window.AboutDebugging.store); 29 30 await installTemporaryExtensionFromXPI( 31 { 32 // Do not pass any `background` script. 33 id: ADDON_NOBG_ID, 34 name: ADDON_NOBG_NAME, 35 }, 36 document 37 ); 38 39 info("Open a toolbox to debug the addon"); 40 const { devtoolsWindow } = await openAboutDevtoolsToolbox( 41 document, 42 tab, 43 window, 44 ADDON_NOBG_NAME 45 ); 46 const toolbox = getToolbox(devtoolsWindow); 47 48 ok( 49 toolbox.commands.descriptorFront.isWebExtensionDescriptor, 50 "Toolbox is debugging an addon" 51 ); 52 const targetName = toolbox.target.name; 53 is( 54 targetName, 55 "Web Extension Fallback Document", 56 "Toolbox has the expected target" 57 ); 58 59 const inspector = await toolbox.selectTool("inspector"); 60 61 let nodeActor; 62 info(`Wait the fallback window to be fully loaded`); 63 await asyncWaitUntil(async () => { 64 nodeActor = await inspector.walker.querySelector( 65 inspector.walker.rootNode, 66 "h1" 67 ); 68 return nodeActor && nodeActor.inlineTextChild; 69 }); 70 71 info("Got a nodeActor with an inline text child"); 72 const actualValue = nodeActor.inlineTextChild._form.nodeValue; 73 is( 74 actualValue, 75 "Your addon does not have any document opened yet.", 76 "nodeActor has the expected inlineTextChild value" 77 ); 78 79 await closeWebExtAboutDevtoolsToolbox(devtoolsWindow, window); 80 await removeTemporaryExtension(ADDON_NOBG_NAME, document); 81 await removeTab(tab); 82 });