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