3 <script src=
"../../http/tests/inspector/inspector-test.js"></script>
4 <script src=
"editor-test.js"></script>
13 var textEditor
= InspectorTest
.createTestEditor();
14 textEditor
.setMimeType("text/javascript");
15 textEditor
.setReadOnly(false);
16 textEditor
.element
.focus();
18 textEditor
.setText(foo
.toString());
20 InspectorTest
.addResult(textEditor
.text());
22 function homeButton(shift
, callback
)
24 var key
= WebInspector
.isMac() ? "leftArrow" : "home";
25 var modifiers
= WebInspector
.isMac() ? ["metaKey"] : [];
27 modifiers
.push("shiftKey");
28 InspectorTest
.fakeKeyEvent(textEditor
, key
, modifiers
, callback
);
31 function hitHomeButton(shift
, times
, callback
)
33 function hitButtonCallback()
36 InspectorTest
.dumpTextWithSelection(textEditor
);
38 homeButton(shift
, hitButtonCallback
);
43 homeButton(shift
, hitButtonCallback
);
46 InspectorTest
.runTestSuite([
47 function testFirstNonBlankCharacter(next
)
49 var selection
= WebInspector
.TextRange
.createFromLocation(2, 8);
50 textEditor
.setSelection(selection
);
51 InspectorTest
.dumpTextWithSelection(textEditor
);
52 hitHomeButton(false, 1, next
);
55 function testFirstNonBlankCharacterFromWhitespace(next
)
57 var selection
= WebInspector
.TextRange
.createFromLocation(2, 2);
58 textEditor
.setSelection(selection
);
59 InspectorTest
.dumpTextWithSelection(textEditor
);
60 hitHomeButton(false, 1, next
);
63 function testHomeButtonToggling(next
)
65 var selection
= WebInspector
.TextRange
.createFromLocation(2, 2);
66 textEditor
.setSelection(selection
);
67 InspectorTest
.dumpTextWithSelection(textEditor
);
68 hitHomeButton(false, 3, next
);
71 function testHomeButtonDoesNotChangeCursor(next
)
73 var selection
= WebInspector
.TextRange
.createFromLocation(0, 2);
74 textEditor
.setSelection(selection
);
75 InspectorTest
.dumpTextWithSelection(textEditor
);
76 hitHomeButton(false, 2, next
);
79 function testHomeButtonWithShift(next
)
81 var selection
= new WebInspector
.TextRange(0, 0, 2, 8);
82 textEditor
.setSelection(selection
);
83 InspectorTest
.dumpTextWithSelection(textEditor
);
84 hitHomeButton(true, 3, next
);
87 function testHomeButtonWithShiftInversed(next
)
89 var selection
= new WebInspector
.TextRange(3, 1, 2, 8);
90 textEditor
.setSelection(selection
);
91 InspectorTest
.dumpTextWithSelection(textEditor
);
92 hitHomeButton(true, 3, next
);
100 <body onload=
"runTest();">
102 This test verifies that home button triggers selection between first symbol of the line
103 and first non-blank symbol of the line.