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
81
82
83
84
85
86
87
|
/* Any copyright is dedicated to the Public Domain.
http://creativecommons.org/publicdomain/zero/1.0/ */
"use strict";
/* import-globals-from helper-addons.js */
Services.scriptloader.loadSubScript(CHROME_URL_ROOT + "helper-addons.js", this);
const { LocalizationHelper } = require("resource://devtools/shared/l10n.js");
const L10N = new LocalizationHelper(
"devtools/client/locales/toolbox.properties"
);
add_task(async () => {
const EXTENSION_NAME = "temporary-web-extension";
const EXTENSION_ID = "test-devtools@mozilla.org";
await enableExtensionDebugging();
info(
"The debugger should show the source codes of extension even if " +
"devtools.chrome.enabled and devtools.debugger.remote-enabled are off"
);
await pushPref("devtools.chrome.enabled", false);
await pushPref("devtools.debugger.remote-enabled", false);
const { document, tab, window } = await openAboutDebugging();
await selectThisFirefoxPage(document, window.AboutDebugging.store);
await installTemporaryExtensionFromXPI(
{
background() {
window.someRandomMethodName = () => {
// This will not be referred from anywhere.
// However this is necessary to show as the source code in the debugger.
};
},
id: EXTENSION_ID,
name: EXTENSION_NAME,
},
document
);
// Select the debugger right away to avoid any noise coming from the inspector.
await pushPref("devtools.toolbox.selectedTool", "jsdebugger");
const { devtoolsWindow } = await openAboutDevtoolsToolbox(
document,
tab,
window,
EXTENSION_NAME
);
const toolbox = getToolbox(devtoolsWindow);
const { panelWin } = toolbox.getCurrentPanel();
info("Check the state of redux");
ok(
panelWin.dbg.store.getState().sourcesTree.isWebExtension,
"isWebExtension flag in sourcesTree is true"
);
info("Check whether the element displays correctly");
let sourceList = panelWin.document.querySelector(".sources-list");
ok(sourceList, "Source list element displays correctly");
ok(
sourceList.textContent.includes("temporary-web-extension"),
"Extension name displays correctly"
);
const waitForLoadedPanelsReload = await watchForLoadedPanelsReload(toolbox);
info("Reload the addon using a toolbox reload shortcut");
toolbox.win.focus();
synthesizeKeyShortcut(L10N.getStr("toolbox.reload.key"), toolbox.win);
await waitForLoadedPanelsReload();
info("Wait until a new background log message is logged");
await waitFor(() => {
// As React may re-create a new sources-list element,
// fetch the latest instance
sourceList = panelWin.document.querySelector(".sources-list");
return sourceList?.textContent.includes("temporary-web-extension");
}, "Wait for the source to re-appear");
await closeWebExtAboutDevtoolsToolbox(devtoolsWindow, window);
await removeTemporaryExtension(EXTENSION_NAME, document);
await removeTab(tab);
});
|