editor/libeditor/html/tests/test_bug417418.html

Wed, 31 Dec 2014 06:09:35 +0100

author
Michael Schloh von Bennewitz <michael@schloh.com>
date
Wed, 31 Dec 2014 06:09:35 +0100
changeset 0
6474c204b198
permissions
-rw-r--r--

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=417418
michael@0 5 -->
michael@0 6 <head>
michael@0 7 <title>Test for Bug 417418</title>
michael@0 8 <script type="text/javascript" src="/MochiKit/MochiKit.js"></script>
michael@0 9 <script type="text/javascript" src="/tests/SimpleTest/SimpleTest.js"></script>
michael@0 10 <script type="text/javascript" src="/tests/SimpleTest/EventUtils.js"></script>
michael@0 11 <link rel="stylesheet" type="text/css" href="/tests/SimpleTest/test.css" />
michael@0 12 </head>
michael@0 13 <body>
michael@0 14 <a target="_blank" href="https://bugzilla.mozilla.org/show_bug.cgi?id=417418">Mozilla Bug 417418</a>
michael@0 15 <div id="display" contenteditable="true">
michael@0 16 <p id="coin">first paragraph</p>
michael@0 17 <p>second paragraph. <img id="img" src="green.png"></p>
michael@0 18 </div>
michael@0 19 <div id="content" style="display: none">
michael@0 20
michael@0 21 </div>
michael@0 22 <pre id="test">
michael@0 23 <script class="testbody" type="text/javascript">
michael@0 24
michael@0 25 /** Test for Bug 417418 **/
michael@0 26 SimpleTest.waitForExplicitFinish();
michael@0 27 SimpleTest.waitForFocus(runTest);
michael@0 28
michael@0 29 function resetSelection() {
michael@0 30 window.getSelection().collapse(document.getElementById("coin"), 0);
michael@0 31 }
michael@0 32
michael@0 33 function runTest() {
michael@0 34 var rightClick = {type: 'mousedown', button: 2},
michael@0 35 singleClick = {type: 'mousedown', button: 0};
michael@0 36 var selection = window.getSelection();
michael@0 37
michael@0 38 var div = document.getElementById('display');
michael@0 39 var img = document.getElementById('img');
michael@0 40 var divRect = div.getBoundingClientRect();
michael@0 41 var imgselected;
michael@0 42
michael@0 43 resetSelection();
michael@0 44 synthesizeMouse(div, divRect.width - 1, divRect.height - 1, rightClick);
michael@0 45 ok(selection.isCollapsed, "selection is not collapsed");
michael@0 46
michael@0 47 resetSelection();
michael@0 48 synthesizeMouse(div, divRect.width - 1, divRect.height - 1, singleClick);
michael@0 49 ok(selection.isCollapsed, "selection is not collapsed");
michael@0 50
michael@0 51 resetSelection();
michael@0 52 synthesizeMouseAtCenter(img, rightClick);
michael@0 53 imgselected = selection.anchorNode == img.parentNode &&
michael@0 54 selection.anchorOffset === 1 &&
michael@0 55 selection.rangeCount === 1;
michael@0 56 ok(imgselected, "image is not selected");
michael@0 57
michael@0 58 resetSelection();
michael@0 59 synthesizeMouseAtCenter(img, singleClick);
michael@0 60 imgselected = selection.anchorNode == img.parentNode &&
michael@0 61 selection.anchorOffset === 1 &&
michael@0 62 selection.rangeCount === 1;
michael@0 63 ok(imgselected, "image is not selected");
michael@0 64
michael@0 65 SimpleTest.finish();
michael@0 66 }
michael@0 67
michael@0 68
michael@0 69 </script>
michael@0 70 </pre>
michael@0 71 </body>
michael@0 72 </html>

mercurial