diff options
author | wolfbeast <mcwerewolf@gmail.com> | 2014-05-21 11:38:25 +0200 |
---|---|---|
committer | wolfbeast <mcwerewolf@gmail.com> | 2014-05-21 11:38:25 +0200 |
commit | d25ba7d760b017b038e5aa6c0a605b4a330eb68d (patch) | |
tree | 16ec27edc7d5f83986f16236d3a36a2682a0f37e /browser/devtools/debugger/test/browser_dbg_scripts-searching-08.js | |
parent | a942906574671868daf122284a9c4689e6924f74 (diff) | |
download | palemoon-gre-d25ba7d760b017b038e5aa6c0a605b4a330eb68d.tar.gz |
Recommit working copy to repo with proper line endings.
Diffstat (limited to 'browser/devtools/debugger/test/browser_dbg_scripts-searching-08.js')
-rw-r--r-- | browser/devtools/debugger/test/browser_dbg_scripts-searching-08.js | 208 |
1 files changed, 208 insertions, 0 deletions
diff --git a/browser/devtools/debugger/test/browser_dbg_scripts-searching-08.js b/browser/devtools/debugger/test/browser_dbg_scripts-searching-08.js new file mode 100644 index 000000000..70809fa69 --- /dev/null +++ b/browser/devtools/debugger/test/browser_dbg_scripts-searching-08.js @@ -0,0 +1,208 @@ +/* vim:set ts=2 sw=2 sts=2 et: */ +/* Any copyright is dedicated to the Public Domain. + http://creativecommons.org/publicdomain/zero/1.0/ */ + +const TAB_URL = EXAMPLE_URL + "browser_dbg_script-switching.html"; + +/** + * Tests if the global search results are hidden when they're supposed to + * (after a focus lost, or when ESCAPE is pressed). + */ + +var gPane = null; +var gTab = null; +var gDebuggee = null; +var gDebugger = null; +var gEditor = null; +var gSources = null; +var gSearchView = null; +var gSearchBox = null; + +function test() +{ + let scriptShown = false; + let framesAdded = false; + + debug_tab_pane(TAB_URL, function(aTab, aDebuggee, aPane) { + gTab = aTab; + gDebuggee = aDebuggee; + gPane = aPane; + gDebugger = gPane.panelWin; + gDebugger.SourceResults.prototype.alwaysExpand = false; + + gDebugger.addEventListener("Debugger:SourceShown", function _onEvent(aEvent) { + let url = aEvent.detail.url; + if (url.indexOf("-02.js") != -1) { + scriptShown = true; + gDebugger.removeEventListener(aEvent.type, _onEvent); + runTest(); + } + }); + + gDebugger.DebuggerController.activeThread.addOneTimeListener("framesadded", function() { + framesAdded = true; + runTest(); + }); + + gDebuggee.firstCall(); + }); + + function runTest() + { + if (scriptShown && framesAdded) { + Services.tm.currentThread.dispatch({ run: testScriptSearching }, 0); + } + } +} + +function testScriptSearching() { + gEditor = gDebugger.DebuggerView.editor; + gSources = gDebugger.DebuggerView.Sources; + gSearchView = gDebugger.DebuggerView.GlobalSearch; + gSearchBox = gDebugger.DebuggerView.Filtering._searchbox; + + doSearch(); +} + +function doSearch() { + is(gSearchView.widget._parent.hidden, true, + "The global search pane shouldn't be visible yet."); + + gDebugger.addEventListener("Debugger:GlobalSearch:MatchFound", function _onEvent(aEvent) { + gDebugger.removeEventListener(aEvent.type, _onEvent); + info("Current script url:\n" + gSources.selectedValue + "\n"); + info("Debugger editor text:\n" + gEditor.getText() + "\n"); + + let url = gSources.selectedValue; + if (url.indexOf("-02.js") != -1) { + executeSoon(function() { + testFocusLost(); + }); + } else { + ok(false, "The current script shouldn't have changed after a global search."); + } + }); + executeSoon(function() { + write("!a"); + }); +} + +function testFocusLost() +{ + is(gSearchView.widget._parent.hidden, false, + "The global search pane should be visible after a search."); + + gDebugger.addEventListener("Debugger:GlobalSearch:ViewCleared", function _onEvent(aEvent) { + gDebugger.removeEventListener(aEvent.type, _onEvent); + info("Current script url:\n" + gSources.selectedValue + "\n"); + info("Debugger editor text:\n" + gEditor.getText() + "\n"); + + let url = gSources.selectedValue; + if (url.indexOf("-02.js") != -1) { + executeSoon(function() { + reshowSearch(); + }); + } else { + ok(false, "The current script shouldn't have changed after the global search stopped."); + } + }); + executeSoon(function() { + gDebugger.DebuggerView.editor.focus(); + }); +} + +function reshowSearch() { + is(gSearchView.widget._parent.hidden, true, + "The global search pane shouldn't be visible after the search was stopped."); + + gDebugger.addEventListener("Debugger:GlobalSearch:MatchFound", function _onEvent(aEvent) { + gDebugger.removeEventListener(aEvent.type, _onEvent); + info("Current script url:\n" + gSources.selectedValue + "\n"); + info("Debugger editor text:\n" + gEditor.getText() + "\n"); + + let url = gSources.selectedValue; + if (url.indexOf("-02.js") != -1) { + executeSoon(function() { + testEscape(); + }); + } else { + ok(false, "The current script shouldn't have changed after a global re-search."); + } + }); + executeSoon(function() { + sendEnter(); + }); +} + +function testEscape() +{ + is(gSearchView.widget._parent.hidden, false, + "The global search pane should be visible after a re-search."); + + gDebugger.addEventListener("Debugger:GlobalSearch:ViewCleared", function _onEvent(aEvent) { + gDebugger.removeEventListener(aEvent.type, _onEvent); + info("Current script url:\n" + gSources.selectedValue + "\n"); + info("Debugger editor text:\n" + gEditor.getText() + "\n"); + + let url = gSources.selectedValue; + if (url.indexOf("-02.js") != -1) { + executeSoon(function() { + finalCheck(); + }); + } else { + ok(false, "The current script shouldn't have changed after the global search escaped."); + } + }); + executeSoon(function() { + sendEscape(); + }); +} + +function finalCheck() +{ + is(gSearchView.widget._parent.hidden, true, + "The global search pane shouldn't be visible after the search was escaped."); + + closeDebuggerAndFinish(); +} + +function clear() { + gSearchBox.focus(); + gSearchBox.value = ""; +} + +function write(text) { + clear(); + append(text); +} + +function sendEnter() { + gSearchBox.focus(); + EventUtils.sendKey("ENTER", gDebugger); +} + +function sendEscape() { + gSearchBox.focus(); + EventUtils.sendKey("ESCAPE", gDebugger); +} + +function append(text) { + gSearchBox.focus(); + + for (let i = 0; i < text.length; i++) { + EventUtils.sendChar(text[i], gDebugger); + } + info("Editor caret position: " + gEditor.getCaretPosition().toSource() + "\n"); +} + +registerCleanupFunction(function() { + removeTab(gTab); + gPane = null; + gTab = null; + gDebuggee = null; + gDebugger = null; + gEditor = null; + gSources = null; + gSearchView = null; + gSearchBox = null; +}); |