--HG--
extra : rebase_source : d20ca4aaa05fea5d9ce2919ce6e26eef115c5a57
This commit is contained in:
Brian Hackett 2018-08-14 15:34:29 +00:00
Родитель 7c44dfb229
Коммит e8f576dc9e
3 изменённых файлов: 109 добавлений и 0 удалений

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

@ -631,6 +631,7 @@ support-files =
examples/doc_rr_basic.html
examples/doc_rr_continuous.html
examples/doc_rr_recovery.html
examples/doc_rr_error.html
[browser_dbg-asm.js]
[browser_dbg-async-stepping.js]
@ -748,3 +749,5 @@ skip-if = os != "mac" || debug || !nightly_build
skip-if = os != "mac" || debug || !nightly_build
[browser_dbg_rr_replay-03.js]
skip-if = os != "mac" || debug || !nightly_build
[browser_dbg_rr_console_warp-01.js]
skip-if = os != "mac" || debug || !nightly_build

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

@ -0,0 +1,83 @@
/* -*- indent-tabs-mode: nil; js-indent-level: 2 -*- */
/* vim: set ft=javascript ts=2 et sw=2 tw=80: */
/* Any copyright is dedicated to the Public Domain.
* http://creativecommons.org/publicdomain/zero/1.0/ */
var { HUDService } = require("devtools/client/webconsole/hudservice");
// This functionality was copied from devtools/client/webconsole/test/mochitest/head.js,
// since this test straddles both the web console and the debugger. I couldn't
// figure out how to load that script directly here.
function findMessages(hud, text, selector = ".message") {
const messages = hud.ui.outputNode.querySelectorAll(selector);
const elements = Array.prototype.filter.call(
messages,
(el) => el.textContent.includes(text)
);
return elements;
}
async function openContextMenu(hud, element) {
const onConsoleMenuOpened = hud.ui.consoleOutput.once("menu-open");
synthesizeContextMenuEvent(element);
await onConsoleMenuOpened;
const doc = hud.ui.consoleOutput.owner.chromeWindow.document;
return doc.getElementById("webconsole-menu");
}
function hideContextMenu(hud) {
const doc = hud.ui.consoleOutput.owner.chromeWindow.document;
const popup = doc.getElementById("webconsole-menu");
if (!popup) {
return Promise.resolve();
}
const onPopupHidden = once(popup, "popuphidden");
popup.hidePopup();
return onPopupHidden;
}
// Test basic console time warping functionality in web replay.
async function test() {
waitForExplicitFinish();
let tab = BrowserTestUtils.addTab(gBrowser, null, { recordExecution: "*" });
gBrowser.selectedTab = tab;
openTrustedLinkIn(EXAMPLE_URL + "doc_rr_error.html", "current");
await once(Services.ppmm, "RecordingFinished");
let console = await openToolboxForTab(tab, "webconsole");
let hud = console.getCurrentPanel().hud;
let messages = findMessages(hud, "Number 5");
ok(messages.length == 1, "Found one message");
let message = messages.pop();
let menuPopup = await openContextMenu(hud, message);
let timeWarpItem = menuPopup.querySelector("#console-menu-time-warp");
ok(timeWarpItem, "Time warp menu item is available");
timeWarpItem.click();
await hideContextMenu(hud);
await once(Services.ppmm, "TimeWarpFinished");
let toolbox = await attachDebugger(tab), client = toolbox.threadClient;
await client.interrupt();
await checkEvaluateInTopFrame(client, "number", 5);
// Initially we are paused inside the 'new Error()' call on line 19. The
// first reverse step takes us to the start of that line.
await reverseStepOverToLine(client, 19);
await reverseStepOverToLine(client, 18);
await setBreakpoint(client, "doc_rr_error.html", 12);
await rewindToLine(client, 12);
await checkEvaluateInTopFrame(client, "number", 4);
await resumeToLine(client, 12);
await checkEvaluateInTopFrame(client, "number", 5);
await toolbox.destroy();
await gBrowser.removeTab(tab);
finish();
}

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

@ -0,0 +1,23 @@
<html lang="en" dir="ltr">
<body>
<div id="maindiv">Hello World!</div>
</body>
<script>
const cpmm = SpecialPowers.Services.cpmm;
function recordingFinished() {
cpmm.sendAsyncMessage("RecordingFinished");
}
var number = 0;
function f() {
number++;
document.getElementById("maindiv").innerHTML = "Number: " + number;
if (number >= 10) {
window.setTimeout(recordingFinished);
return;
}
window.setTimeout(f, 1);
throw new Error("Number " + number);
}
window.setTimeout(f, 1);
</script>
</html>