editor/libeditor/html/tests/test_bug417418.html

changeset 0
6474c204b198
     1.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     1.2 +++ b/editor/libeditor/html/tests/test_bug417418.html	Wed Dec 31 06:09:35 2014 +0100
     1.3 @@ -0,0 +1,72 @@
     1.4 +<!DOCTYPE HTML>
     1.5 +<html>
     1.6 +<!--
     1.7 +https://bugzilla.mozilla.org/show_bug.cgi?id=417418
     1.8 +-->
     1.9 +<head>
    1.10 +  <title>Test for Bug 417418</title>
    1.11 +  <script type="text/javascript" src="/MochiKit/MochiKit.js"></script>
    1.12 +  <script type="text/javascript" src="/tests/SimpleTest/SimpleTest.js"></script>
    1.13 +  <script type="text/javascript" src="/tests/SimpleTest/EventUtils.js"></script>
    1.14 +  <link rel="stylesheet" type="text/css" href="/tests/SimpleTest/test.css" />
    1.15 +</head>
    1.16 +<body>
    1.17 +<a target="_blank" href="https://bugzilla.mozilla.org/show_bug.cgi?id=417418">Mozilla Bug 417418</a>
    1.18 +<div id="display" contenteditable="true">
    1.19 +<p id="coin">first paragraph</p>
    1.20 +<p>second paragraph. <img id="img" src="green.png"></p>
    1.21 +</div>
    1.22 +<div id="content" style="display: none">
    1.23 +
    1.24 +</div>
    1.25 +<pre id="test">
    1.26 +<script class="testbody" type="text/javascript">
    1.27 +
    1.28 +/** Test for Bug 417418 **/
    1.29 +SimpleTest.waitForExplicitFinish();
    1.30 +SimpleTest.waitForFocus(runTest);
    1.31 +
    1.32 +function resetSelection() {
    1.33 +  window.getSelection().collapse(document.getElementById("coin"), 0);
    1.34 +}
    1.35 +
    1.36 +function runTest() {
    1.37 +    var rightClick = {type: 'mousedown', button: 2},
    1.38 +        singleClick = {type: 'mousedown', button: 0};
    1.39 +    var selection = window.getSelection();
    1.40 +
    1.41 +    var div = document.getElementById('display');
    1.42 +    var img = document.getElementById('img');
    1.43 +    var divRect = div.getBoundingClientRect();
    1.44 +    var imgselected;
    1.45 +
    1.46 +    resetSelection();
    1.47 +    synthesizeMouse(div, divRect.width - 1, divRect.height - 1, rightClick);
    1.48 +    ok(selection.isCollapsed, "selection is not collapsed");
    1.49 +
    1.50 +    resetSelection();
    1.51 +    synthesizeMouse(div, divRect.width - 1, divRect.height - 1, singleClick);
    1.52 +    ok(selection.isCollapsed, "selection is not collapsed");
    1.53 +
    1.54 +    resetSelection();
    1.55 +    synthesizeMouseAtCenter(img, rightClick);
    1.56 +    imgselected = selection.anchorNode == img.parentNode &&
    1.57 +                      selection.anchorOffset === 1 &&
    1.58 +                      selection.rangeCount === 1;
    1.59 +    ok(imgselected, "image is not selected");
    1.60 +
    1.61 +    resetSelection();
    1.62 +    synthesizeMouseAtCenter(img, singleClick);
    1.63 +    imgselected = selection.anchorNode == img.parentNode &&
    1.64 +                      selection.anchorOffset === 1 &&
    1.65 +                      selection.rangeCount === 1;
    1.66 +    ok(imgselected, "image is not selected");
    1.67 +
    1.68 +    SimpleTest.finish();
    1.69 +}
    1.70 +
    1.71 +
    1.72 +</script>
    1.73 +</pre>
    1.74 +</body>
    1.75 +</html>

mercurial