| <html> |
| <head> |
| <script src="../../http/tests/inspector/inspector-test.js"></script> |
| <script src="editor-test.js"></script> |
| <script> |
| |
| function test() |
| { |
| var textEditor = InspectorTest.createTestEditor(); |
| InspectorTest.fillEditorWithText(textEditor, 34); |
| InspectorTest.dumpEditorChunks(textEditor); |
| |
| InspectorTest.runTestSuite([ |
| function testSelectionAtStartOfCollapsedChunk(next) |
| { |
| var chunks = textEditor._mainPanel._textChunks; |
| var lastChunk = chunks[chunks.length - 1]; |
| window.getSelection().setBaseAndExtent(lastChunk.element, 0, lastChunk.element, 0); |
| InspectorTest.addResult(textEditor._mainPanel.selection()); |
| next(); |
| }, |
| |
| function testSelectionAtEndOfCollapsedChunk(next) |
| { |
| var chunks = textEditor._mainPanel._textChunks; |
| var lastChunk = chunks[chunks.length - 1]; |
| window.getSelection().setBaseAndExtent(lastChunk.element, 1, lastChunk.element, 1); |
| InspectorTest.addResult(textEditor._mainPanel.selection()); |
| next(); |
| }, |
| |
| function testSelectionAtMiddleOfCollapsedChunk(next) |
| { |
| var chunks = textEditor._mainPanel._textChunks; |
| var lastChunk = chunks[chunks.length - 1]; |
| window.getSelection().setBaseAndExtent(lastChunk.element.firstChild, 1, lastChunk.element.firstChild, 11); |
| InspectorTest.addResult(textEditor._mainPanel.selection()); |
| next(); |
| }, |
| |
| function testSelectionAtStartAndEndOfExpandedRows(next) |
| { |
| var chunks = textEditor._mainPanel._textChunks; |
| var firstChunk = chunks[0]; |
| window.getSelection().setBaseAndExtent(firstChunk.expandedLineRow(3), 0, firstChunk.expandedLineRow(4), 1); |
| InspectorTest.addResult(textEditor._mainPanel.selection()); |
| next(); |
| }, |
| |
| function testSelectionAtMiddleOfExpandedRows(next) |
| { |
| var chunks = textEditor._mainPanel._textChunks; |
| var firstChunk = chunks[0]; |
| window.getSelection().setBaseAndExtent(firstChunk.expandedLineRow(3).firstChild, 3, firstChunk.expandedLineRow(4).firstChild, 4); |
| InspectorTest.addResult(textEditor._mainPanel.selection()); |
| next(); |
| }, |
| ]); |
| } |
| |
| </script> |
| </head> |
| |
| <body onload="runTest()"> |
| <p> |
| This test checks the text editor selection calculation. |
| </p> |
| |
| </body> |
| </html> |