Wed, 31 Dec 2014 06:09:35 +0100
Cloned upstream origin tor-browser at tor-browser-31.3.0esr-4.5-1-build1
revision ID fc1c9ff7c1b2defdbc039f12214767608f46423f for hacking purpose.
michael@0 | 1 | <!DOCTYPE HTML> |
michael@0 | 2 | <html> |
michael@0 | 3 | <!-- |
michael@0 | 4 | https://bugzilla.mozilla.org/show_bug.cgi?id=864040 |
michael@0 | 5 | --> |
michael@0 | 6 | <head> |
michael@0 | 7 | <meta charset="utf-8"> |
michael@0 | 8 | <title>Test for Bug 864040</title> |
michael@0 | 9 | <script type="application/javascript" src="/tests/SimpleTest/SimpleTest.js"></script> |
michael@0 | 10 | <script type="application/javascript" src="/tests/SimpleTest/EventUtils.js"></script> |
michael@0 | 11 | <script type="application/javascript" src="/tests/SimpleTest/WindowSnapshot.js"></script> |
michael@0 | 12 | <link rel="stylesheet" type="text/css" href="/tests/SimpleTest/test.css"/> |
michael@0 | 13 | </head> |
michael@0 | 14 | <body> |
michael@0 | 15 | <a target="_blank" href="https://bugzilla.mozilla.org/show_bug.cgi?id=864040">Mozilla Bug 864040</a> |
michael@0 | 16 | <div id="display"> |
michael@0 | 17 | <textarea id="ta" rows="5" cols="20"></textarea> |
michael@0 | 18 | <div id="ce" contentEditable="true" style="height: 5em;"></div> |
michael@0 | 19 | </div> |
michael@0 | 20 | <div id="content" style="display: none"> |
michael@0 | 21 | </div> |
michael@0 | 22 | <pre id="test"> |
michael@0 | 23 | <script type="application/javascript"> |
michael@0 | 24 | /** |
michael@0 | 25 | * Test for Bug 864040 |
michael@0 | 26 | * |
michael@0 | 27 | * We use a selection event to set the selection to the end of an editor |
michael@0 | 28 | * containing an ending newline. Then we test to see that the caret is |
michael@0 | 29 | * actually drawn on the newline. |
michael@0 | 30 | */ |
michael@0 | 31 | |
michael@0 | 32 | function testSelectEndOfText(elem) { |
michael@0 | 33 | var tn = elem.tagName; |
michael@0 | 34 | elem.focus(); |
michael@0 | 35 | |
michael@0 | 36 | // Enter test string into editor |
michael@0 | 37 | var test_string = 'test\n'; |
michael@0 | 38 | sendString(test_string); |
michael@0 | 39 | |
michael@0 | 40 | // Get the caret position after what we entered |
michael@0 | 41 | var result = synthesizeQuerySelectedText(); |
michael@0 | 42 | ok(result, tn + ': failed to query selection (1)'); |
michael@0 | 43 | var refoffset = result.offset; |
michael@0 | 44 | |
michael@0 | 45 | // Take a snapshot of where the caret is (on the new line) |
michael@0 | 46 | referenceSnapshot = snapshotWindow(window, true /* withCaret */); |
michael@0 | 47 | ok(referenceSnapshot, tn + ': failed to take snapshot (1)'); |
michael@0 | 48 | |
michael@0 | 49 | // Set selection to the same spot through a selection event |
michael@0 | 50 | ok(synthesizeSelectionSet(refoffset, 0, false), tn + ': failed to set selection'); |
michael@0 | 51 | |
michael@0 | 52 | // Make sure new selection is the same |
michael@0 | 53 | result = synthesizeQuerySelectedText(); |
michael@0 | 54 | ok(result, tn + ': failed to query selection (2)'); |
michael@0 | 55 | is(result.offset, refoffset, tn + ': caret is not at the right position'); |
michael@0 | 56 | |
michael@0 | 57 | // Take a snapshot of where the new caret is (shoud still be on the new line) |
michael@0 | 58 | testSnapshot = snapshotWindow(window, true /* withCaret */); |
michael@0 | 59 | ok(testSnapshot, tn + ': failed to take snapshot (2)'); |
michael@0 | 60 | |
michael@0 | 61 | // Compare snapshot (should be the same) |
michael@0 | 62 | result = compareSnapshots(referenceSnapshot, testSnapshot, true /* expected */) |
michael@0 | 63 | ok(result, tn + ': failed to compare snapshots'); |
michael@0 | 64 | // result = [correct, s1data, s2data] |
michael@0 | 65 | ok(result[0], tn + ': caret is not on new line'); |
michael@0 | 66 | if (!result[0]) { |
michael@0 | 67 | dump('Ref: ' + result[1] + '\n'); |
michael@0 | 68 | dump('Res: ' + result[2] + '\n'); |
michael@0 | 69 | } |
michael@0 | 70 | } |
michael@0 | 71 | |
michael@0 | 72 | function runTests() { |
michael@0 | 73 | // we don't test regular <input> because this test is about multiline support |
michael@0 | 74 | // test textarea |
michael@0 | 75 | testSelectEndOfText(document.getElementById('ta')); |
michael@0 | 76 | // test contentEditable |
michael@0 | 77 | testSelectEndOfText(document.getElementById('ce')); |
michael@0 | 78 | SimpleTest.finish(); |
michael@0 | 79 | } |
michael@0 | 80 | |
michael@0 | 81 | SimpleTest.waitForExplicitFinish(); |
michael@0 | 82 | |
michael@0 | 83 | SimpleTest.waitForFocus(runTests); |
michael@0 | 84 | </script> |
michael@0 | 85 | </pre> |
michael@0 | 86 | </body> |
michael@0 | 87 | </html> |