1.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000 1.2 +++ b/layout/base/tests/test_bug558663.html Wed Dec 31 06:09:35 2014 +0100 1.3 @@ -0,0 +1,101 @@ 1.4 +<!DOCTYPE HTML> 1.5 +<html> 1.6 +<!-- 1.7 +https://bugzilla.mozilla.org/show_bug.cgi?id=558663 1.8 +--> 1.9 +<head> 1.10 + <title>Test for Bug 558663</title> 1.11 + <script type="application/javascript" src="/tests/SimpleTest/SimpleTest.js"></script> 1.12 + <script type="application/javascript" src="/tests/SimpleTest/EventUtils.js"></script> 1.13 + <script type="application/javascript" src="/tests/SimpleTest/WindowSnapshot.js"></script> 1.14 + <link rel="stylesheet" type="text/css" href="/tests/SimpleTest/test.css"/> 1.15 +</head> 1.16 +<body> 1.17 +<p><a target="_blank" href="https://bugzilla.mozilla.org/show_bug.cgi?id=558663">Mozilla Bug 514127</a></p> 1.18 + 1.19 + <!-- 20x20 of red --> 1.20 +<iframe id="iframe" src="data:text/html,<img id='image' border='0' src='data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAABQAAAAUCAIAAAAC64paAAAAG0lEQVR42mP8z0A%2BYKJA76jmUc2jmkc1U0EzACKcASfOgGoMAAAAAElFTkSuQmCC'>"></iframe> 1.21 + 1.22 +<pre id="test"> 1.23 +<script type="application/javascript"> 1.24 + 1.25 +/** Test for Bug 558663 **/ 1.26 + 1.27 +SimpleTest.waitForExplicitFinish(); 1.28 +window.addEventListener("load", runTest, false); 1.29 + 1.30 +function checkSnapshots(s1, s2, shouldBeEqual, testName) { 1.31 + var res = compareSnapshots(s1, s2, shouldBeEqual); 1.32 + if (res[0]) { 1.33 + ok(true, testName + " snapshots compare correctly"); 1.34 + } else { 1.35 + ok(false, testName + " snapshots compare incorrectly. snapshot 1: " + 1.36 + res[1] + " snapshot 2: " + res[2]); 1.37 + } 1.38 +} 1.39 + 1.40 +function runTest() { 1.41 + document.getElementById("iframe").contentWindow.document.designMode = "on"; 1.42 + 1.43 + // The editor requires the event loop to spin after you turn on design mode 1.44 + // before it takes effect. 1.45 + setTimeout(continueTest, 100); 1.46 +} 1.47 + 1.48 +function continueTest() { 1.49 + var win = document.getElementById("iframe").contentWindow; 1.50 + var doc = win.document; 1.51 + var image = doc.getElementById("image"); 1.52 + 1.53 + // We want to test that clicking on the image and then clicking on one of the 1.54 + // draggers doesn't make the draggers disappear. 1.55 + 1.56 + // clean snapshot 1.57 + var before = snapshotWindow(win); 1.58 + 1.59 + // click to get the draggers 1.60 + synthesizeMouse(image, 1, 1, {type: "mousedown"}, win); 1.61 + synthesizeMouse(image, 1, 1, {type: "mouseup"}, win); 1.62 + 1.63 + // mouse over a dragger will change its color, so move the mouse away 1.64 + synthesizeMouse(doc.documentElement, 50, 50, {type: "mousemove"}, win); 1.65 + 1.66 + // snapshot with hopefully draggers 1.67 + var middle = snapshotWindow(win); 1.68 + 1.69 + // clicking on the top left dragger shouldn't change anything 1.70 + synthesizeMouse(image, 1, 1, {type: "mousedown"}, win); 1.71 + synthesizeMouse(image, 1, 1, {type: "mouseup"}, win); 1.72 + 1.73 + // mouse over a dragger will change its color, so move the mouse away 1.74 + synthesizeMouse(doc.documentElement, 50, 50, {type: "mousemove"}, win); 1.75 + 1.76 + // snapshot with hopefully draggers again 1.77 + var middle2 = snapshotWindow(win); 1.78 + 1.79 + // click outside the image (but inside the document) to unselect it 1.80 + synthesizeMouse(doc.documentElement, 50, 50, {type: "mousedown"}, win); 1.81 + synthesizeMouse(doc.documentElement, 50, 50, {type: "mouseup"}, win); 1.82 + 1.83 + // and then click outside the document so we don't draw a caret 1.84 + synthesizeMouse(document.documentElement, 1, 1, {type: "mousedown"}, window); 1.85 + synthesizeMouse(document.documentElement, 1, 1, {type: "mouseup"}, window); 1.86 + 1.87 + // hopefully clean snapshot 1.88 + var end = snapshotWindow(win); 1.89 + 1.90 + // before == end && middle == middle2 && before/end != middle/middle2 1.91 + checkSnapshots(before, end, true, "before and after should be the same") 1.92 + checkSnapshots(middle, middle2, true, "middle two should be the same"); 1.93 + checkSnapshots(before, middle, false, "before and middle should not be the same"); 1.94 + checkSnapshots(before, middle2, false, "before and middle2 should not be the same"); 1.95 + checkSnapshots(middle, end, false, "middle and end should not be the same"); 1.96 + checkSnapshots(middle2, end, false, "middle2 and end should not be the same"); 1.97 + 1.98 + SimpleTest.finish(); 1.99 +} 1.100 + 1.101 +</script> 1.102 +</pre> 1.103 +</body> 1.104 +</html>