1.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000 1.2 +++ b/layout/generic/test/test_bug469774.xul Wed Dec 31 06:09:35 2014 +0100 1.3 @@ -0,0 +1,72 @@ 1.4 +<?xml version="1.0"?> 1.5 +<?xml-stylesheet href="chrome://global/skin" type="text/css"?> 1.6 +<?xml-stylesheet href="chrome://mochikit/content/tests/SimpleTest/test.css" type="text/css"?> 1.7 +<!-- 1.8 +https://bugzilla.mozilla.org/show_bug.cgi?id=469774 1.9 +--> 1.10 +<window title="Mozilla Bug 469774" 1.11 + xmlns="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul"> 1.12 + 1.13 + <script type="application/javascript" src="chrome://mochikit/content/tests/SimpleTest/SimpleTest.js"/> 1.14 + <script type="text/javascript" src="chrome://mochikit/content/tests/SimpleTest/WindowSnapshot.js"></script> 1.15 + 1.16 +<vbox height="50"/> 1.17 + 1.18 +<menupopup id="popup"> 1.19 + <textbox id="textbox"/> 1.20 +</menupopup> 1.21 + 1.22 +<body xmlns="http://www.w3.org/1999/xhtml"> 1.23 + <a target="_blank" href="https://bugzilla.mozilla.org/show_bug.cgi?id=469774">Mozilla Bug 469774</a> 1.24 + 1.25 + <p id="display"></p> 1.26 +<div id="content" style="display: none"> 1.27 +</div> 1.28 +</body> 1.29 + 1.30 +<script class="testbody" type="application/javascript;version=1.7"><![CDATA[ 1.31 + 1.32 +/** Test for Bug 469774 **/ 1.33 + 1.34 +// Test whether menu popups are blocked from being painted in their parent window. 1.35 + 1.36 +// Like snapshotWindow, but with DRAWWINDOW_DRAW_CARET 1.37 +function snapShot() { 1.38 + var canvas = document.createElementNS("http://www.w3.org/1999/xhtml", "canvas"); 1.39 + canvas.setAttribute("width", 200); 1.40 + canvas.setAttribute("height", 50); 1.41 + var ctx = canvas.getContext("2d"); 1.42 + ctx.drawWindow(window, 0, 0, 200, 50, "transparent", ctx.DRAWWINDOW_DRAW_CARET); 1.43 + return canvas; 1.44 +} 1.45 + 1.46 +function doTest() { 1.47 + window.removeEventListener("focus", doTest, false); 1.48 + 1.49 + var before = snapShot(); 1.50 + 1.51 + var popup = document.getElementById("popup"); 1.52 + popup.openPopup(null, "after_start", 0, 0, false, false); 1.53 + 1.54 + popup.addEventListener("popupshown", function() { 1.55 + var textbox = document.getElementById("textbox"); 1.56 + textbox.focus(); // show caret 1.57 + 1.58 + var after = snapShot(); 1.59 + 1.60 + var equal, str1, str2; 1.61 + [equal, str1, str2] = compareSnapshots(after, before, true); 1.62 + ok(equal, "Showing a popup shouldn't affect drawing in its parent window", 1.63 + "got " + str1 + " but expected " + str2); 1.64 + 1.65 + popup.hidePopup(); 1.66 + SimpleTest.finish(); 1.67 + }, false); 1.68 +} 1.69 + 1.70 +SimpleTest.waitForExplicitFinish(); 1.71 +window.addEventListener("focus", doTest, false); 1.72 + 1.73 +]]></script> 1.74 + 1.75 +</window>