| <html> |
| <head> |
| <script src="../../http/tests/inspector/inspector-test.js"></script> |
| <script src="editor-test.js"></script> |
| <script> |
| |
| function test() |
| { |
| function foo() |
| { |
| return 42; |
| } |
| var textEditor = InspectorTest.createTestEditor(); |
| textEditor.setMimeType("text/javascript"); |
| textEditor.setReadOnly(false); |
| textEditor.element.focus(); |
| |
| textEditor.setText(foo.toString()); |
| |
| InspectorTest.addResult(textEditor.text()); |
| |
| function homeButton(shift, callback) |
| { |
| var key = WebInspector.isMac() ? "leftArrow" : "home"; |
| var modifiers = WebInspector.isMac() ? ["metaKey"] : []; |
| if (shift) |
| modifiers.push("shiftKey"); |
| InspectorTest.fakeKeyEvent(textEditor, key, modifiers, callback); |
| } |
| |
| function hitHomeButton(shift, times, callback) |
| { |
| function hitButtonCallback() |
| { |
| --times; |
| InspectorTest.dumpTextWithSelection(textEditor); |
| if (times > 0) { |
| homeButton(shift, hitButtonCallback); |
| return; |
| } |
| callback(); |
| } |
| homeButton(shift, hitButtonCallback); |
| } |
| |
| InspectorTest.runTestSuite([ |
| function testFirstNonBlankCharacter(next) |
| { |
| var selection = WebInspector.TextRange.createFromLocation(2, 8); |
| textEditor.setSelection(selection); |
| InspectorTest.dumpTextWithSelection(textEditor); |
| hitHomeButton(false, 1, next); |
| }, |
| |
| function testFirstNonBlankCharacterFromWhitespace(next) |
| { |
| var selection = WebInspector.TextRange.createFromLocation(2, 2); |
| textEditor.setSelection(selection); |
| InspectorTest.dumpTextWithSelection(textEditor); |
| hitHomeButton(false, 1, next); |
| }, |
| |
| function testHomeButtonToggling(next) |
| { |
| var selection = WebInspector.TextRange.createFromLocation(2, 2); |
| textEditor.setSelection(selection); |
| InspectorTest.dumpTextWithSelection(textEditor); |
| hitHomeButton(false, 3, next); |
| }, |
| |
| function testHomeButtonDoesNotChangeCursor(next) |
| { |
| var selection = WebInspector.TextRange.createFromLocation(0, 2); |
| textEditor.setSelection(selection); |
| InspectorTest.dumpTextWithSelection(textEditor); |
| hitHomeButton(false, 2, next); |
| }, |
| |
| function testHomeButtonWithShift(next) |
| { |
| var selection = new WebInspector.TextRange(0, 0, 2, 8); |
| textEditor.setSelection(selection); |
| InspectorTest.dumpTextWithSelection(textEditor); |
| hitHomeButton(true, 3, next); |
| }, |
| |
| function testHomeButtonWithShiftInversed(next) |
| { |
| var selection = new WebInspector.TextRange(3, 1, 2, 8); |
| textEditor.setSelection(selection); |
| InspectorTest.dumpTextWithSelection(textEditor); |
| hitHomeButton(true, 3, next); |
| } |
| ]); |
| } |
| |
| </script> |
| </head> |
| |
| <body onload="runTest();"> |
| <p> |
| This test verifies that home button triggers selection between first symbol of the line |
| and first non-blank symbol of the line. |
| </p> |
| |
| </body> |
| </html> |