layout/base/tests/test_bug558663.html

changeset 0
6474c204b198
equal deleted inserted replaced
-1:000000000000 0:1264ec4ceafb
1 <!DOCTYPE HTML>
2 <html>
3 <!--
4 https://bugzilla.mozilla.org/show_bug.cgi?id=558663
5 -->
6 <head>
7 <title>Test for Bug 558663</title>
8 <script type="application/javascript" src="/tests/SimpleTest/SimpleTest.js"></script>
9 <script type="application/javascript" src="/tests/SimpleTest/EventUtils.js"></script>
10 <script type="application/javascript" src="/tests/SimpleTest/WindowSnapshot.js"></script>
11 <link rel="stylesheet" type="text/css" href="/tests/SimpleTest/test.css"/>
12 </head>
13 <body>
14 <p><a target="_blank" href="https://bugzilla.mozilla.org/show_bug.cgi?id=558663">Mozilla Bug 514127</a></p>
15
16 <!-- 20x20 of red -->
17 <iframe id="iframe" src="data:text/html,<img id='image' border='0' src='data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAABQAAAAUCAIAAAAC64paAAAAG0lEQVR42mP8z0A%2BYKJA76jmUc2jmkc1U0EzACKcASfOgGoMAAAAAElFTkSuQmCC'>"></iframe>
18
19 <pre id="test">
20 <script type="application/javascript">
21
22 /** Test for Bug 558663 **/
23
24 SimpleTest.waitForExplicitFinish();
25 window.addEventListener("load", runTest, false);
26
27 function checkSnapshots(s1, s2, shouldBeEqual, testName) {
28 var res = compareSnapshots(s1, s2, shouldBeEqual);
29 if (res[0]) {
30 ok(true, testName + " snapshots compare correctly");
31 } else {
32 ok(false, testName + " snapshots compare incorrectly. snapshot 1: " +
33 res[1] + " snapshot 2: " + res[2]);
34 }
35 }
36
37 function runTest() {
38 document.getElementById("iframe").contentWindow.document.designMode = "on";
39
40 // The editor requires the event loop to spin after you turn on design mode
41 // before it takes effect.
42 setTimeout(continueTest, 100);
43 }
44
45 function continueTest() {
46 var win = document.getElementById("iframe").contentWindow;
47 var doc = win.document;
48 var image = doc.getElementById("image");
49
50 // We want to test that clicking on the image and then clicking on one of the
51 // draggers doesn't make the draggers disappear.
52
53 // clean snapshot
54 var before = snapshotWindow(win);
55
56 // click to get the draggers
57 synthesizeMouse(image, 1, 1, {type: "mousedown"}, win);
58 synthesizeMouse(image, 1, 1, {type: "mouseup"}, win);
59
60 // mouse over a dragger will change its color, so move the mouse away
61 synthesizeMouse(doc.documentElement, 50, 50, {type: "mousemove"}, win);
62
63 // snapshot with hopefully draggers
64 var middle = snapshotWindow(win);
65
66 // clicking on the top left dragger shouldn't change anything
67 synthesizeMouse(image, 1, 1, {type: "mousedown"}, win);
68 synthesizeMouse(image, 1, 1, {type: "mouseup"}, win);
69
70 // mouse over a dragger will change its color, so move the mouse away
71 synthesizeMouse(doc.documentElement, 50, 50, {type: "mousemove"}, win);
72
73 // snapshot with hopefully draggers again
74 var middle2 = snapshotWindow(win);
75
76 // click outside the image (but inside the document) to unselect it
77 synthesizeMouse(doc.documentElement, 50, 50, {type: "mousedown"}, win);
78 synthesizeMouse(doc.documentElement, 50, 50, {type: "mouseup"}, win);
79
80 // and then click outside the document so we don't draw a caret
81 synthesizeMouse(document.documentElement, 1, 1, {type: "mousedown"}, window);
82 synthesizeMouse(document.documentElement, 1, 1, {type: "mouseup"}, window);
83
84 // hopefully clean snapshot
85 var end = snapshotWindow(win);
86
87 // before == end && middle == middle2 && before/end != middle/middle2
88 checkSnapshots(before, end, true, "before and after should be the same")
89 checkSnapshots(middle, middle2, true, "middle two should be the same");
90 checkSnapshots(before, middle, false, "before and middle should not be the same");
91 checkSnapshots(before, middle2, false, "before and middle2 should not be the same");
92 checkSnapshots(middle, end, false, "middle and end should not be the same");
93 checkSnapshots(middle2, end, false, "middle2 and end should not be the same");
94
95 SimpleTest.finish();
96 }
97
98 </script>
99 </pre>
100 </body>
101 </html>

mercurial