layout/generic/test/test_bug469774.xul

Wed, 31 Dec 2014 06:09:35 +0100

author
Michael Schloh von Bennewitz <michael@schloh.com>
date
Wed, 31 Dec 2014 06:09:35 +0100
changeset 0
6474c204b198
permissions
-rw-r--r--

Cloned upstream origin tor-browser at tor-browser-31.3.0esr-4.5-1-build1
revision ID fc1c9ff7c1b2defdbc039f12214767608f46423f for hacking purpose.

     1 <?xml version="1.0"?>
     2 <?xml-stylesheet href="chrome://global/skin" type="text/css"?>
     3 <?xml-stylesheet href="chrome://mochikit/content/tests/SimpleTest/test.css" type="text/css"?>
     4 <!--
     5 https://bugzilla.mozilla.org/show_bug.cgi?id=469774
     6 -->
     7 <window title="Mozilla Bug 469774"
     8   xmlns="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul">
    10   <script type="application/javascript" src="chrome://mochikit/content/tests/SimpleTest/SimpleTest.js"/>
    11   <script type="text/javascript" src="chrome://mochikit/content/tests/SimpleTest/WindowSnapshot.js"></script>
    13 <vbox height="50"/>
    15 <menupopup id="popup">
    16   <textbox id="textbox"/>
    17 </menupopup>
    19 <body  xmlns="http://www.w3.org/1999/xhtml">
    20   <a target="_blank" href="https://bugzilla.mozilla.org/show_bug.cgi?id=469774">Mozilla Bug 469774</a>
    22   <p id="display"></p>
    23 <div id="content" style="display: none">
    24 </div>
    25 </body>
    27 <script class="testbody" type="application/javascript;version=1.7"><![CDATA[
    29 /** Test for Bug 469774 **/
    31 // Test whether menu popups are blocked from being painted in their parent window.
    33 // Like snapshotWindow, but with DRAWWINDOW_DRAW_CARET
    34 function snapShot() {
    35   var canvas = document.createElementNS("http://www.w3.org/1999/xhtml", "canvas");
    36   canvas.setAttribute("width", 200);
    37   canvas.setAttribute("height", 50);
    38   var ctx = canvas.getContext("2d");
    39   ctx.drawWindow(window, 0, 0, 200, 50, "transparent", ctx.DRAWWINDOW_DRAW_CARET);
    40   return canvas;
    41 }
    43 function doTest() {
    44   window.removeEventListener("focus", doTest, false);
    46   var before = snapShot();
    48   var popup = document.getElementById("popup");
    49   popup.openPopup(null, "after_start", 0, 0, false, false);
    51   popup.addEventListener("popupshown", function() {
    52     var textbox = document.getElementById("textbox");
    53     textbox.focus(); // show caret
    55     var after = snapShot();
    57     var equal, str1, str2;
    58     [equal, str1, str2] = compareSnapshots(after, before, true);
    59     ok(equal, "Showing a popup shouldn't affect drawing in its parent window",
    60        "got " + str1 + " but expected " + str2);
    62     popup.hidePopup();
    63     SimpleTest.finish();
    64   }, false);
    65 }
    67 SimpleTest.waitForExplicitFinish();
    68 window.addEventListener("focus", doTest, false);
    70 ]]></script>
    72 </window>

mercurial