2012-08-18 13:29:47 +04: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";
|
|
|
|
|
2012-09-11 23:50:19 +04:00
|
|
|
/**
|
|
|
|
* Tests if the global search results are cleared on location changes, and
|
|
|
|
* the expected UI behaviors are triggered.
|
|
|
|
*/
|
|
|
|
|
2012-08-18 13:29:47 +04:00
|
|
|
var gPane = null;
|
|
|
|
var gTab = null;
|
|
|
|
var gDebuggee = null;
|
|
|
|
var gDebugger = null;
|
|
|
|
var gEditor = null;
|
2013-02-21 03:33:36 +04:00
|
|
|
var gSources = null;
|
2012-08-18 13:29:47 +04:00
|
|
|
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 12:07:59 +04:00
|
|
|
gDebugger = gPane.panelWin;
|
2012-11-21 12:49:45 +04:00
|
|
|
gDebugger.SourceResults.prototype.alwaysExpand = false;
|
2012-08-18 13:29:47 +04:00
|
|
|
|
2013-01-07 02:11:03 +04:00
|
|
|
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();
|
|
|
|
}
|
|
|
|
});
|
|
|
|
|
2012-08-18 13:29:47 +04:00
|
|
|
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() {
|
|
|
|
gDebugger.DebuggerController.activeThread.resume(function() {
|
|
|
|
gEditor = gDebugger.DebuggerView.editor;
|
2013-02-21 03:33:36 +04:00
|
|
|
gSources = gDebugger.DebuggerView.Sources;
|
2012-08-18 13:29:47 +04:00
|
|
|
gSearchView = gDebugger.DebuggerView.GlobalSearch;
|
2012-10-26 21:10:17 +04:00
|
|
|
gSearchBox = gDebugger.DebuggerView.Filtering._searchbox;
|
2012-08-18 13:29:47 +04:00
|
|
|
|
|
|
|
doSearch();
|
|
|
|
});
|
|
|
|
}
|
|
|
|
|
|
|
|
function doSearch() {
|
2013-06-21 18:33:56 +04:00
|
|
|
is(gSearchView.widget._list.childNodes.length, 0,
|
2012-08-18 13:29:47 +04:00
|
|
|
"The global search pane shouldn't have any child nodes yet.");
|
2013-06-21 18:33:56 +04:00
|
|
|
is(gSearchView.widget._parent.hidden, true,
|
2012-08-18 13:29:47 +04:00
|
|
|
"The global search pane shouldn't be visible yet.");
|
|
|
|
is(gSearchView._splitter.hidden, true,
|
|
|
|
"The global search pane splitter shouldn't be visible yet.");
|
|
|
|
|
2013-01-07 02:11:03 +04:00
|
|
|
gDebugger.addEventListener("Debugger:GlobalSearch:MatchFound", function _onEvent(aEvent) {
|
|
|
|
gDebugger.removeEventListener(aEvent.type, _onEvent);
|
2013-02-21 03:33:36 +04:00
|
|
|
info("Current script url:\n" + gSources.selectedValue + "\n");
|
2012-08-18 13:29:47 +04:00
|
|
|
info("Debugger editor text:\n" + gEditor.getText() + "\n");
|
|
|
|
|
2013-02-21 03:33:36 +04:00
|
|
|
let url = gSources.selectedValue;
|
2012-08-18 13:29:47 +04:00
|
|
|
if (url.indexOf("-02.js") != -1) {
|
|
|
|
executeSoon(function() {
|
|
|
|
info("Editor caret position: " + gEditor.getCaretPosition().toSource() + "\n");
|
|
|
|
ok(gEditor.getCaretPosition().line == 5 &&
|
|
|
|
gEditor.getCaretPosition().col == 0,
|
|
|
|
"The editor shouldn't have jumped to a matching line yet.");
|
2013-02-21 03:33:36 +04:00
|
|
|
is(gSources.visibleItems.length, 2,
|
2012-08-18 13:29:47 +04:00
|
|
|
"Not all the scripts are shown after the global search.");
|
|
|
|
|
2013-06-21 18:33:56 +04:00
|
|
|
isnot(gSearchView.widget._list.childNodes.length, 0,
|
2012-08-18 13:29:47 +04:00
|
|
|
"The global search pane should be visible now.");
|
2013-06-21 18:33:56 +04:00
|
|
|
isnot(gSearchView.widget._parent.hidden, true,
|
2012-08-18 13:29:47 +04:00
|
|
|
"The global search pane should be visible now.");
|
|
|
|
isnot(gSearchView._splitter.hidden, true,
|
|
|
|
"The global search pane splitter should be visible now.");
|
|
|
|
|
|
|
|
testLocationChange();
|
|
|
|
});
|
|
|
|
} else {
|
|
|
|
ok(false, "The current script shouldn't have changed after a global search.");
|
|
|
|
}
|
|
|
|
});
|
|
|
|
executeSoon(function() {
|
|
|
|
write("!eval");
|
|
|
|
});
|
|
|
|
}
|
|
|
|
|
|
|
|
function testLocationChange()
|
|
|
|
{
|
2013-04-04 12:23:42 +04:00
|
|
|
gDebugger.DebuggerController._target.once("navigate", function onTabNavigated(aEvent, aPacket) {
|
2013-03-25 22:02:34 +04:00
|
|
|
ok(true, "tabNavigated event was fired after location change.");
|
|
|
|
info("Still attached to the tab.");
|
2012-08-18 13:29:47 +04:00
|
|
|
|
2013-03-25 22:02:34 +04:00
|
|
|
executeSoon(function() {
|
2013-06-21 18:33:56 +04:00
|
|
|
is(gSearchView.widget._list.childNodes.length, 0,
|
2013-03-25 22:02:34 +04:00
|
|
|
"The global search pane shouldn't have any child nodes after a page navigation.");
|
2013-06-21 18:33:56 +04:00
|
|
|
is(gSearchView.widget._parent.hidden, true,
|
2013-03-25 22:02:34 +04:00
|
|
|
"The global search pane shouldn't be visible after a page navigation.");
|
|
|
|
is(gSearchView._splitter.hidden, true,
|
|
|
|
"The global search pane splitter shouldn't be visible after a page navigation.");
|
2012-08-18 13:29:47 +04:00
|
|
|
|
2013-03-25 22:02:34 +04:00
|
|
|
is(gDebugger.DebuggerController.SourceScripts.getCache().length, 0,
|
|
|
|
"The scripts sources cache for global searching should be cleared after a page navigation.")
|
2012-08-18 13:29:47 +04:00
|
|
|
|
2013-03-25 22:02:34 +04:00
|
|
|
closeDebuggerAndFinish();
|
|
|
|
});
|
2012-08-18 13:29:47 +04:00
|
|
|
});
|
|
|
|
|
|
|
|
content.location = TAB1_URL;
|
|
|
|
}
|
|
|
|
|
|
|
|
function clear() {
|
|
|
|
gSearchBox.focus();
|
|
|
|
gSearchBox.value = "";
|
|
|
|
}
|
|
|
|
|
|
|
|
function write(text) {
|
|
|
|
clear();
|
|
|
|
append(text);
|
|
|
|
}
|
|
|
|
|
|
|
|
function append(text) {
|
|
|
|
gSearchBox.focus();
|
|
|
|
|
|
|
|
for (let i = 0; i < text.length; i++) {
|
2013-01-07 02:11:03 +04:00
|
|
|
EventUtils.sendChar(text[i], gDebugger);
|
2012-08-18 13:29:47 +04:00
|
|
|
}
|
|
|
|
info("Editor caret position: " + gEditor.getCaretPosition().toSource() + "\n");
|
|
|
|
}
|
|
|
|
|
|
|
|
registerCleanupFunction(function() {
|
|
|
|
removeTab(gTab);
|
|
|
|
gPane = null;
|
|
|
|
gTab = null;
|
|
|
|
gDebuggee = null;
|
|
|
|
gDebugger = null;
|
|
|
|
gEditor = null;
|
2013-02-21 03:33:36 +04:00
|
|
|
gSources = null;
|
2012-09-11 23:50:20 +04:00
|
|
|
gSearchView = null;
|
2012-08-18 13:29:47 +04:00
|
|
|
gSearchBox = null;
|
|
|
|
});
|