summaryrefslogtreecommitdiffstats
path: root/devtools/server/tests/chrome/test_webextension-addon-debugging-connect.html
diff options
context:
space:
mode:
Diffstat (limited to 'devtools/server/tests/chrome/test_webextension-addon-debugging-connect.html')
-rw-r--r--devtools/server/tests/chrome/test_webextension-addon-debugging-connect.html80
1 files changed, 80 insertions, 0 deletions
diff --git a/devtools/server/tests/chrome/test_webextension-addon-debugging-connect.html b/devtools/server/tests/chrome/test_webextension-addon-debugging-connect.html
new file mode 100644
index 0000000000..d983d1bbb8
--- /dev/null
+++ b/devtools/server/tests/chrome/test_webextension-addon-debugging-connect.html
@@ -0,0 +1,80 @@
+<!DOCTYPE HTML>
+<html>
+<!--
+Bug 1302702 - Test connect to a webextension addon
+-->
+<head>
+ <meta charset="utf-8">
+ <title>Mozilla Bug</title>
+ <script src="chrome://mochikit/content/tests/SimpleTest/SimpleTest.js"></script>
+ <script src="chrome://mochikit/content/tests/SimpleTest/ExtensionTestUtils.js"></script>
+ <script src="webextension-helpers.js"></script>
+ <link rel="stylesheet" type="text/css" href="chrome://mochikit/content/tests/SimpleTest/test.css">
+</head>
+<body>
+<pre id="test">
+<script type="application/javascript">
+"use strict";
+
+add_task(async function test_webextension_addon_debugging_connect() {
+ // Install and start a test webextension.
+ const extension = ExtensionTestUtils.loadExtension({
+ useAddonManager: "temporary",
+ background: function() {
+ /* eslint-disable no-undef */
+ browser.test.log("background script executed");
+ browser.test.sendMessage("background page ready");
+ /* eslint-enable no-undef */
+ },
+ });
+ await extension.startup();
+ await extension.awaitMessage("background page ready");
+
+ // Connect a DevToolsClient.
+ const transport = DevToolsServer.connectPipe();
+ const client = new DevToolsClient(transport);
+ await client.connect();
+
+ // List addons and assertions on the expected addon actor.
+ const addonDescriptor = await client.mainRoot.getAddon({ id: extension.id });
+ ok(addonDescriptor, "The expected webextension addon actor has been found");
+
+ const addonTarget = await addonDescriptor.getTarget();
+ ok(addonTarget, "The expected webextension target addon actor has been found");
+
+ // Connect to the target addon actor and wait for the updated list of frames.
+ is(addonDescriptor.targetForm.isOOP, true,
+ "Got the expected oop mode in the webextension actor form");
+ const frames = await waitForFramesUpdated(addonTarget);
+ const backgroundPageFrame = frames.filter((frame) => {
+ return frame.url && frame.url.endsWith("/_generated_background_page.html");
+ }).pop();
+ is(backgroundPageFrame.addonID, extension.id, "Got an extension frame");
+
+ // When running in oop mode we can explicitly attach the thread without locking
+ // the main process.
+ const threadFront = await addonTarget.attachThread();
+
+ ok(threadFront, "Got a threadFront for the target addon");
+ is(threadFront.paused, false, "The addon threadActor isn't paused");
+
+ const waitTransportClosed = new Promise(resolve => {
+ client._transport.once("close", resolve);
+ });
+
+ await addonTarget.destroy();
+ await client.close();
+
+ // Check that if we close the debugging client without uninstalling the addon,
+ // the webextension debugging actor should release the debug browser.
+ await waitTransportClosed;
+ is(ExtensionParent.DebugUtils.debugBrowserPromises.size, 0,
+ "The debug browser has been released when the RDP connection has been closed");
+
+ await extension.unload();
+});
+
+</script>
+</pre>
+</body>
+</html>