1.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000 1.2 +++ b/layout/generic/test/test_image_selection.html Wed Dec 31 06:09:35 2014 +0100 1.3 @@ -0,0 +1,93 @@ 1.4 +<!DOCTYPE HTML> 1.5 +<html> 1.6 +<!-- 1.7 +https://bugzilla.mozilla.org/show_bug.cgi?id=599368 1.8 +--> 1.9 +<head> 1.10 + <title>Test for Bug 599368</title> 1.11 + <script type="application/javascript" src="/tests/SimpleTest/SimpleTest.js"></script> 1.12 + <script type="text/javascript" src="/tests/SimpleTest/EventUtils.js"></script> 1.13 + <script type="text/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 +<a target="_blank" href="https://bugzilla.mozilla.org/show_bug.cgi?id=599368">Mozilla Bug 599368</a> 1.18 +<iframe id="display" src="about:blank"></iframe> 1.19 +<div id="content" style="display: none"> 1.20 + 1.21 +</div> 1.22 +<pre id="test"> 1.23 +<script type="application/javascript"> 1.24 + 1.25 +/** Test for Bug 599368 **/ 1.26 + 1.27 +SimpleTest.waitForExplicitFinish(); 1.28 + 1.29 +window.addEventListener("load", step1, false); 1.30 + 1.31 +var gImage; 1.32 +var gIframe; 1.33 +var gBlueNotSelected; 1.34 +var gBlueSelected; 1.35 +var gFuchsiaSelected; 1.36 + 1.37 +function step1() 1.38 +{ 1.39 + gIframe = document.getElementById("display"); 1.40 + doc = gIframe.contentDocument; 1.41 + 1.42 + gImage = doc.createElement('img'); 1.43 + var src = String(window.location).split("/"); 1.44 + src.pop(); 1.45 + src.push("blue-32x32.png"); 1.46 + src = src.join("/"); 1.47 + gImage.src = src; 1.48 + gImage.addEventListener("load", step2, false); 1.49 + doc.body.appendChild(gImage); 1.50 + 1.51 + doc.designMode = "on"; 1.52 +} 1.53 + 1.54 +function step2() { 1.55 + gImage.removeEventListener("load", step2, false); 1.56 + 1.57 + gBlueNotSelected = snapshotWindow(gIframe.contentWindow, false); 1.58 + 1.59 + synthesizeMouse(gImage, 5, 5, {}, gIframe.contentWindow); 1.60 + setTimeout(step3, 0); 1.61 +} 1.62 + 1.63 +function step3() { 1.64 + gBlueSelected = snapshotWindow(gIframe.contentWindow, false); 1.65 + 1.66 + var src = String(window.location).split("/"); 1.67 + src.pop(); 1.68 + src.push("fuchsia-32x32.png"); 1.69 + src = src.join("/"); 1.70 + gImage.addEventListener("load", step4, false); 1.71 + gImage.src = src; 1.72 +} 1.73 + 1.74 +function step4() { 1.75 + gImage.removeEventListener("load", step4, false); 1.76 + 1.77 + gFuchsiaSelected = snapshotWindow(gIframe.contentWindow, false); 1.78 + 1.79 + assert_different(gBlueNotSelected, gBlueSelected, 1.80 + "selecting image should add drag points"); 1.81 + assert_different(gBlueSelected, gFuchsiaSelected, 1.82 + "different images should appear different"); 1.83 + 1.84 + SimpleTest.finish(); 1.85 +} 1.86 + 1.87 +function assert_different(shot1, shot2, desc) 1.88 +{ 1.89 + var [correct, s1, s2] = compareSnapshots(shot1, shot2, false); 1.90 + ok(correct, desc); 1.91 +} 1.92 + 1.93 +</script> 1.94 +</pre> 1.95 +</body> 1.96 +</html>