michael@0: /* Any copyright is dedicated to the Public Domain. michael@0: http://creativecommons.org/publicdomain/zero/1.0/ */ michael@0: michael@0: /** michael@0: * Tests basic search functionality (find token and jump to line). michael@0: */ michael@0: michael@0: const TAB_URL = EXAMPLE_URL + "doc_recursion-stack.html"; michael@0: michael@0: let gTab, gDebuggee, gPanel, gDebugger; michael@0: let gEditor, gSources, gFiltering, gSearchBox; michael@0: michael@0: function test() { michael@0: initDebugger(TAB_URL).then(([aTab, aDebuggee, aPanel]) => { michael@0: gTab = aTab; michael@0: gDebuggee = aDebuggee; michael@0: gPanel = aPanel; michael@0: gDebugger = gPanel.panelWin; michael@0: gEditor = gDebugger.DebuggerView.editor; michael@0: gSources = gDebugger.DebuggerView.Sources; michael@0: gFiltering = gDebugger.DebuggerView.Filtering; michael@0: gSearchBox = gDebugger.DebuggerView.Filtering._searchbox; michael@0: michael@0: waitForSourceShown(gPanel, ".html").then(performTest); michael@0: }); michael@0: } michael@0: michael@0: function performTest() { michael@0: setText(gSearchBox, "#html"); michael@0: michael@0: EventUtils.synthesizeKey("VK_RETURN", { shiftKey: true }, gDebugger); michael@0: is(gFiltering.searchData.toSource(), '["#", ["", "html"]]', michael@0: "The searchbox data wasn't parsed correctly."); michael@0: ok(isCaretPos(gPanel, 35, 7), michael@0: "The editor didn't jump to the correct line."); michael@0: michael@0: EventUtils.synthesizeKey("VK_RETURN", { shiftKey: true }, gDebugger); michael@0: is(gFiltering.searchData.toSource(), '["#", ["", "html"]]', michael@0: "The searchbox data wasn't parsed correctly."); michael@0: ok(isCaretPos(gPanel, 5, 6), michael@0: "The editor didn't jump to the correct line."); michael@0: michael@0: EventUtils.synthesizeKey("VK_RETURN", { shiftKey: true }, gDebugger); michael@0: is(gFiltering.searchData.toSource(), '["#", ["", "html"]]', michael@0: "The searchbox data wasn't parsed correctly."); michael@0: ok(isCaretPos(gPanel, 3, 15), michael@0: "The editor didn't jump to the correct line."); michael@0: michael@0: setText(gSearchBox, ":12"); michael@0: is(gFiltering.searchData.toSource(), '[":", ["", 12]]', michael@0: "The searchbox data wasn't parsed correctly."); michael@0: ok(isCaretPos(gPanel, 12), michael@0: "The editor didn't jump to the correct line."); michael@0: michael@0: EventUtils.synthesizeKey("g", { metaKey: true }, gDebugger); michael@0: is(gFiltering.searchData.toSource(), '[":", ["", 13]]', michael@0: "The searchbox data wasn't parsed correctly."); michael@0: ok(isCaretPos(gPanel, 13), michael@0: "The editor didn't jump to the correct line after Meta+G."); michael@0: michael@0: EventUtils.synthesizeKey("n", { ctrlKey: true }, gDebugger); michael@0: is(gFiltering.searchData.toSource(), '[":", ["", 14]]', michael@0: "The searchbox data wasn't parsed correctly."); michael@0: ok(isCaretPos(gPanel, 14), michael@0: "The editor didn't jump to the correct line after Ctrl+N."); michael@0: michael@0: EventUtils.synthesizeKey("G", { metaKey: true, shiftKey: true }, gDebugger); michael@0: is(gFiltering.searchData.toSource(), '[":", ["", 13]]', michael@0: "The searchbox data wasn't parsed correctly."); michael@0: ok(isCaretPos(gPanel, 13), michael@0: "The editor didn't jump to the correct line after Meta+Shift+G."); michael@0: michael@0: EventUtils.synthesizeKey("p", { ctrlKey: true }, gDebugger); michael@0: is(gFiltering.searchData.toSource(), '[":", ["", 12]]', michael@0: "The searchbox data wasn't parsed correctly."); michael@0: ok(isCaretPos(gPanel, 12), michael@0: "The editor didn't jump to the correct line after Ctrl+P."); michael@0: michael@0: for (let i = 0; i < 100; i++) { michael@0: EventUtils.sendKey("DOWN", gDebugger); michael@0: } michael@0: is(gFiltering.searchData.toSource(), '[":", ["", 36]]', michael@0: "The searchbox data wasn't parsed correctly."); michael@0: ok(isCaretPos(gPanel, 36), michael@0: "The editor didn't jump to the correct line after multiple DOWN keys."); michael@0: michael@0: for (let i = 0; i < 100; i++) { michael@0: EventUtils.sendKey("UP", gDebugger); michael@0: } michael@0: is(gFiltering.searchData.toSource(), '[":", ["", 1]]', michael@0: "The searchbox data wasn't parsed correctly."); michael@0: ok(isCaretPos(gPanel, 1), michael@0: "The editor didn't jump to the correct line after multiple UP keys."); michael@0: michael@0: michael@0: let token = "debugger"; michael@0: setText(gSearchBox, "#" + token); michael@0: is(gFiltering.searchData.toSource(), '["#", ["", "debugger"]]', michael@0: "The searchbox data wasn't parsed correctly."); michael@0: ok(isCaretPos(gPanel, 8, 12 + token.length), michael@0: "The editor didn't jump to the correct token (1)."); michael@0: michael@0: EventUtils.sendKey("DOWN", gDebugger); michael@0: is(gFiltering.searchData.toSource(), '["#", ["", "debugger"]]', michael@0: "The searchbox data wasn't parsed correctly."); michael@0: ok(isCaretPos(gPanel, 14, 9 + token.length), michael@0: "The editor didn't jump to the correct token (2)."); michael@0: michael@0: EventUtils.sendKey("DOWN", gDebugger); michael@0: is(gFiltering.searchData.toSource(), '["#", ["", "debugger"]]', michael@0: "The searchbox data wasn't parsed correctly."); michael@0: ok(isCaretPos(gPanel, 18, 15 + token.length), michael@0: "The editor didn't jump to the correct token (3)."); michael@0: michael@0: EventUtils.sendKey("RETURN", gDebugger); michael@0: is(gFiltering.searchData.toSource(), '["#", ["", "debugger"]]', michael@0: "The searchbox data wasn't parsed correctly."); michael@0: ok(isCaretPos(gPanel, 26, 11 + token.length), michael@0: "The editor didn't jump to the correct token (4)."); michael@0: michael@0: EventUtils.sendKey("RETURN", gDebugger); michael@0: is(gFiltering.searchData.toSource(), '["#", ["", "debugger"]]', michael@0: "The searchbox data wasn't parsed correctly."); michael@0: ok(isCaretPos(gPanel, 8, 12 + token.length), michael@0: "The editor didn't jump to the correct token (5)."); michael@0: michael@0: EventUtils.sendKey("UP", gDebugger); michael@0: is(gFiltering.searchData.toSource(), '["#", ["", "debugger"]]', michael@0: "The searchbox data wasn't parsed correctly."); michael@0: ok(isCaretPos(gPanel, 26, 11 + token.length), michael@0: "The editor didn't jump to the correct token (6)."); michael@0: michael@0: setText(gSearchBox, ":bogus#" + token + ";"); michael@0: is(gFiltering.searchData.toSource(), '["#", [":bogus", "debugger;"]]', michael@0: "The searchbox data wasn't parsed correctly."); michael@0: ok(isCaretPos(gPanel, 14, 9 + token.length + 1), michael@0: "The editor didn't jump to the correct token (7)."); michael@0: michael@0: setText(gSearchBox, ":13#" + token + ";"); michael@0: is(gFiltering.searchData.toSource(), '["#", [":13", "debugger;"]]', michael@0: "The searchbox data wasn't parsed correctly."); michael@0: ok(isCaretPos(gPanel, 14, 9 + token.length + 1), michael@0: "The editor didn't jump to the correct token (8)."); michael@0: michael@0: setText(gSearchBox, ":#" + token + ";"); michael@0: is(gFiltering.searchData.toSource(), '["#", [":", "debugger;"]]', michael@0: "The searchbox data wasn't parsed correctly."); michael@0: ok(isCaretPos(gPanel, 14, 9 + token.length + 1), michael@0: "The editor didn't jump to the correct token (9)."); michael@0: michael@0: setText(gSearchBox, "::#" + token + ";"); michael@0: is(gFiltering.searchData.toSource(), '["#", ["::", "debugger;"]]', michael@0: "The searchbox data wasn't parsed correctly."); michael@0: ok(isCaretPos(gPanel, 14, 9 + token.length + 1), michael@0: "The editor didn't jump to the correct token (10)."); michael@0: michael@0: setText(gSearchBox, ":::#" + token + ";"); michael@0: is(gFiltering.searchData.toSource(), '["#", [":::", "debugger;"]]', michael@0: "The searchbox data wasn't parsed correctly."); michael@0: ok(isCaretPos(gPanel, 14, 9 + token.length + 1), michael@0: "The editor didn't jump to the correct token (11)."); michael@0: michael@0: michael@0: setText(gSearchBox, "#" + token + ";" + ":bogus"); michael@0: is(gFiltering.searchData.toSource(), '["#", ["", "debugger;:bogus"]]', michael@0: "The searchbox data wasn't parsed correctly."); michael@0: ok(isCaretPos(gPanel, 14, 9 + token.length + 1), michael@0: "The editor didn't jump to the correct token (12)."); michael@0: michael@0: setText(gSearchBox, "#" + token + ";" + ":13"); michael@0: is(gFiltering.searchData.toSource(), '["#", ["", "debugger;:13"]]', michael@0: "The searchbox data wasn't parsed correctly."); michael@0: ok(isCaretPos(gPanel, 14, 9 + token.length + 1), michael@0: "The editor didn't jump to the correct token (13)."); michael@0: michael@0: setText(gSearchBox, "#" + token + ";" + ":"); michael@0: is(gFiltering.searchData.toSource(), '["#", ["", "debugger;:"]]', michael@0: "The searchbox data wasn't parsed correctly."); michael@0: ok(isCaretPos(gPanel, 14, 9 + token.length + 1), michael@0: "The editor didn't jump to the correct token (14)."); michael@0: michael@0: setText(gSearchBox, "#" + token + ";" + "::"); michael@0: is(gFiltering.searchData.toSource(), '["#", ["", "debugger;::"]]', michael@0: "The searchbox data wasn't parsed correctly."); michael@0: ok(isCaretPos(gPanel, 14, 9 + token.length + 1), michael@0: "The editor didn't jump to the correct token (15)."); michael@0: michael@0: setText(gSearchBox, "#" + token + ";" + ":::"); michael@0: is(gFiltering.searchData.toSource(), '["#", ["", "debugger;:::"]]', michael@0: "The searchbox data wasn't parsed correctly."); michael@0: ok(isCaretPos(gPanel, 14, 9 + token.length + 1), michael@0: "The editor didn't jump to the correct token (16)."); michael@0: michael@0: michael@0: setText(gSearchBox, ":i am not a number"); michael@0: is(gFiltering.searchData.toSource(), '[":", ["", 0]]', michael@0: "The searchbox data wasn't parsed correctly."); michael@0: ok(isCaretPos(gPanel, 14, 9 + token.length + 1), michael@0: "The editor didn't remain at the correct token (17)."); michael@0: michael@0: setText(gSearchBox, "#__i do not exist__"); michael@0: is(gFiltering.searchData.toSource(), '["#", ["", "__i do not exist__"]]', michael@0: "The searchbox data wasn't parsed correctly."); michael@0: ok(isCaretPos(gPanel, 14, 9 + token.length + 1), michael@0: "The editor didn't remain at the correct token (18)."); michael@0: michael@0: michael@0: setText(gSearchBox, "#" + token); michael@0: is(gFiltering.searchData.toSource(), '["#", ["", "debugger"]]', michael@0: "The searchbox data wasn't parsed correctly."); michael@0: ok(isCaretPos(gPanel, 8, 12 + token.length), michael@0: "The editor didn't jump to the correct token (19)."); michael@0: michael@0: michael@0: clearText(gSearchBox); michael@0: is(gFiltering.searchData.toSource(), '["", [""]]', michael@0: "The searchbox data wasn't parsed correctly."); michael@0: michael@0: EventUtils.sendKey("RETURN", gDebugger); michael@0: is(gFiltering.searchData.toSource(), '["", [""]]', michael@0: "The searchbox data wasn't parsed correctly."); michael@0: ok(isCaretPos(gPanel, 8, 12 + token.length), michael@0: "The editor shouldn't jump to another token (20)."); michael@0: michael@0: EventUtils.sendKey("RETURN", gDebugger); michael@0: is(gFiltering.searchData.toSource(), '["", [""]]', michael@0: "The searchbox data wasn't parsed correctly."); michael@0: ok(isCaretPos(gPanel, 8, 12 + token.length), michael@0: "The editor shouldn't jump to another token (21)."); michael@0: michael@0: michael@0: setText(gSearchBox, ":1:2:3:a:b:c:::12"); michael@0: is(gFiltering.searchData.toSource(), '[":", [":1:2:3:a:b:c::", 12]]', michael@0: "The searchbox data wasn't parsed correctly."); michael@0: ok(isCaretPos(gPanel, 12), michael@0: "The editor didn't jump to the correct line (22)."); michael@0: michael@0: setText(gSearchBox, "#don't#find#me#instead#find#" + token); michael@0: is(gFiltering.searchData.toSource(), '["#", ["#don\'t#find#me#instead#find", "debugger"]]', michael@0: "The searchbox data wasn't parsed correctly."); michael@0: ok(isCaretPos(gPanel, 8, 12 + token.length), michael@0: "The editor didn't jump to the correct token (23)."); michael@0: michael@0: EventUtils.sendKey("DOWN", gDebugger); michael@0: is(gFiltering.searchData.toSource(), '["#", ["#don\'t#find#me#instead#find", "debugger"]]', michael@0: "The searchbox data wasn't parsed correctly."); michael@0: ok(isCaretPos(gPanel, 14, 9 + token.length), michael@0: "The editor didn't jump to the correct token (24)."); michael@0: michael@0: EventUtils.sendKey("DOWN", gDebugger); michael@0: is(gFiltering.searchData.toSource(), '["#", ["#don\'t#find#me#instead#find", "debugger"]]', michael@0: "The searchbox data wasn't parsed correctly."); michael@0: ok(isCaretPos(gPanel, 18, 15 + token.length), michael@0: "The editor didn't jump to the correct token (25)."); michael@0: michael@0: EventUtils.sendKey("RETURN", gDebugger); michael@0: is(gFiltering.searchData.toSource(), '["#", ["#don\'t#find#me#instead#find", "debugger"]]', michael@0: "The searchbox data wasn't parsed correctly."); michael@0: ok(isCaretPos(gPanel, 26, 11 + token.length), michael@0: "The editor didn't jump to the correct token (26)."); michael@0: michael@0: EventUtils.sendKey("RETURN", gDebugger); michael@0: is(gFiltering.searchData.toSource(), '["#", ["#don\'t#find#me#instead#find", "debugger"]]', michael@0: "The searchbox data wasn't parsed correctly."); michael@0: ok(isCaretPos(gPanel, 8, 12 + token.length), michael@0: "The editor didn't jump to the correct token (27)."); michael@0: michael@0: EventUtils.sendKey("UP", gDebugger); michael@0: is(gFiltering.searchData.toSource(), '["#", ["#don\'t#find#me#instead#find", "debugger"]]', michael@0: "The searchbox data wasn't parsed correctly."); michael@0: ok(isCaretPos(gPanel, 26, 11 + token.length), michael@0: "The editor didn't jump to the correct token (28)."); michael@0: michael@0: michael@0: clearText(gSearchBox); michael@0: is(gFiltering.searchData.toSource(), '["", [""]]', michael@0: "The searchbox data wasn't parsed correctly."); michael@0: ok(isCaretPos(gPanel, 26, 11 + token.length), michael@0: "The editor didn't remain at the correct token (29)."); michael@0: is(gSources.visibleItems.length, 1, michael@0: "Not all the sources are shown after the search (30)."); michael@0: michael@0: michael@0: gEditor.focus(); michael@0: gEditor.setSelection.apply(gEditor, gEditor.getPosition(1, 5)); michael@0: ok(isCaretPos(gPanel, 1, 6), michael@0: "The editor caret position didn't update after selecting some text."); michael@0: michael@0: EventUtils.synthesizeKey("F", { accelKey: true }); michael@0: is(gFiltering.searchData.toSource(), '["#", ["", "!-- "]]', michael@0: "The searchbox data wasn't parsed correctly."); michael@0: is(gSearchBox.value, "#!-- ", michael@0: "The search field has the right initial value (1)."); michael@0: michael@0: gEditor.focus(); michael@0: gEditor.setSelection.apply(gEditor, gEditor.getPosition(415, 418)); michael@0: ok(isCaretPos(gPanel, 21, 30), michael@0: "The editor caret position didn't update after selecting some number."); michael@0: michael@0: EventUtils.synthesizeKey("L", { accelKey: true }); michael@0: is(gFiltering.searchData.toSource(), '[":", ["", 100]]', michael@0: "The searchbox data wasn't parsed correctly."); michael@0: is(gSearchBox.value, ":100", michael@0: "The search field has the right initial value (2)."); michael@0: michael@0: michael@0: closeDebuggerAndFinish(gPanel); michael@0: } michael@0: michael@0: registerCleanupFunction(function() { michael@0: gTab = null; michael@0: gDebuggee = null; michael@0: gPanel = null; michael@0: gDebugger = null; michael@0: gEditor = null; michael@0: gSources = null; michael@0: gFiltering = null; michael@0: gSearchBox = null; michael@0: });