1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
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>
|