blob: aa9b843b2b600a6d9606c9c7d45901a8e588e3e8 [file] [log] [blame]
<html>
<head>
<script src="../../http/tests/inspector/inspector-test.js"></script>
<script src="../../http/tests/inspector/console-test.js"></script>
<script>
function test()
{
var prompt = Console.ConsoleView.instance()._prompt;
InspectorTest.waitUntilConsoleEditorLoaded().then(step1);
function step1()
{
sequential([
() => pressEnterAfter("window"),
() => pressEnterAfter("window."),
() => pressEnterAfter("if (1 === 2)"),
() => pressEnterAfter("if (1 === 2) {"),
() => pressEnterAfter("if (1 === 2) {}"),
() => pressEnterAfter("[1,2,"),
() => pressEnterAfter("[1,2,3]"),
() => pressEnterAfter("{abc:"),
() => pressEnterAfter("{abc:123}"),
() => pressEnterAfter(
`function incomplete() {
if (1)
5;`),
() => pressEnterAfter(
`function bad() {
if (1)
}`),
() => pressEnterAfter(
`function good() {
if (1) {
5;
}
}`),
() => pressEnterAfter("1,"),
() => pressEnterAfter("label:"),
() => pressEnterAfter("for (var i = 0; i < 100; i++)"),
() => pressEnterAfter("for (var i = 0; i < 100; i++) i"),
() => pressEnterAfter("var templateStr = `"),
() => pressEnterAfter("var templateStr = `str`"),
() => pressEnterAfter("var doubleQ = \""),
() => pressEnterAfter("var singleQ = '"),
() => pressEnterAfter("var singleQ = 'str'")
]).then(InspectorTest.completeTest);
}
function sequential(tests)
{
var promise = Promise.resolve();
for (var i = 0; i < tests.length; i++)
promise = promise.then(tests[i]);
return promise;
}
function pressEnterAfter(text)
{
var fulfill;
var promise = new Promise(x => fulfill = x);
InspectorTest.addSniffer(Console.ConsolePrompt.prototype, "_enterProcessedForTest", enterProcessed);
prompt.setText(text);
prompt.moveCaretToEndOfPrompt();
prompt._enterKeyPressed(InspectorTest.createKeyEvent("Enter"));
return promise;
function enterProcessed()
{
InspectorTest.addResult("Text Before Enter:");
InspectorTest.addResult(text.replace(/ /g, "."));
InspectorTest.addResult("Text After Enter:");
InspectorTest.addResult(prompt.text().replace(/ /g, ".") || "<empty>");
InspectorTest.addResult("");
fulfill();
}
}
}
</script>
</head>
<body onload="runTest()">
<p>Tests that the console enters a newline instead of running a command if the command is incomplete.</p>
</body>
</html>