Bug 1717802 - [devtools] Fission test for event breakpoint with remote frames r=ochameau

Differential Revision: https://phabricator.services.mozilla.com/D125685
This commit is contained in:
Hubert Boma Manilla 2021-09-23 08:53:57 +00:00
Родитель eeff2699c2
Коммит b8d1653388
3 изменённых файлов: 104 добавлений и 0 удалений

Просмотреть файл

@ -218,6 +218,7 @@ skip-if =
os == 'mac' # Bug 1607321
os == 'win' && os_version == '10.0' && bits == 64 # Bug 1607321
[browser_dbg-event-handler.js]
[browser_dbg-event-breakpoints-fission.js]
[browser_dbg-event-breakpoints.js]
[browser_dbg-eval-throw.js]
[browser_dbg-sourceURL-breakpoint.js]

Просмотреть файл

@ -0,0 +1,80 @@
/* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at <http://mozilla.org/MPL/2.0/>. */
// Tests early event breakpoints and event breakpoints in a remote frame.
add_task(async function () {
await pushPref(
"devtools.debugger.features.event-listeners-breakpoints",
true
);
const dbg = await initDebugger(
"doc-event-breakpoints-fission.html",
"event-breakpoints"
);
await selectSource(dbg, "event-breakpoints");
await waitForSelectedSource(dbg, "event-breakpoints");
await dbg.actions.addEventListenerBreakpoints([
"event.mouse.click",
"event.xhr.load",
"timer.timeout.set"
]);
info("Assert early timeout event breakpoint gets hit");
const waitForReload = reloadBrowser();
await waitForPaused(dbg);
assertPauseLocation(dbg, 17, "doc-event-breakpoints-fission.html");
await resume(dbg);
await waitForReload;
info("Assert event breakpoints work in remote frame");
await invokeAndAssertBreakpoints(dbg);
info("reload the iframe")
await SpecialPowers.spawn(gBrowser.selectedBrowser, [], () =>
content.wrappedJSObject.reloadIframe()
);
info("Assert event breakpoints work in remote frame after reload");
await invokeAndAssertBreakpoints(dbg);
});
async function invokeAndAssertBreakpoints(dbg) {
invokeInTabRemoteFrame("clickHandler");
await waitForPaused(dbg);
assertPauseLocation(dbg, 12);
await resume(dbg);
invokeInTabRemoteFrame("xhrHandler");
await waitForPaused(dbg);
assertPauseLocation(dbg, 20);
await resume(dbg);
}
function assertPauseLocation(dbg, line, url = "event-breakpoints.js") {
const { location } = dbg.selectors.getVisibleSelectedFrame();
const selectedSource = dbg.selectors.getSelectedSourceWithContent();
is(location.sourceId, selectedSource.id, `Correct selected sourceId`);
ok(selectedSource.url.includes(url), "Correct url");
is(location.line, line, "Correct paused line");
assertPausedLocation(dbg);
}
async function invokeInTabRemoteFrame(fnc, ...args) {
info(`Invoking in tab remote frame: ${fnc}(${args.map(uneval).join(",")})`);
await SpecialPowers.spawn(gBrowser.selectedBrowser, [fnc, args], function (_fnc, _args) {
return SpecialPowers.spawn(
content.document.querySelector("iframe"),
[_fnc, _args],
(__fnc, __args) => content.wrappedJSObject[__fnc](...__args)
);
});
}

Просмотреть файл

@ -0,0 +1,23 @@
<!-- This Source Code Form is subject to the terms of the Mozilla Public
- License, v. 2.0. If a copy of the MPL was not distributed with this
- file, You can obtain one at http://mozilla.org/MPL/2.0/. -->
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8"/>
<title>Debugger event bp fission test page</title>
<script>
function reloadIframe() {
return new Promise(resolve => {
const iframe = document.querySelector("iframe");
iframe.addEventListener("load", () => resolve(), { once: true });
iframe.setAttribute("src", iframe.getAttribute("src"));
});
}
setTimeout(() => console.log("timeout fired"), 0)
</script>
</head>
<body>
<iframe src="http://example.org/browser/devtools/client/debugger/test/mochitest/examples/doc-event-breakpoints.html"></iframe>
</body>
</html>