mirror of
https://gitlab.winehq.org/wine/wine-gecko.git
synced 2024-09-13 09:24:08 -07:00
Bug 1042092 - test consumeanchor behaviour, r=Enn
--HG-- extra : rebase_source : cd263845a1319eb9662885ec84da1de687705eec
This commit is contained in:
parent
ac46985dbb
commit
fc1c51d210
@ -12,6 +12,8 @@ support-files =
|
||||
[test_bug467442.xul]
|
||||
[test_bug477754.xul]
|
||||
[test_bug703150.xul]
|
||||
[test_bug987230.xul]
|
||||
skip-if = os == 'linux' # No native mouse events
|
||||
[test_popupSizeTo.xul]
|
||||
[test_resizer.xul]
|
||||
[test_stack.xul]
|
||||
|
107
layout/xul/test/test_bug987230.xul
Normal file
107
layout/xul/test/test_bug987230.xul
Normal file
@ -0,0 +1,107 @@
|
||||
<?xml version="1.0"?>
|
||||
<?xml-stylesheet type="text/css" href="chrome://global/skin"?>
|
||||
<?xml-stylesheet type="text/css" href="chrome://mochikit/content/tests/SimpleTest/test.css"?>
|
||||
<!--
|
||||
https://bugzilla.mozilla.org/show_bug.cgi?id=987230
|
||||
-->
|
||||
<window title="Mozilla Bug 987230"
|
||||
xmlns="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul"
|
||||
onload="SimpleTest.waitForFocus(nextTest, window)">
|
||||
<script type="application/javascript" src="chrome://mochikit/content/tests/SimpleTest/SimpleTest.js"/>
|
||||
<script type="application/javascript" src="chrome://mochikit/content/tests/SimpleTest/EventUtils.js"/>
|
||||
|
||||
|
||||
<!-- test results are displayed in the html:body -->
|
||||
<body xmlns="http://www.w3.org/1999/xhtml">
|
||||
<a href="https://bugzilla.mozilla.org/show_bug.cgi?id=987230"
|
||||
target="_blank">Mozilla Bug 987230</a>
|
||||
</body>
|
||||
|
||||
<vbox>
|
||||
<toolbar>
|
||||
<toolbarbutton id="toolbarbutton-anchor"
|
||||
label="Anchor"
|
||||
consumeanchor="toolbarbutton-anchor"
|
||||
onclick="onAnchorClick(event)"
|
||||
style="padding: 50px !important; list-style-image: url(chrome://branding/content/icon32.png)"/>
|
||||
</toolbar>
|
||||
<spacer flex="1"/>
|
||||
<hbox id="hbox-anchor"
|
||||
style="padding: 20px"
|
||||
onclick="onAnchorClick(event)">
|
||||
<hbox id="inner-anchor"
|
||||
consumeanchor="hbox-anchor"
|
||||
>
|
||||
Another anchor
|
||||
</hbox>
|
||||
</hbox>
|
||||
<spacer flex="1"/>
|
||||
</vbox>
|
||||
|
||||
<panel id="mypopup"
|
||||
type="arrow"
|
||||
onpopupshown="onMyPopupShown(event)"
|
||||
onpopuphidden="onMyPopupHidden(event)">This is a test popup</panel>
|
||||
|
||||
<!-- test code goes here -->
|
||||
<script type="application/javascript">
|
||||
<![CDATA[
|
||||
/** Test for Bug 987230 **/
|
||||
SimpleTest.waitForExplicitFinish();
|
||||
|
||||
const Ci = Components.interfaces;
|
||||
const Cc = Components.classes;
|
||||
|
||||
let isWindows = navigator.platform.toLowerCase().startsWith("win");
|
||||
|
||||
function synthesizeNativeMouseClick(aElement, aOffsetX, aOffsetY) {
|
||||
let rect = aElement.getBoundingClientRect();
|
||||
let win = aElement.ownerDocument.defaultView;
|
||||
let x = aOffsetX + win.mozInnerScreenX + rect.left;
|
||||
let y = aOffsetY + win.mozInnerScreenY + rect.top;
|
||||
|
||||
let utils = win.QueryInterface(Ci.nsIInterfaceRequestor)
|
||||
.getInterface(Ci.nsIDOMWindowUtils);
|
||||
|
||||
let scale = utils.screenPixelsPerCSSPixel;
|
||||
let mouseDown = isWindows ? 2 : 1;
|
||||
let mouseUp = isWindows ? 4 : 2;
|
||||
utils.sendNativeMouseEvent(x * scale, y * scale, mouseDown, 0, null);
|
||||
utils.sendNativeMouseEvent(x * scale, y * scale, mouseUp, 0, null);
|
||||
}
|
||||
|
||||
function onMyPopupHidden(e) {
|
||||
ok(true, "Popup hidden");
|
||||
if (outerAnchor.id == "toolbarbutton-anchor") {
|
||||
popupHasShown = false;
|
||||
outerAnchor = document.getElementById("hbox-anchor");
|
||||
anchor = document.getElementById("inner-anchor");
|
||||
nextTest();
|
||||
} else {
|
||||
SimpleTest.finish();
|
||||
}
|
||||
}
|
||||
|
||||
let popupHasShown = false;
|
||||
function onMyPopupShown(e) {
|
||||
popupHasShown = true;
|
||||
synthesizeNativeMouseClick(outerAnchor, 5, 5);
|
||||
}
|
||||
|
||||
function onAnchorClick(e) {
|
||||
info("click: " + e.target.id);
|
||||
ok(!popupHasShown, "Popup should only be shown once");
|
||||
popup.openPopup(anchor, "bottomcenter topright");
|
||||
}
|
||||
|
||||
let popup = document.getElementById("mypopup");
|
||||
let outerAnchor = document.getElementById("toolbarbutton-anchor");
|
||||
let anchor = document.getAnonymousElementByAttribute(outerAnchor, "class", "toolbarbutton-icon");
|
||||
|
||||
function nextTest(e) {
|
||||
synthesizeMouse(outerAnchor, 5, 5, {});
|
||||
}
|
||||
|
||||
]]>
|
||||
</script>
|
||||
</window>
|
Loading…
Reference in New Issue
Block a user