From 5f8de423f190bbb79a62f804151bc24824fa32d8 Mon Sep 17 00:00:00 2001 From: "Matt A. Tobin" Date: Fri, 2 Feb 2018 04:16:08 -0500 Subject: Add m-esr52 at 52.6.0 --- .../test/mochitest/browser_dbg_search-basic-03.js | 123 +++++++++++++++++++++ 1 file changed, 123 insertions(+) create mode 100644 devtools/client/debugger/test/mochitest/browser_dbg_search-basic-03.js (limited to 'devtools/client/debugger/test/mochitest/browser_dbg_search-basic-03.js') diff --git a/devtools/client/debugger/test/mochitest/browser_dbg_search-basic-03.js b/devtools/client/debugger/test/mochitest/browser_dbg_search-basic-03.js new file mode 100644 index 000000000..0020776d6 --- /dev/null +++ b/devtools/client/debugger/test/mochitest/browser_dbg_search-basic-03.js @@ -0,0 +1,123 @@ +/* Any copyright is dedicated to the Public Domain. + http://creativecommons.org/publicdomain/zero/1.0/ */ + +/** + * Tests that searches which cause a popup to be shown properly handle the + * ESCAPE key. + */ + +const TAB_URL = EXAMPLE_URL + "doc_script-switching-01.html"; + +var gTab, gPanel, gDebugger; +var gSources, gSearchBox; + +function test() { + let options = { + source: EXAMPLE_URL + "code_script-switching-01.js", + line: 1, + }; + initDebugger(TAB_URL, options).then(([aTab,, aPanel]) => { + gTab = aTab; + gPanel = aPanel; + gDebugger = gPanel.panelWin; + gSources = gDebugger.DebuggerView.Sources; + gSearchBox = gDebugger.DebuggerView.Filtering._searchbox; + + // Calling `firstCall` is going to break into the other script + waitForSourceAndCaretAndScopes(gPanel, "-02.js", 6) + .then(performFileSearch) + .then(escapeAndHide) + .then(escapeAndClear) + .then(() => verifySourceAndCaret("-01.js", 1, 1)) + .then(performFunctionSearch) + .then(escapeAndHide) + .then(escapeAndClear) + .then(() => verifySourceAndCaret("-01.js", 4, 10)) + .then(performGlobalSearch) + .then(escapeAndClear) + .then(() => verifySourceAndCaret("-01.js", 4, 10)) + .then(() => resumeDebuggerThenCloseAndFinish(gPanel)) + .then(null, aError => { + ok(false, "Got an error: " + aError.message + "\n" + aError.stack); + }); + + callInTab(gTab, "firstCall"); + }); +} + +function performFileSearch() { + let finished = promise.all([ + ensureSourceIs(gPanel, "-02.js"), + ensureCaretAt(gPanel, 6), + once(gDebugger, "popupshown"), + waitForDebuggerEvents(gPanel, gDebugger.EVENTS.FILE_SEARCH_MATCH_FOUND), + waitForSourceShown(gPanel, "-01.js") + ]); + + setText(gSearchBox, "."); + + return finished.then(() => promise.all([ + ensureSourceIs(gPanel, "-01.js"), + ensureCaretAt(gPanel, 1) + ])); +} + +function performFunctionSearch() { + let finished = promise.all([ + ensureSourceIs(gPanel, "-01.js"), + ensureCaretAt(gPanel, 1), + once(gDebugger, "popupshown"), + waitForDebuggerEvents(gPanel, gDebugger.EVENTS.FUNCTION_SEARCH_MATCH_FOUND) + ]); + + setText(gSearchBox, "@"); + + return finished.then(() => promise.all([ + ensureSourceIs(gPanel, "-01.js"), + ensureCaretAt(gPanel, 4, 10) + ])); +} + +function performGlobalSearch() { + let finished = promise.all([ + ensureSourceIs(gPanel, "-01.js"), + ensureCaretAt(gPanel, 4, 10), + waitForDebuggerEvents(gPanel, gDebugger.EVENTS.GLOBAL_SEARCH_MATCH_FOUND) + ]); + + setText(gSearchBox, "!first"); + + return finished.then(() => promise.all([ + ensureSourceIs(gPanel, "-01.js"), + ensureCaretAt(gPanel, 4, 10) + ])); +} + +function escapeAndHide() { + let finished = once(gDebugger, "popuphidden", true); + EventUtils.sendKey("ESCAPE", gDebugger); + return finished; +} + +function escapeAndClear() { + EventUtils.sendKey("ESCAPE", gDebugger); + is(gSearchBox.getAttribute("value"), "", + "The searchbox has properly emptied after pressing escape."); +} + +function verifySourceAndCaret(aUrl, aLine, aColumn) { + ok(gSources.selectedItem.attachment.label.includes(aUrl), + "The selected item's label appears to be correct."); + ok(gSources.selectedItem.attachment.source.url.includes(aUrl), + "The selected item's value appears to be correct."); + ok(isCaretPos(gPanel, aLine, aColumn), + "The current caret position appears to be correct."); +} + +registerCleanupFunction(function () { + gTab = null; + gPanel = null; + gDebugger = null; + gSources = null; + gSearchBox = null; +}); -- cgit v1.2.3