Skip to content

Commit

Permalink
Backed out 2 changesets (bug 1908095) for causing failures at browser…
Browse files Browse the repository at this point in the history
…_dbg-features-breakpoints.js. a=backout

Backed out changeset 21bf8880f772 (bug 1908095)
Backed out changeset 85060db8ce99 (bug 1908095)
  • Loading branch information
Ponchale committed Sep 11, 2024
1 parent 307e831 commit e9bba41
Show file tree
Hide file tree
Showing 15 changed files with 105 additions and 315 deletions.
Original file line number Diff line number Diff line change
@@ -1,149 +1,87 @@
/* Any copyright is dedicated to the Public Domain.
http://creativecommons.org/publicdomain/zero/1.0/ */
"use strict";

Services.scriptloader.loadSubScript(
"chrome://mochitests/content/browser/devtools/client/debugger/test/mochitest/shared-head.js",
this
);

/* import-globals-from helper-addons.js */
Services.scriptloader.loadSubScript(CHROME_URL_ROOT + "helper-addons.js", this);

const L10N = new LocalizationHelper(
"devtools/client/locales/toolbox.properties"
);

const EXTENSION_NAME = "temporary-web-extension";
const EXTENSION_ID = "[email protected]";

add_task(async function testOpenDebuggerReload() {
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);
});

add_task(async function testAddAndRemoveBreakpoint() {
await enableExtensionDebugging();

const { document, tab, window } = await openAboutDebugging();
await selectThisFirefoxPage(document, window.AboutDebugging.store);

await installTemporaryExtensionFromXPI(
{
background() {
window.invokeLogFromWebextension = () => {
console.log("From webextension");
};
},
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 dbg = createDebuggerContext(toolbox);

info("Select the source and add a breakpoint");
// Note: the background script filename is dynamically generated id, so we
// simply get the first source from the list.
const displayedSources = dbg.selectors.getDisplayedSourcesList();
const backgroundScript = displayedSources[0];
await selectSource(dbg, backgroundScript);
await addBreakpoint(dbg, backgroundScript, 3);

info("Trigger the breakpoint and wait for the debugger to pause");
const webconsole = await toolbox.selectTool("webconsole");
const { hud } = webconsole;
hud.ui.wrapper.dispatchEvaluateExpression("invokeLogFromWebextension()");
await waitForPaused(dbg);

info("Resume and remove the breakpoint");
await resume(dbg);
await removeBreakpoint(dbg, backgroundScript.id, 3);

info("Trigger the function again and check the debugger does not pause");
hud.ui.wrapper.dispatchEvaluateExpression("invokeLogFromWebextension()");
await wait(500);
assertNotPaused(dbg);

await closeWebExtAboutDevtoolsToolbox(devtoolsWindow, window);
await removeTemporaryExtension(EXTENSION_NAME, document);
await removeTab(tab);
});
"use strict";

/* import-globals-from helper-addons.js */
Services.scriptloader.loadSubScript(CHROME_URL_ROOT + "helper-addons.js", this);

const L10N = new LocalizationHelper(
"devtools/client/locales/toolbox.properties"
);

add_task(async () => {
const EXTENSION_NAME = "temporary-web-extension";
const EXTENSION_ID = "[email protected]";

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);
});

Original file line number Diff line number Diff line change
Expand Up @@ -19,14 +19,12 @@ add_task(async function testBreakableLinesOverReloads() {
);

info("Assert breakable lines of the first html page load");
await assertBreakableLines(dbg, "index.html", 85, [
await assertBreakableLines(dbg, "index.html", 78, [
...getRange(16, 17),
21,
...getRange(24, 25),
30,
36,
39,
...getRange(41, 43),
]);

info("Assert breakable lines of the first original source file, original.js");
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,31 +30,24 @@ add_task(async function testBreakableLinesOverReloads() {
);

info("Assert breakable lines of the first html page load");
await assertBreakablePositions(dbg, "index.html", 85, [
await assertBreakablePositions(dbg, "index.html", 78, [
{ line: 16, columns: [6, 14] },
{ line: 17, columns: [] },
{ line: 21, columns: [12, 20, 48] },
{ line: 24, columns: [12, 20] },
{ line: 25, columns: [] },
{ line: 30, columns: [] },
{ line: 36, columns: [] },
{ line: 39, columns: [] },
{ line: 41, columns: [8, 18] },
{ line: 42, columns: [] },
{ line: 43, columns: [] },
]);

info("Pretty print first html page load and assert breakable lines");
await prettyPrint(dbg);
await assertBreakablePositions(dbg, "index.html:formatted", 96, [
await assertBreakablePositions(dbg, "index.html:formatted", 87, [
{ line: 16, columns: [0, 8] },
{ line: 22, columns: [0, 8, 35] },
{ line: 27, columns: [0, 8] },
{ line: 28, columns: [] },
{ line: 36, columns: [] },
{ line: 48, columns: [] },
{ line: 50, columns: [2, 12] },
{ line: 53, columns: [] },
]);
await closeTab(dbg, "index.html:formatted");

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -70,63 +70,4 @@ add_task(
await dbg.actions.stepIn();
await assertNotPaused(dbg);
}
);

/**
* Tests that the source tree works with all the various types of sources
* coming from the integration test page.
*
* Also assert a few extra things on sources with query strings:
* - they can be pretty printed,
* - quick open matches them,
* - you can set breakpoint on them.
*/
add_task(async function testSourceTreeOnTheIntegrationTestPage() {
const dbg = await initDebuggerWithAbsoluteURL("about:blank");

await navigateToAbsoluteURL(
dbg,
TEST_URL,
"index.html",
"script.js",
"log-worker.js"
);

info("Select the source and add a breakpoint");
await selectSource(dbg, "script.js");
await addBreakpoint(dbg, "script.js", 7);

info("Trigger the breakpoint and wait for the debugger to pause");
invokeInTab("nonSourceMappedFunction");
await waitForPaused(dbg);

info("Resume and remove the breakpoint");
await resume(dbg);
await removeBreakpoint(dbg, findSource(dbg, "script.js").id, 7);

info("Trigger the function again and check the debugger does not pause");
invokeInTab("nonSourceMappedFunction");
await wait(500);
assertNotPaused(dbg);

info("[worker] Select the source and add a breakpoint");
await selectSource(dbg, "log-worker.js");
await addBreakpoint(dbg, "log-worker.js", 2);

info("[worker] Trigger the breakpoint and wait for the debugger to pause");
invokeInTab("invokeLogWorker");
await waitForPaused(dbg);

info("[worker] Resume and remove the breakpoint");
await resume(dbg);
await removeBreakpoint(dbg, findSource(dbg, "log-worker.js").id, 2);

info(
"[worker] Trigger the function again and check the debugger does not pause"
);
invokeInTab("invokeLogWorker");
await wait(500);
assertNotPaused(dbg);

dbg.toolbox.closeToolbox();
});
);
Original file line number Diff line number Diff line change
Expand Up @@ -320,12 +320,11 @@ add_task(async function testSourceTreeOnTheIntegrationTestPage() {
.getAllThreads()
.find(thread => thread.name == "Main Thread");

// When EFT is disabled the iframe's source is meld into the main target.
const expectedSameUrlSources = isEveryFrameTargetEnabled() ? 3 : 4;
is(
sourceActors.filter(actor => actor.thread == mainThread.actor).length,
expectedSameUrlSources,
`same-url.js is loaded ${expectedSameUrlSources} times in the main thread`
// When EFT is disabled the iframe's source is meld into the main target
isEveryFrameTargetEnabled() ? 3 : 4,
"same-url.js is loaded 3 times in the main thread"
);

if (isEveryFrameTargetEnabled()) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,10 +11,10 @@
"license": "MPL-2.0",
"dependencies": {},
"devDependencies": {
"@babel/core": "7.25.2",
"babel-loader": "7.1.2",
"babel-preset-es2015": "6.24.1",
"webpack": "4.47.0",
"webpack-cli": "4.10.0"
"babel-core": "^7.0.0-beta.3",
"babel-loader": "^7.1.2",
"babel-preset-es2015": "^6.24.1",
"webpack": "^4",
"webpack-cli": ""
}
}
Loading

0 comments on commit e9bba41

Please sign in to comment.