OLD | NEW |
1 function initialize_EditorTests() | 1 function initialize_EditorTests() |
2 { | 2 { |
3 | 3 |
4 InspectorTest.createTestEditor = function(clientHeight, textEditorDelegate) | 4 InspectorTest.createTestEditor = function(clientHeight, textEditorDelegate) |
5 { | 5 { |
6 var textEditor = new WebInspector.CodeMirrorTextEditor("", textEditorDelegat
e || new WebInspector.TextEditorDelegate()); | 6 var textEditor = new WebInspector.CodeMirrorTextEditor("", textEditorDelegat
e || new WebInspector.TextEditorDelegate()); |
7 clientHeight = clientHeight || 100; | 7 clientHeight = clientHeight || 100; |
8 textEditor.element.style.height = clientHeight + "px"; | 8 textEditor.element.style.height = clientHeight + "px"; |
9 textEditor.element.style.flex = "none"; | 9 textEditor.element.style.flex = "none"; |
10 textEditor.show(WebInspector.inspectorView.element); | 10 textEditor.show(WebInspector.inspectorView.element); |
(...skipping 77 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
88 | 88 |
89 var eventCodes = { | 89 var eventCodes = { |
90 Enter: 13, | 90 Enter: 13, |
91 Home: 36, | 91 Home: 36, |
92 ArrowLeft: 37, | 92 ArrowLeft: 37, |
93 ArrowUp: 38, | 93 ArrowUp: 38, |
94 ArrowRight: 39, | 94 ArrowRight: 39, |
95 ArrowDown: 40 | 95 ArrowDown: 40 |
96 }; | 96 }; |
97 | 97 |
98 function createCodeMirrorFakeEvent(eventType, code, charCode, modifiers) | 98 function createCodeMirrorFakeEvent(editor, eventType, code, charCode, modifiers) |
99 { | 99 { |
100 function eventPreventDefault() | 100 function eventPreventDefault() |
101 { | 101 { |
102 this._handled = true; | 102 this._handled = true; |
103 } | 103 } |
104 var event = { | 104 var event = { |
105 _handled: false, | 105 _handled: false, |
106 type: eventType, | 106 type: eventType, |
107 keyCode: code, | 107 keyCode: code, |
108 charCode: charCode, | 108 charCode: charCode, |
109 preventDefault: eventPreventDefault, | 109 preventDefault: eventPreventDefault, |
110 stopPropagation: function(){}, | 110 stopPropagation: function(){}, |
| 111 target: editor._codeMirror.display.input.textarea |
111 }; | 112 }; |
112 if (modifiers) { | 113 if (modifiers) { |
113 for (var i = 0; i < modifiers.length; ++i) | 114 for (var i = 0; i < modifiers.length; ++i) |
114 event[modifiers[i]] = true; | 115 event[modifiers[i]] = true; |
115 } | 116 } |
116 return event; | 117 return event; |
117 } | 118 } |
118 | 119 |
119 function fakeCodeMirrorKeyEvent(editor, eventType, code, charCode, modifiers) | 120 function fakeCodeMirrorKeyEvent(editor, eventType, code, charCode, modifiers) |
120 { | 121 { |
121 var event = createCodeMirrorFakeEvent(eventType, code, charCode, modifiers); | 122 var event = createCodeMirrorFakeEvent(editor, eventType, code, charCode, mod
ifiers); |
122 switch(eventType) { | 123 switch(eventType) { |
123 case "keydown": | 124 case "keydown": |
124 editor._codeMirror.triggerOnKeyDown(event); | 125 editor._codeMirror.triggerOnKeyDown(event); |
125 break; | 126 break; |
126 case "keypress": | 127 case "keypress": |
127 editor._codeMirror.triggerOnKeyPress(event); | 128 editor._codeMirror.triggerOnKeyPress(event); |
128 break; | 129 break; |
129 case "keyup": | 130 case "keyup": |
130 editor._codeMirror.triggerOnKeyUp(event); | 131 editor._codeMirror.triggerOnKeyUp(event); |
131 break; | 132 break; |
132 default: | 133 default: |
133 throw new Error("Unknown KeyEvent type"); | 134 throw new Error("Unknown KeyEvent type"); |
134 } | 135 } |
135 return event._handled; | 136 return event._handled; |
136 } | 137 } |
137 | 138 |
138 function fakeCodeMirrorInputEvent(editor, character) | 139 function fakeCodeMirrorInputEvent(editor, character) |
139 { | 140 { |
140 if (typeof character === "string") | 141 if (typeof character === "string") |
141 editor._codeMirror.display.input.value += character; | 142 editor._codeMirror.display.input.textarea.value += character; |
142 } | 143 } |
143 | 144 |
144 InspectorTest.fakeKeyEvent = function(editor, originalCode, modifiers, callback) | 145 InspectorTest.fakeKeyEvent = function(editor, originalCode, modifiers, callback) |
145 { | 146 { |
146 modifiers = modifiers || []; | 147 modifiers = modifiers || []; |
147 var code; | 148 var code; |
148 var charCode; | 149 var charCode; |
149 if (originalCode === "'") { | 150 if (originalCode === "'") { |
150 code = 222; | 151 code = 222; |
151 charCode = 0; | 152 charCode = 0; |
(...skipping 47 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
199 var keyName = sortedKeys[i]; | 200 var keyName = sortedKeys[i]; |
200 if (!keyName.length) | 201 if (!keyName.length) |
201 keyName = "<Empty string>"; | 202 keyName = "<Empty string>"; |
202 else | 203 else |
203 keyName = "'" + keyName + "'"; | 204 keyName = "'" + keyName + "'"; |
204 InspectorTest.addResult(keyName + ": " + listHashMap[sortedKeys[i]]); | 205 InspectorTest.addResult(keyName + ": " + listHashMap[sortedKeys[i]]); |
205 } | 206 } |
206 } | 207 } |
207 | 208 |
208 } | 209 } |
OLD | NEW |