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 that the selection is dropped for line and token searches, after michael@0: * pressing backspace enough times. michael@0: */ michael@0: michael@0: const TAB_URL = EXAMPLE_URL + "doc_script-switching-01.html"; michael@0: michael@0: let gTab, gDebuggee, gPanel, gDebugger; michael@0: let gEditor, gSources, 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: gSearchBox = gDebugger.DebuggerView.Filtering._searchbox; michael@0: michael@0: waitForSourceShown(gPanel, "-01.js") michael@0: .then(testLineSearch) michael@0: .then(testTokenSearch) michael@0: .then(() => closeDebuggerAndFinish(gPanel)) michael@0: .then(null, aError => { michael@0: ok(false, "Got an error: " + aError.message + "\n" + aError.stack); michael@0: }); michael@0: }); michael@0: } michael@0: michael@0: function testLineSearch() { michael@0: setText(gSearchBox, ":42"); michael@0: ok(isCaretPos(gPanel, 7), michael@0: "The editor caret position appears to be correct (1.1)."); michael@0: ok(isEditorSel(gPanel, [160, 160]), michael@0: "The editor selection appears to be correct (1.1)."); michael@0: is(gEditor.getSelection(), "", michael@0: "The editor selected text appears to be correct (1.1)."); michael@0: michael@0: backspaceText(gSearchBox, 1); michael@0: ok(isCaretPos(gPanel, 4), michael@0: "The editor caret position appears to be correct (1.2)."); michael@0: ok(isEditorSel(gPanel, [110, 110]), michael@0: "The editor selection appears to be correct (1.2)."); michael@0: is(gEditor.getSelection(), "", michael@0: "The editor selected text appears to be correct (1.2)."); michael@0: michael@0: backspaceText(gSearchBox, 1); michael@0: ok(isCaretPos(gPanel, 4), michael@0: "The editor caret position appears to be correct (1.3)."); michael@0: ok(isEditorSel(gPanel, [110, 110]), michael@0: "The editor selection appears to be correct (1.3)."); michael@0: is(gEditor.getSelection(), "", michael@0: "The editor selected text appears to be correct (1.3)."); michael@0: michael@0: setText(gSearchBox, ":4"); michael@0: ok(isCaretPos(gPanel, 4), michael@0: "The editor caret position appears to be correct (1.4)."); michael@0: ok(isEditorSel(gPanel, [110, 110]), michael@0: "The editor selection appears to be correct (1.4)."); michael@0: is(gEditor.getSelection(), "", michael@0: "The editor selected text appears to be correct (1.4)."); michael@0: michael@0: gSearchBox.select(); michael@0: backspaceText(gSearchBox, 1); michael@0: ok(isCaretPos(gPanel, 4), michael@0: "The editor caret position appears to be correct (1.5)."); michael@0: ok(isEditorSel(gPanel, [110, 110]), michael@0: "The editor selection appears to be correct (1.5)."); michael@0: is(gEditor.getSelection(), "", michael@0: "The editor selected text appears to be correct (1.5)."); michael@0: is(gSearchBox.value, "", michael@0: "The searchbox should have been cleared."); michael@0: } michael@0: michael@0: function testTokenSearch() { michael@0: setText(gSearchBox, "#;\""); michael@0: ok(isCaretPos(gPanel, 5, 23), michael@0: "The editor caret position appears to be correct (2.1)."); michael@0: ok(isEditorSel(gPanel, [153, 155]), michael@0: "The editor selection appears to be correct (2.1)."); michael@0: is(gEditor.getSelection(), ";\"", michael@0: "The editor selected text appears to be correct (2.1)."); michael@0: michael@0: backspaceText(gSearchBox, 1); michael@0: ok(isCaretPos(gPanel, 5, 22), michael@0: "The editor caret position appears to be correct (2.2)."); michael@0: ok(isEditorSel(gPanel, [153, 154]), michael@0: "The editor selection appears to be correct (2.2)."); michael@0: is(gEditor.getSelection(), ";", michael@0: "The editor selected text appears to be correct (2.2)."); michael@0: michael@0: backspaceText(gSearchBox, 1); michael@0: ok(isCaretPos(gPanel, 5, 22), michael@0: "The editor caret position appears to be correct (2.3)."); michael@0: ok(isEditorSel(gPanel, [154, 154]), michael@0: "The editor selection appears to be correct (2.3)."); michael@0: is(gEditor.getSelection(), "", michael@0: "The editor selected text appears to be correct (2.3)."); michael@0: michael@0: setText(gSearchBox, "#;"); michael@0: ok(isCaretPos(gPanel, 5, 22), michael@0: "The editor caret position appears to be correct (2.4)."); michael@0: ok(isEditorSel(gPanel, [153, 154]), michael@0: "The editor selection appears to be correct (2.4)."); michael@0: is(gEditor.getSelection(), ";", michael@0: "The editor selected text appears to be correct (2.4)."); michael@0: michael@0: gSearchBox.select(); michael@0: backspaceText(gSearchBox, 1); michael@0: ok(isCaretPos(gPanel, 5, 22), michael@0: "The editor caret position appears to be correct (2.5)."); michael@0: ok(isEditorSel(gPanel, [154, 154]), michael@0: "The editor selection appears to be correct (2.5)."); michael@0: is(gEditor.getSelection(), "", michael@0: "The editor selected text appears to be correct (2.5)."); michael@0: is(gSearchBox.value, "", michael@0: "The searchbox should have been cleared."); 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: gSearchBox = null; michael@0: });