2012-09-11 12:50:19 -07:00
|
|
|
/* 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 gScripts = 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;
|
2012-11-30 00:07:59 -08:00
|
|
|
gDebugger = gPane.panelWin;
|
2012-11-21 00:49:45 -08:00
|
|
|
gDebugger.SourceResults.prototype.alwaysExpand = false;
|
2012-09-11 12:50:19 -07:00
|
|
|
|
|
|
|
gDebugger.DebuggerController.activeThread.addOneTimeListener("framesadded", function() {
|
|
|
|
framesAdded = true;
|
|
|
|
runTest();
|
|
|
|
});
|
|
|
|
|
|
|
|
gDebuggee.firstCall();
|
|
|
|
});
|
|
|
|
|
2012-10-26 10:10:17 -07:00
|
|
|
window.addEventListener("Debugger:SourceShown", function _onEvent(aEvent) {
|
2012-09-11 12:50:19 -07:00
|
|
|
let url = aEvent.detail.url;
|
|
|
|
if (url.indexOf("-02.js") != -1) {
|
|
|
|
scriptShown = true;
|
|
|
|
window.removeEventListener(aEvent.type, _onEvent);
|
|
|
|
runTest();
|
|
|
|
}
|
|
|
|
});
|
|
|
|
|
|
|
|
function runTest()
|
|
|
|
{
|
|
|
|
if (scriptShown && framesAdded) {
|
|
|
|
Services.tm.currentThread.dispatch({ run: testScriptSearching }, 0);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
function testScriptSearching() {
|
|
|
|
gDebugger.DebuggerController.activeThread.resume(function() {
|
|
|
|
gEditor = gDebugger.DebuggerView.editor;
|
2012-10-26 10:10:17 -07:00
|
|
|
gScripts = gDebugger.DebuggerView.Sources;
|
2012-09-11 12:50:19 -07:00
|
|
|
gSearchView = gDebugger.DebuggerView.GlobalSearch;
|
2012-10-26 10:10:17 -07:00
|
|
|
gSearchBox = gDebugger.DebuggerView.Filtering._searchbox;
|
2012-09-11 12:50:19 -07:00
|
|
|
|
|
|
|
doSearch();
|
|
|
|
});
|
|
|
|
}
|
|
|
|
|
|
|
|
function doSearch() {
|
2012-10-26 10:10:17 -07:00
|
|
|
is(gSearchView._container._parent.hidden, true,
|
2012-09-11 12:50:19 -07:00
|
|
|
"The global search pane shouldn't be visible yet.");
|
|
|
|
|
|
|
|
window.addEventListener("Debugger:GlobalSearch:MatchFound", function _onEvent(aEvent) {
|
|
|
|
window.removeEventListener(aEvent.type, _onEvent);
|
2012-10-26 10:10:17 -07:00
|
|
|
info("Current script url:\n" + gScripts.selectedValue + "\n");
|
2012-09-11 12:50:19 -07:00
|
|
|
info("Debugger editor text:\n" + gEditor.getText() + "\n");
|
|
|
|
|
2012-10-26 10:10:17 -07:00
|
|
|
let url = gScripts.selectedValue;
|
2012-09-11 12:50:19 -07:00
|
|
|
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()
|
|
|
|
{
|
2012-10-26 10:10:17 -07:00
|
|
|
is(gSearchView._container._parent.hidden, false,
|
2012-09-11 12:50:19 -07:00
|
|
|
"The global search pane should be visible after a search.");
|
|
|
|
|
|
|
|
window.addEventListener("Debugger:GlobalSearch:ViewCleared", function _onEvent(aEvent) {
|
|
|
|
window.removeEventListener(aEvent.type, _onEvent);
|
2012-10-26 10:10:17 -07:00
|
|
|
info("Current script url:\n" + gScripts.selectedValue + "\n");
|
2012-09-11 12:50:19 -07:00
|
|
|
info("Debugger editor text:\n" + gEditor.getText() + "\n");
|
|
|
|
|
2012-10-26 10:10:17 -07:00
|
|
|
let url = gScripts.selectedValue;
|
2012-09-11 12:50:19 -07:00
|
|
|
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() {
|
2012-10-26 10:10:17 -07:00
|
|
|
is(gSearchView._container._parent.hidden, true,
|
2012-09-11 12:50:19 -07:00
|
|
|
"The global search pane shouldn't be visible after the search was stopped.");
|
|
|
|
|
|
|
|
window.addEventListener("Debugger:GlobalSearch:MatchFound", function _onEvent(aEvent) {
|
|
|
|
window.removeEventListener(aEvent.type, _onEvent);
|
2012-10-26 10:10:17 -07:00
|
|
|
info("Current script url:\n" + gScripts.selectedValue + "\n");
|
2012-09-11 12:50:19 -07:00
|
|
|
info("Debugger editor text:\n" + gEditor.getText() + "\n");
|
|
|
|
|
2012-10-26 10:10:17 -07:00
|
|
|
let url = gScripts.selectedValue;
|
2012-09-11 12:50:19 -07:00
|
|
|
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()
|
|
|
|
{
|
2012-10-26 10:10:17 -07:00
|
|
|
is(gSearchView._container._parent.hidden, false,
|
2012-09-11 12:50:19 -07:00
|
|
|
"The global search pane should be visible after a re-search.");
|
|
|
|
|
|
|
|
window.addEventListener("Debugger:GlobalSearch:ViewCleared", function _onEvent(aEvent) {
|
|
|
|
window.removeEventListener(aEvent.type, _onEvent);
|
2012-10-26 10:10:17 -07:00
|
|
|
info("Current script url:\n" + gScripts.selectedValue + "\n");
|
2012-09-11 12:50:19 -07:00
|
|
|
info("Debugger editor text:\n" + gEditor.getText() + "\n");
|
|
|
|
|
2012-10-26 10:10:17 -07:00
|
|
|
let url = gScripts.selectedValue;
|
2012-09-11 12:50:19 -07:00
|
|
|
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()
|
|
|
|
{
|
2012-10-26 10:10:17 -07:00
|
|
|
is(gSearchView._container._parent.hidden, true,
|
2012-09-11 12:50:19 -07:00
|
|
|
"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");
|
|
|
|
}
|
|
|
|
|
|
|
|
function sendEscape() {
|
|
|
|
gSearchBox.focus();
|
|
|
|
EventUtils.sendKey("ESCAPE");
|
|
|
|
}
|
|
|
|
|
|
|
|
function append(text) {
|
|
|
|
gSearchBox.focus();
|
|
|
|
|
|
|
|
for (let i = 0; i < text.length; i++) {
|
|
|
|
EventUtils.sendChar(text[i]);
|
|
|
|
}
|
|
|
|
info("Editor caret position: " + gEditor.getCaretPosition().toSource() + "\n");
|
|
|
|
}
|
|
|
|
|
|
|
|
registerCleanupFunction(function() {
|
|
|
|
removeTab(gTab);
|
|
|
|
gPane = null;
|
|
|
|
gTab = null;
|
|
|
|
gDebuggee = null;
|
|
|
|
gDebugger = null;
|
|
|
|
gEditor = null;
|
|
|
|
gScripts = null;
|
2012-09-11 12:50:20 -07:00
|
|
|
gSearchView = null;
|
2012-09-11 12:50:19 -07:00
|
|
|
gSearchBox = null;
|
|
|
|
});
|