This commit is contained in:
Kyle Huey 2012-04-09 14:53:10 -07:00
Родитель 1cb9c37463 208fedac2a
Коммит 339b89a35d
10 изменённых файлов: 459 добавлений и 92 удалений

Просмотреть файл

@ -83,10 +83,7 @@ Site.prototype = {
* when done.
*/
block: function Site_block() {
if (gBlockedLinks.isBlocked(this._link)) {
if (aCallback)
aCallback();
} else {
if (!gBlockedLinks.isBlocked(this._link)) {
gBlockedLinks.block(this._link);
gUpdater.updateGrid();
}

Просмотреть файл

@ -20,62 +20,80 @@ var gScripts = 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.debuggerWindow;
testScriptsDisplay();
gPane.activeThread.addOneTimeListener("framesadded", function() {
framesAdded = true;
runTest();
});
gDebuggee.firstCall();
});
window.addEventListener("Debugger:ScriptShown", function _onEvent(aEvent) {
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: testScriptsDisplay }, 0);
}
}
}
function testScriptsDisplay() {
gPane.activeThread.addOneTimeListener("framesadded", function() {
Services.tm.currentThread.dispatch({ run: function() {
gScripts = gDebugger.DebuggerView.Scripts._scripts;
gScripts = gDebugger.DebuggerView.Scripts._scripts;
is(gDebugger.StackFrames.activeThread.state, "paused",
"Should only be getting stack frames while paused.");
is(gDebugger.StackFrames.activeThread.state, "paused",
"Should only be getting stack frames while paused.");
is(gScripts.itemCount, 2, "Found the expected number of scripts.");
is(gScripts.itemCount, 2, "Found the expected number of scripts.");
for (let i = 0; i < gScripts.itemCount; i++) {
info("label: " + i + " " + gScripts.getItemAtIndex(i).getAttribute("label"));
}
for (let i = 0; i < gScripts.itemCount; i++) {
info("label: " + i + " " + gScripts.getItemAtIndex(i).getAttribute("label"));
}
let label1 = "test-script-switching-01.js";
let label2 = "test-script-switching-02.js";
let label1 = "test-script-switching-01.js";
let label2 = "test-script-switching-02.js";
ok(gDebugger.DebuggerView.Scripts.contains(EXAMPLE_URL +
label1), "First script url is incorrect.");
ok(gDebugger.DebuggerView.Scripts.contains(EXAMPLE_URL +
label2), "Second script url is incorrect.");
ok(gDebugger.DebuggerView.Scripts.contains(EXAMPLE_URL +
label1), "First script url is incorrect.");
ok(gDebugger.DebuggerView.Scripts.contains(EXAMPLE_URL +
label2), "Second script url is incorrect.");
ok(gDebugger.DebuggerView.Scripts.containsLabel(
label1), "First script label is incorrect.");
ok(gDebugger.DebuggerView.Scripts.containsLabel(
label2), "Second script label is incorrect.");
ok(gDebugger.DebuggerView.Scripts.containsLabel(
label1), "First script label is incorrect.");
ok(gDebugger.DebuggerView.Scripts.containsLabel(
label2), "Second script label is incorrect.");
ok(gDebugger.editor.getText().search(/debugger/) != -1,
"The correct script was loaded initially.");
ok(gDebugger.editor.getText().search(/debugger/) != -1,
"The correct script was loaded initially.");
is(gDebugger.editor.getDebugLocation(), 5,
"editor debugger location is correct.");
is(gDebugger.editor.getDebugLocation(), 5,
"editor debugger location is correct.");
gDebugger.editor.addEventListener(SourceEditor.EVENTS.TEXT_CHANGED,
function onChange() {
gDebugger.editor.removeEventListener(SourceEditor.EVENTS.TEXT_CHANGED,
onChange);
testSwitchPaused();
});
gScripts.selectedIndex = 0;
gDebugger.SourceScripts.onChange({ target: gScripts });
}}, 0);
window.addEventListener("Debugger:ScriptShown", function _onEvent(aEvent) {
let url = aEvent.detail.url;
if (url.indexOf("-01.js") != -1) {
window.removeEventListener(aEvent.type, _onEvent);
testSwitchPaused();
}
});
gDebuggee.firstCall();
gDebugger.DebuggerView.Scripts.selectScript(EXAMPLE_URL + label1);
}
function testSwitchPaused()
@ -90,14 +108,16 @@ function testSwitchPaused()
"editor debugger location has been cleared.");
gDebugger.StackFrames.activeThread.resume(function() {
gDebugger.editor.addEventListener(SourceEditor.EVENTS.TEXT_CHANGED,
function onSecondChange() {
gDebugger.editor.removeEventListener(SourceEditor.EVENTS.TEXT_CHANGED,
onSecondChange);
testSwitchRunning();
window.addEventListener("Debugger:ScriptShown", function _onEvent(aEvent) {
let url = aEvent.detail.url;
if (url.indexOf("-02.js") != -1) {
window.removeEventListener(aEvent.type, _onEvent);
testSwitchRunning();
}
});
gScripts.selectedIndex = 1;
gDebugger.SourceScripts.onChange({ target: gScripts });
gDebugger.DebuggerView.Scripts.selectScript(EXAMPLE_URL +
"test-script-switching-02.js");
});
}

Просмотреть файл

@ -20,44 +20,63 @@ var gScripts = 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.debuggerWindow;
testScriptsDisplay();
gPane.activeThread.addOneTimeListener("framesadded", function() {
framesAdded = true;
runTest();
});
gDebuggee.firstCall();
});
window.addEventListener("Debugger:ScriptShown", function _onEvent(aEvent) {
let url = aEvent.detail.url;
if (url.indexOf("editor-mode") != -1) {
scriptShown = true;
window.removeEventListener(aEvent.type, _onEvent);
runTest();
}
});
function runTest()
{
if (scriptShown && framesAdded) {
Services.tm.currentThread.dispatch({ run: testScriptsDisplay }, 0);
}
}
}
function testScriptsDisplay() {
gPane.activeThread.addOneTimeListener("framesadded", function() {
Services.tm.currentThread.dispatch({ run: function() {
gScripts = gDebugger.DebuggerView.Scripts._scripts;
gScripts = gDebugger.DebuggerView.Scripts._scripts;
is(gDebugger.StackFrames.activeThread.state, "paused",
"Should only be getting stack frames while paused.");
is(gDebugger.StackFrames.activeThread.state, "paused",
"Should only be getting stack frames while paused.");
is(gScripts.itemCount, 2, "Found the expected number of scripts.");
is(gScripts.itemCount, 2, "Found the expected number of scripts.");
is(gDebugger.editor.getMode(), SourceEditor.MODES.HTML,
"Found the expected editor mode.");
is(gDebugger.editor.getMode(), SourceEditor.MODES.HTML,
"Found the expected editor mode.");
ok(gDebugger.editor.getText().search(/debugger/) != -1,
"The correct script was loaded initially.");
ok(gDebugger.editor.getText().search(/debugger/) != -1,
"The correct script was loaded initially.");
gDebugger.editor.addEventListener(SourceEditor.EVENTS.TEXT_CHANGED,
function onChange() {
gDebugger.editor.removeEventListener(SourceEditor.EVENTS.TEXT_CHANGED,
onChange);
testSwitchPaused();
});
gScripts.selectedIndex = 0;
gDebugger.SourceScripts.onChange({ target: gScripts });
}}, 0);
window.addEventListener("Debugger:ScriptShown", function _onEvent(aEvent) {
let url = aEvent.detail.url;
if (url.indexOf("switching-01.js") != -1) {
window.removeEventListener(aEvent.type, _onEvent);
testSwitchPaused();
}
});
gDebuggee.firstCall();
let url = gDebuggee.document.querySelector("script").src;
gDebugger.DebuggerView.Scripts.selectScript(url);
}
function testSwitchPaused()

Просмотреть файл

@ -153,15 +153,19 @@ const DEFAULT_KEYBINDINGS = [
alt: true,
},
{
action: "Comment",
action: "Comment/Uncomment",
code: Ci.nsIDOMKeyEvent.DOM_VK_SLASH,
accel: true,
},
{
action: "Uncomment",
code: Ci.nsIDOMKeyEvent.DOM_VK_SLASH,
action: "Move to Bracket Opening",
code: Ci.nsIDOMKeyEvent.DOM_VK_OPEN_BRACKET,
accel: true,
},
{
action: "Move to Bracket Closing",
code: Ci.nsIDOMKeyEvent.DOM_VK_CLOSE_BRACKET,
accel: true,
shift: true,
},
];
@ -403,8 +407,9 @@ SourceEditor.prototype = {
"Find Previous Occurrence": [this.ui.findPrevious, this.ui],
"Goto Line...": [this.ui.gotoLine, this.ui],
"Move Lines Down": [this._moveLines, this],
"Comment": [this._doComment, this],
"Uncomment": [this._doUncomment, this],
"Comment/Uncomment": [this._doCommentUncomment, this],
"Move to Bracket Opening": [this._moveToBracketOpening, this],
"Move to Bracket Closing": [this._moveToBracketClosing, this],
};
for (let name in actions) {
@ -1050,6 +1055,63 @@ SourceEditor.prototype = {
return {line: line, blockStart: blockCommentStart, blockEnd: blockCommentEnd};
},
/**
* Decide whether to comment the selection/current line or to uncomment it.
*
* @private
*/
_doCommentUncomment: function SE__doCommentUncomment()
{
if (this.readOnly) {
return false;
}
let commentObject = this._getCommentStrings();
if (!commentObject) {
return false;
}
let selection = this.getSelection();
let model = this._model;
let firstLine = model.getLineAtOffset(selection.start);
let lastLine = model.getLineAtOffset(selection.end);
// Checks for block comment.
let firstLineText = model.getLine(firstLine);
let lastLineText = model.getLine(lastLine);
let openIndex = firstLineText.indexOf(commentObject.blockStart);
let closeIndex = lastLineText.lastIndexOf(commentObject.blockEnd);
if (openIndex != -1 && closeIndex != -1 &&
(firstLine != lastLine ||
(closeIndex - openIndex) >= commentObject.blockStart.length)) {
return this._doUncomment();
}
if (!commentObject.line) {
return this._doComment();
}
// If the selection is not a block comment, check for the first and the last
// lines to be line commented.
let firstLastCommented = [firstLineText,
lastLineText].every(function(aLineText) {
let openIndex = aLineText.indexOf(commentObject.line);
if (openIndex != -1) {
let textUntilComment = aLineText.slice(0, openIndex);
if (!textUntilComment || /^\s+$/.test(textUntilComment)) {
return true;
}
}
return false;
});
if (firstLastCommented) {
return this._doUncomment();
}
// If we reach here, then we have to comment the selection/line.
return this._doComment();
},
/**
* Wrap the selected text in comments. If nothing is selected the current
* caret line is commented out. Single line and block comments depend on the
@ -1123,7 +1185,9 @@ SourceEditor.prototype = {
let lastLineText = this._model.getLine(lastLine);
let openIndex = firstLineText.indexOf(commentObject.blockStart);
let closeIndex = lastLineText.lastIndexOf(commentObject.blockEnd);
if (openIndex != -1 && closeIndex != -1) {
if (openIndex != -1 && closeIndex != -1 &&
(firstLine != lastLine ||
(closeIndex - openIndex) >= commentObject.blockStart.length)) {
let firstLineStartOffset = this.getLineStart(firstLine);
let lastLineStartOffset = this.getLineStart(lastLine);
let openOffset = firstLineStartOffset + openIndex;
@ -1161,6 +1225,99 @@ SourceEditor.prototype = {
return true;
},
/**
* Helper function for _moveToBracket{Opening/Closing} to find the offset of
* matching bracket.
*
* @param number aOffset
* The offset of the bracket for which you want to find the bracket.
* @private
*/
_getMatchingBracketIndex: function SE__getMatchingBracketIndex(aOffset)
{
return this._styler._findMatchingBracket(this._model, aOffset);
},
/**
* Move the cursor to the matching opening bracket if at corresponding closing
* bracket, otherwise move to the opening bracket for the current block of code.
*
* @private
*/
_moveToBracketOpening: function SE__moveToBracketOpening()
{
let mode = this.getMode();
// Returning early if not in JavaScipt or CSS mode.
if (mode != SourceEditor.MODES.JAVASCRIPT &&
mode != SourceEditor.MODES.CSS) {
return false;
}
let caretOffset = this.getCaretOffset() - 1;
let matchingIndex = this._getMatchingBracketIndex(caretOffset);
// If the caret is not at the closing bracket "}", find the index of the
// opening bracket "{" for the current code block.
if (matchingIndex == -1 || matchingIndex > caretOffset) {
let text = this.getText();
let closingOffset = text.indexOf("}", caretOffset);
while (closingOffset > -1) {
let closingMatchingIndex = this._getMatchingBracketIndex(closingOffset);
if (closingMatchingIndex < caretOffset && closingMatchingIndex != -1) {
matchingIndex = closingMatchingIndex;
break;
}
closingOffset = text.indexOf("}", closingOffset + 1);
}
}
if (matchingIndex > -1) {
this.setCaretOffset(matchingIndex);
}
return true;
},
/**
* Moves the cursor to the matching closing bracket if at corresponding opening
* bracket, otherwise move to the closing bracket for the current block of code.
*
* @private
*/
_moveToBracketClosing: function SE__moveToBracketClosing()
{
let mode = this.getMode();
// Returning early if not in JavaScipt or CSS mode.
if (mode != SourceEditor.MODES.JAVASCRIPT &&
mode != SourceEditor.MODES.CSS) {
return false;
}
let caretOffset = this.getCaretOffset();
let matchingIndex = this._getMatchingBracketIndex(caretOffset - 1);
// If the caret is not at the opening bracket "{", find the index of the
// closing bracket "}" for the current code block.
if (matchingIndex == -1 || matchingIndex < caretOffset) {
let text = this.getText();
let openingOffset = text.lastIndexOf("{", caretOffset);
while (openingOffset > -1) {
let openingMatchingIndex = this._getMatchingBracketIndex(openingOffset);
if (openingMatchingIndex > caretOffset) {
matchingIndex = openingMatchingIndex;
break;
}
openingOffset = text.lastIndexOf("{", openingOffset - 1);
}
}
if (matchingIndex > -1) {
this.setCaretOffset(matchingIndex);
}
return true;
},
/**
* Add an event listener to the editor. You can use one of the known events.
*

Просмотреть файл

@ -63,6 +63,7 @@ _BROWSER_TEST_FILES = \
browser_bug729480_line_vertical_align.js \
browser_bug725430_comment_uncomment.js \
browser_bug731721_debugger_stepping.js \
browser_bug729960_block_bracket_jump.js \
head.js \
libs:: $(_BROWSER_TEST_FILES)

Просмотреть файл

@ -48,7 +48,7 @@ function test() {
editor.redo();
is(editor.getText(), "//" + text, "Redo works");
editor.setCaretPosition(0);
EventUtils.synthesizeKey("/", {accelKey: true, shiftKey: true}, testWin);
EventUtils.synthesizeKey("/", {accelKey: true}, testWin);
is(editor.getText(), text, "JS Single Line Uncommenting works");
editor.setText(text);
@ -61,18 +61,18 @@ function test() {
editor.redo();
is(editor.getText(), "/*" + text + "*/", "Redo works");
EventUtils.synthesizeKey("VK_A", {accelKey: true}, testWin);
EventUtils.synthesizeKey("/", {accelKey: true, shiftKey: true}, testWin);
EventUtils.synthesizeKey("/", {accelKey: true}, testWin);
is(editor.getText(), text, "JS Block Uncommenting works");
editor.undo();
is(editor.getText(), "/*" + text + "*/", "Undo Block Uncommenting works");
editor.redo();
is(editor.getText(), text, "Redo works");
let regText = "//firstline\n // secondline\nthird//line\nfourthline//";
let expText = "firstline\n secondline\nthird//line\nfourthline//";
let regText = "//firstline\n // secondline\nthird//line\n//fourthline";
let expText = "firstline\n secondline\nthird//line\nfourthline";
editor.setText(regText);
EventUtils.synthesizeKey("VK_A", {accelKey: true}, testWin);
EventUtils.synthesizeKey("/", {accelKey: true, shiftKey: true}, testWin);
EventUtils.synthesizeKey("/", {accelKey: true}, testWin);
is(editor.getText(), expText, "JS Multiple Line Uncommenting works");
editor.undo();
is(editor.getText(), regText, "Undo Multiple Line Uncommenting works");
@ -87,7 +87,7 @@ function test() {
EventUtils.synthesizeKey("/", {accelKey: true}, testWin);
is(editor.getText(), expText, "CSS Commenting without selection works");
editor.setCaretPosition(0);
EventUtils.synthesizeKey("/", {accelKey: true, shiftKey: true}, testWin);
EventUtils.synthesizeKey("/", {accelKey: true}, testWin);
is(editor.getText(), text, "CSS Uncommenting without selection works");
editor.setText(text);
@ -96,7 +96,7 @@ function test() {
EventUtils.synthesizeKey("/", {accelKey: true}, testWin);
is(editor.getText(), "/*" + text + "*/", "CSS Multiple Line Commenting works");
EventUtils.synthesizeKey("VK_A", {accelKey: true}, testWin);
EventUtils.synthesizeKey("/", {accelKey: true, shiftKey: true}, testWin);
EventUtils.synthesizeKey("/", {accelKey: true}, testWin);
is(editor.getText(), text, "CSS Multiple Line Uncommenting works");
editor.setMode(SourceEditor.MODES.HTML);
@ -107,7 +107,7 @@ function test() {
EventUtils.synthesizeKey("/", {accelKey: true}, testWin);
is(editor.getText(), expText, "HTML Commenting without selection works");
editor.setCaretPosition(0);
EventUtils.synthesizeKey("/", {accelKey: true, shiftKey: true}, testWin);
EventUtils.synthesizeKey("/", {accelKey: true}, testWin);
is(editor.getText(), text, "HTML Uncommenting without selection works");
editor.setText(text);
@ -116,7 +116,7 @@ function test() {
EventUtils.synthesizeKey("/", {accelKey: true}, testWin);
is(editor.getText(), "<!--" + text + "-->", "HTML Multiple Line Commenting works");
EventUtils.synthesizeKey("VK_A", {accelKey: true}, testWin);
EventUtils.synthesizeKey("/", {accelKey: true, shiftKey: true}, testWin);
EventUtils.synthesizeKey("/", {accelKey: true}, testWin);
is(editor.getText(), text, "HTML Multiple Line Uncommenting works");
editor.setMode(SourceEditor.MODES.TEXT);
@ -125,10 +125,10 @@ function test() {
editor.setCaretPosition(0);
EventUtils.synthesizeKey("/", {accelKey: true}, testWin);
is(editor.getText(), text, "Commenting disabled in Text mode");
editor.setText("//" + text);
editor.setText(regText);
EventUtils.synthesizeKey("VK_A", {accelKey: true}, testWin);
EventUtils.synthesizeKey("/", {accelKey: true, shiftKey: true}, testWin);
is(editor.getText(), "//" + text, "Uncommenting disabled in Text mode");
EventUtils.synthesizeKey("/", {accelKey: true}, testWin);
is(editor.getText(), regText, "Uncommenting disabled in Text mode");
editor.setText(text);
editor.readOnly = true;
@ -136,10 +136,10 @@ function test() {
editor.setCaretPosition(0);
EventUtils.synthesizeKey("/", {accelKey: true}, testWin);
is(editor.getText(), text, "Commenting disabled in ReadOnly mode");
editor.setText("//" + text);
editor.setText(regText);
EventUtils.synthesizeKey("VK_A", {accelKey: true}, testWin);
EventUtils.synthesizeKey("/", {accelKey: true, shiftKey: true}, testWin);
is(editor.getText(), "//" + text, "Uncommenting disabled in ReadOnly mode");
EventUtils.synthesizeKey("/", {accelKey: true}, testWin);
is(editor.getText(), regText, "Uncommenting disabled in ReadOnly mode");
editor.destroy();

Просмотреть файл

@ -0,0 +1,164 @@
/* vim: set ts=2 et sw=2 tw=80: */
/* Any copyright is dedicated to the Public Domain.
http://creativecommons.org/publicdomain/zero/1.0/ */
"use strict";
function test() {
let temp = {};
Cu.import("resource:///modules/source-editor.jsm", temp);
let SourceEditor = temp.SourceEditor;
waitForExplicitFinish();
let editor;
const windowUrl = "data:text/xml,<?xml version='1.0'?>" +
"<window xmlns='http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul'" +
" title='test for bug 729960' width='600' height='500'><hbox flex='1'/></window>";
const windowFeatures = "chrome,titlebar,toolbar,centerscreen,resizable,dialog=no";
let testWin = Services.ww.openWindow(null, windowUrl, "_blank", windowFeatures, null);
testWin.addEventListener("load", function onWindowLoad() {
testWin.removeEventListener("load", onWindowLoad, false);
waitForFocus(initEditor, testWin);
}, false);
function initEditor()
{
let hbox = testWin.document.querySelector("hbox");
editor = new SourceEditor();
editor.init(hbox, {showLineNumbers: true}, editorLoaded);
}
function editorLoaded()
{
editor.focus();
let JSText = "function foo(aVar) {\n" +
" // Block Level 1\n\n" +
" function level2() {\n" +
" let baz = aVar;\n" +
" // Block Level 2\n" +
" function level3() {\n" +
" // Block Level 3\n" +
" }\n" +
" }\n" +
" // Block Level 1" +
" function bar() { /* Block Level 2 */ }\n" +
"}";
editor.setMode(SourceEditor.MODES.JAVASCRIPT);
editor.setText(JSText);
// Setting caret at Line 1 bracket start.
editor.setCaretOffset(19);
EventUtils.synthesizeKey("]", {accelKey: true}, testWin);
is(editor.getCaretOffset(), 220,
"JS : Jump to closing bracket of the code block when caret at block start");
EventUtils.synthesizeKey("[", {accelKey: true}, testWin);
is(editor.getCaretOffset(), 19,
"JS : Jump to opening bracket of the code block when caret at block end");
// Setting caret at Line 10 start.
editor.setCaretOffset(161);
EventUtils.synthesizeKey("[", {accelKey: true}, testWin);
is(editor.getCaretOffset(), 19,
"JS : Jump to opening bracket of code block when inside the function");
editor.setCaretOffset(161);
EventUtils.synthesizeKey("]", {accelKey: true}, testWin);
is(editor.getCaretOffset(), 220,
"JS : Jump to closing bracket of code block when inside the function");
// Setting caret at Line 6 start.
editor.setCaretOffset(67);
EventUtils.synthesizeKey("]", {accelKey: true}, testWin);
is(editor.getCaretOffset(), 159,
"JS : Jump to closing bracket in a nested function with caret inside");
editor.setCaretOffset(67);
EventUtils.synthesizeKey("[", {accelKey: true}, testWin);
is(editor.getCaretOffset(), 61,
"JS : Jump to opening bracket in a nested function with caret inside");
let CSSText = "#object {\n" +
" property: value;\n" +
" /* comment */\n" +
"}";
editor.setMode(SourceEditor.MODES.CSS);
editor.setText(CSSText);
// Setting caret at Line 1 bracket start.
editor.setCaretOffset(8);
EventUtils.synthesizeKey("]", {accelKey: true}, testWin);
is(editor.getCaretOffset(), 45,
"CSS : Jump to closing bracket of the code block when caret at block start");
EventUtils.synthesizeKey("[", {accelKey: true}, testWin);
is(editor.getCaretOffset(), 8,
"CSS : Jump to opening bracket of the code block when caret at block end");
// Setting caret at Line 3 start.
editor.setCaretOffset(28);
EventUtils.synthesizeKey("[", {accelKey: true}, testWin);
is(editor.getCaretOffset(), 8,
"CSS : Jump to opening bracket of code block when inside the function");
editor.setCaretOffset(28);
EventUtils.synthesizeKey("]", {accelKey: true}, testWin);
is(editor.getCaretOffset(), 45,
"CSS : Jump to closing bracket of code block when inside the function");
let HTMLText = "<html>\n" +
" <head>\n" +
" <title>Testing Block Jump</title>\n" +
" </head>\n" +
" <body></body>\n" +
"</html>";
editor.setMode(SourceEditor.MODES.HTML);
editor.setText(HTMLText);
// Setting caret at Line 1 end.
editor.setCaretOffset(6);
EventUtils.synthesizeKey("]", {accelKey: true}, testWin);
is(editor.getCaretOffset(), 6,
"HTML : Jump to block end : Nothing happens in html mode");
// Setting caret at Line 4 end.
editor.setCaretOffset(64);
EventUtils.synthesizeKey("[", {accelKey: true}, testWin);
is(editor.getCaretOffset(), 64,
"HTML : Jump to block start : Nothing happens in html mode");
let text = "line 1\n" +
"line 2\n" +
"line 3\n" +
"line 4\n";
editor.setMode(SourceEditor.MODES.TEXT);
editor.setText(text);
// Setting caret at Line 1 start.
editor.setCaretOffset(0);
EventUtils.synthesizeKey("]", {accelKey: true}, testWin);
is(editor.getCaretOffset(), 0,
"Text : Jump to block end : Nothing happens in text mode");
// Setting caret at Line 4 end.
editor.setCaretOffset(28);
EventUtils.synthesizeKey("[", {accelKey: true}, testWin);
is(editor.getCaretOffset(), 28,
"Text : Jump to block start : Nothing happens in text mode");
editor.destroy();
testWin.close();
testWin = editor = null;
waitForFocus(finish, window);
}
}

Просмотреть файл

@ -1177,7 +1177,8 @@ function setupBracketCompletion(aSourceEditor)
editorElement.addEventListener("keypress", function onKeyPress(aEvent) {
let pair = pairs[aEvent.charCode];
if (!pair) {
if (!pair || aEvent.ctrlKey || aEvent.metaKey ||
aEvent.accelKey || aEvent.altKey) {
return true;
}

Просмотреть файл

@ -90,6 +90,14 @@ function testEditorAdded(aChrome, aEditor)
is(computedStyle.backgroundColor, "rgb(255, 255, 255)",
"content's background color is initially white");
EventUtils.synthesizeKey("[", {accelKey: true}, gChromeWindow);
is(aEditor.sourceEditor.getText(), "",
"Nothing happened as it is a known shortcut in source editor");
EventUtils.synthesizeKey("]", {accelKey: true}, gChromeWindow);
is(aEditor.sourceEditor.getText(), "",
"Nothing happened as it is a known shortcut in source editor");
for each (let c in TESTCASE_CSS_SOURCE) {
EventUtils.synthesizeKey(c, {}, gChromeWindow);
}

Просмотреть файл

@ -75,7 +75,7 @@ bindinggen_dependencies := \
$(binding_header_files): %Binding.h: $(bindinggen_dependencies) \
$(webidl_base)/%.webidl \
$(NULL)
$(PYTHON_PATH) \
$(PYTHON) $(topsrcdir)/config/pythonpath.py \
$(PLY_INCLUDE) -I$(srcdir)/parser \
$(srcdir)/BindingGen.py $(ACCESSOR_OPT) header \
$(srcdir)/Bindings.conf $*Binding \
@ -84,7 +84,7 @@ $(binding_header_files): %Binding.h: $(bindinggen_dependencies) \
$(binding_cpp_files): %Binding.cpp: $(bindinggen_dependencies) \
$(webidl_base)/%.webidl \
$(NULL)
$(PYTHON_PATH) \
$(PYTHON) $(topsrcdir)/config/pythonpath.py \
$(PLY_INCLUDE) -I$(srcdir)/parser \
$(srcdir)/BindingGen.py $(ACCESSOR_OPT) cpp \
$(srcdir)/Bindings.conf $*Binding \