Wed, 31 Dec 2014 06:09:35 +0100
Cloned upstream origin tor-browser at tor-browser-31.3.0esr-4.5-1-build1
revision ID fc1c9ff7c1b2defdbc039f12214767608f46423f for hacking purpose.
michael@0 | 1 | <?xml version="1.0"?> |
michael@0 | 2 | <?xml-stylesheet href="chrome://global/skin" type="text/css"?> |
michael@0 | 3 | <?xml-stylesheet href="chrome://mochikit/content/tests/SimpleTest/test.css" type="text/css"?> |
michael@0 | 4 | <!-- |
michael@0 | 5 | https://bugzilla.mozilla.org/show_bug.cgi?id=420499 |
michael@0 | 6 | --> |
michael@0 | 7 | <window title="Mozilla Bug 420499" onload="setTimeout(focusInput, 500);" |
michael@0 | 8 | xmlns="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul"> |
michael@0 | 9 | <script type="application/javascript" src="chrome://mochikit/content/tests/SimpleTest/SimpleTest.js"/> |
michael@0 | 10 | <script type="application/javascript" src="chrome://mochikit/content/tests/SimpleTest/EventUtils.js"></script> |
michael@0 | 11 | |
michael@0 | 12 | |
michael@0 | 13 | |
michael@0 | 14 | <menu id="menu" label="Menu"> |
michael@0 | 15 | <menupopup id="file-popup"> |
michael@0 | 16 | <!-- <textbox id="some-text" maxlength="10" value="some text"/> --> |
michael@0 | 17 | <menu label="submenu"> |
michael@0 | 18 | <menupopup id="file-popup-inner"> |
michael@0 | 19 | |
michael@0 | 20 | <menuitem label="Item1"/> |
michael@0 | 21 | <menuitem label="Item2"/> |
michael@0 | 22 | <textbox id="some-text" maxlength="10" value="some more text"/> |
michael@0 | 23 | </menupopup> |
michael@0 | 24 | </menu> |
michael@0 | 25 | <menuitem label="Item3"/> |
michael@0 | 26 | <menuitem label="Item4"/> |
michael@0 | 27 | </menupopup> |
michael@0 | 28 | </menu> |
michael@0 | 29 | |
michael@0 | 30 | <popupset> |
michael@0 | 31 | <popup id="contextmenu"> |
michael@0 | 32 | <menuitem label="Cut"/> |
michael@0 | 33 | <menuitem label="Copy"/> |
michael@0 | 34 | <menuitem label="Paste"/> |
michael@0 | 35 | </popup> |
michael@0 | 36 | <tooltip id="tooltip" orient="vertical"> |
michael@0 | 37 | <description value="This is a tooltip"/> |
michael@0 | 38 | </tooltip> |
michael@0 | 39 | </popupset> |
michael@0 | 40 | |
michael@0 | 41 | <!-- test results are displayed in the html:body --> |
michael@0 | 42 | <body xmlns="http://www.w3.org/1999/xhtml" bgcolor="white"> |
michael@0 | 43 | |
michael@0 | 44 | <p id="par1">Paragraph 1</p> |
michael@0 | 45 | <p id="par2">Paragraph 2</p> |
michael@0 | 46 | <p id="par3">Paragraph 3</p> |
michael@0 | 47 | <p id="par4">Paragraph 4</p> |
michael@0 | 48 | <p id="par5">Paragraph 5</p> |
michael@0 | 49 | |
michael@0 | 50 | <input type="text" id="text-input" maxlength="10" value="some more text"/> <br /> |
michael@0 | 51 | |
michael@0 | 52 | <a href="https://bugzilla.mozilla.org/show_bug.cgi?id=420499" |
michael@0 | 53 | target="_blank">Mozilla Bug 420499</a> |
michael@0 | 54 | </body> |
michael@0 | 55 | |
michael@0 | 56 | <!-- test code goes here --> |
michael@0 | 57 | <script type="application/javascript"><![CDATA[ |
michael@0 | 58 | |
michael@0 | 59 | /** Test for Bug 420499 **/ |
michael@0 | 60 | SimpleTest.waitForExplicitFinish(); |
michael@0 | 61 | |
michael@0 | 62 | function getSelectionController() { |
michael@0 | 63 | return document.docShell |
michael@0 | 64 | .QueryInterface(Components.interfaces.nsIInterfaceRequestor) |
michael@0 | 65 | .getInterface(Components.interfaces.nsISelectionDisplay) |
michael@0 | 66 | .QueryInterface(Components.interfaces.nsISelectionController); |
michael@0 | 67 | } |
michael@0 | 68 | |
michael@0 | 69 | function isCaretVisible() { |
michael@0 | 70 | window.QueryInterface(Components.interfaces.nsIInterfaceRequestor); |
michael@0 | 71 | var docShell = window.QueryInterface(Components.interfaces.nsIInterfaceRequestor) |
michael@0 | 72 | .getInterface(Components.interfaces.nsIWebNavigation) |
michael@0 | 73 | .QueryInterface(Components.interfaces.nsIDocShell); |
michael@0 | 74 | var selCon = docShell.QueryInterface(Components.interfaces.nsIInterfaceRequestor) |
michael@0 | 75 | .getInterface(Components.interfaces.nsISelectionDisplay) |
michael@0 | 76 | .QueryInterface(Components.interfaces.nsISelectionController); |
michael@0 | 77 | return selCon.caretVisible; |
michael@0 | 78 | } |
michael@0 | 79 | |
michael@0 | 80 | function focusInput() { |
michael@0 | 81 | ok(!isCaretVisible(), "Caret shouldn't be visible"); |
michael@0 | 82 | $("text-input").focus(); |
michael@0 | 83 | ok(isCaretVisible(), "Caret should be visible when input focused"); |
michael@0 | 84 | window.addEventListener("popupshown", popupMenuShownHandler, false); |
michael@0 | 85 | $("menu").open = true; |
michael@0 | 86 | } |
michael@0 | 87 | |
michael@0 | 88 | function popupMenuShownHandler() { |
michael@0 | 89 | window.removeEventListener("popupshown", popupMenuShownHandler, false); |
michael@0 | 90 | ok(!isCaretVisible(), "Caret shouldn't be visible when menu open"); |
michael@0 | 91 | window.addEventListener("popuphidden", ensureParagraphFocused, false); |
michael@0 | 92 | $("menu").open = false; |
michael@0 | 93 | } |
michael@0 | 94 | |
michael@0 | 95 | function ensureParagraphFocused() { |
michael@0 | 96 | window.removeEventListener("popuphidden", ensureParagraphFocused, false); |
michael@0 | 97 | ok(isCaretVisible(), "Caret should have returned to previous focus"); |
michael@0 | 98 | window.addEventListener("popupshown", popupMenuShownHandler2, false); |
michael@0 | 99 | $("contextmenu").openPopup($('text-input'), "topleft" , -1 , -1 , true, true); |
michael@0 | 100 | } |
michael@0 | 101 | |
michael@0 | 102 | function popupMenuShownHandler2() { |
michael@0 | 103 | window.removeEventListener("popupshown", popupMenuShownHandler2, false); |
michael@0 | 104 | ok(isCaretVisible(), "Caret should be visible when context menu open"); |
michael@0 | 105 | window.addEventListener("popuphidden", ensureParagraphFocused2, false); |
michael@0 | 106 | document.getElementById("contextmenu").hidePopup(); |
michael@0 | 107 | } |
michael@0 | 108 | |
michael@0 | 109 | function ensureParagraphFocused2() { |
michael@0 | 110 | window.removeEventListener("popuphidden", ensureParagraphFocused2, false); |
michael@0 | 111 | ok(isCaretVisible(), "Caret should still be visible"); |
michael@0 | 112 | window.addEventListener("popupshown", tooltipShownHandler, false); |
michael@0 | 113 | $("tooltip").openPopup($('text-input'), "topleft" , -1 , -1 , false, true); |
michael@0 | 114 | } |
michael@0 | 115 | |
michael@0 | 116 | function tooltipShownHandler() { |
michael@0 | 117 | window.removeEventListener("popupshown", tooltipShownHandler, false); |
michael@0 | 118 | ok(isCaretVisible(), "Caret should be visible when tooltip is visible"); |
michael@0 | 119 | window.addEventListener("popuphidden", ensureParagraphFocused3, false); |
michael@0 | 120 | document.getElementById("tooltip").hidePopup(); |
michael@0 | 121 | } |
michael@0 | 122 | |
michael@0 | 123 | function ensureParagraphFocused3() { |
michael@0 | 124 | window.removeEventListener("popuphidden", ensureParagraphFocused2, false); |
michael@0 | 125 | ok(isCaretVisible(), "Caret should still be visible"); |
michael@0 | 126 | SimpleTest.finish(); |
michael@0 | 127 | } |
michael@0 | 128 | ]]></script> |
michael@0 | 129 | </window> |