mirror of
https://gitlab.winehq.org/wine/wine-gecko.git
synced 2024-09-13 09:24:08 -07:00
Bug 387097, colorpicker not opening properly sometimes, also add colorpicker test, r=mano
This commit is contained in:
parent
d97c5c5687
commit
8a7f1e85b6
@ -47,6 +47,7 @@ include $(topsrcdir)/config/rules.mk
|
||||
_TEST_FILES = test_bug360220.xul \
|
||||
test_bug359754.xul \
|
||||
test_bug365773.xul \
|
||||
test_colorpicker_popup.xul \
|
||||
$(NULL)
|
||||
|
||||
libs:: $(_TEST_FILES)
|
||||
|
136
toolkit/content/tests/widgets/test_colorpicker_popup.xul
Normal file
136
toolkit/content/tests/widgets/test_colorpicker_popup.xul
Normal file
@ -0,0 +1,136 @@
|
||||
<?xml version="1.0"?>
|
||||
<?xml-stylesheet href="chrome://global/skin" type="text/css"?>
|
||||
<?xml-stylesheet href="/tests/SimpleTest/test.css" type="text/css"?>
|
||||
|
||||
<window title="Colorpicker Tests"
|
||||
onload="setTimeout(runTests, 0);"
|
||||
onpopupshown="popupShown();"
|
||||
onpopuphidden="popupHiding();"
|
||||
xmlns:html="http://www.w3.org/1999/xhtml"
|
||||
xmlns="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul">
|
||||
|
||||
<title>Colorpicker Tests</title>
|
||||
<script type="application/javascript" src="/MochiKit/packed.js"></script>
|
||||
<script type="application/javascript" src="/tests/SimpleTest/SimpleTest.js"></script>
|
||||
<script type="application/javascript" src="/tests/SimpleTest/EventUtils.js"></script>
|
||||
|
||||
<colorpicker id="colorpicker-popup" type="button" color="#FF0000"/>
|
||||
|
||||
<script class="testbody" type="application/javascript">
|
||||
<![CDATA[
|
||||
|
||||
var gTestPhase = -1;
|
||||
var gCp = null;
|
||||
|
||||
SimpleTest.waitForExplicitFinish();
|
||||
|
||||
function runTests()
|
||||
{
|
||||
gCp = document.getElementById("colorpicker-popup");
|
||||
is(gCp.color, "#FF0000", "popup color is initialized");
|
||||
|
||||
goNext();
|
||||
}
|
||||
|
||||
var phases = [ "mouse click", "showPopup",
|
||||
"key left", "key right", "key up", "key down", "key space" ];
|
||||
|
||||
function popupShown()
|
||||
{
|
||||
if (gTestPhase >= phases.length)
|
||||
return;
|
||||
|
||||
var phase = phases[gTestPhase];
|
||||
|
||||
is(gCp.open, true, phase + " popup shown, open property is true");
|
||||
|
||||
switch (phase) {
|
||||
case "mouse click":
|
||||
synthesizeMouse(gCp, 2, 2, { });
|
||||
break;
|
||||
case "showPopup":
|
||||
gCp.hidePopup();
|
||||
break;
|
||||
case "key left":
|
||||
synthesizeKey("VK_LEFT", { });
|
||||
synthesizeKeyExpectEvent("VK_RETURN", { });
|
||||
is(gCp.color, "#C0C0C0", "key left while open");
|
||||
break;
|
||||
case "key right":
|
||||
synthesizeKey("VK_RIGHT", { });
|
||||
synthesizeKeyExpectEvent("VK_SPACE", { });
|
||||
is(gCp.color, "#FF0000", "key right while open");
|
||||
break;
|
||||
case "key up":
|
||||
synthesizeKey("VK_UP", { });
|
||||
synthesizeKeyExpectEvent("VK_RETURN", { });
|
||||
is(gCp.color, "#FF6666", "key up while open");
|
||||
break;
|
||||
case "key down":
|
||||
synthesizeKey("VK_DOWN", { });
|
||||
synthesizeKeyExpectEvent("VK_SPACE", { });
|
||||
is(gCp.color, "#FF0000", "key down while open");
|
||||
break;
|
||||
default:
|
||||
synthesizeKey("VK_ESCAPE", { });
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
function popupHiding()
|
||||
{
|
||||
var phase = phases[gTestPhase];
|
||||
if (phase == "showPopup")
|
||||
phase = "hidePopup";
|
||||
if (phase == "key left")
|
||||
phase = "escape";
|
||||
is(gCp.open, false, phase + " popup hidden, open property is false");
|
||||
|
||||
goNext();
|
||||
}
|
||||
|
||||
function goNext()
|
||||
{
|
||||
gTestPhase++;
|
||||
if (gTestPhase >= phases.length)
|
||||
SimpleTest.finish();
|
||||
|
||||
var phase = phases[gTestPhase];
|
||||
switch (phase) {
|
||||
case "mouse click":
|
||||
synthesizeMouse(gCp, 2, 2, { });
|
||||
break;
|
||||
case "showPopup":
|
||||
gCp.showPopup();
|
||||
break;
|
||||
case "key left":
|
||||
synthesizeKey("VK_LEFT", { });
|
||||
break;
|
||||
case "key right":
|
||||
synthesizeKey("VK_RIGHT", { });
|
||||
break;
|
||||
case "key down":
|
||||
synthesizeKey("VK_UP", { });
|
||||
break;
|
||||
case "key up":
|
||||
synthesizeKey("VK_DOWN", { });
|
||||
break;
|
||||
case "key space":
|
||||
synthesizeKey("VK_SPACE", { });
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
]]>
|
||||
</script>
|
||||
|
||||
<body xmlns="http://www.w3.org/1999/xhtml">
|
||||
<p id="display">
|
||||
</p>
|
||||
<div id="content" style="display: none">
|
||||
</div>
|
||||
<pre id="test">
|
||||
</pre>
|
||||
</body>
|
||||
|
||||
</window>
|
@ -422,7 +422,7 @@
|
||||
</handlers>
|
||||
</binding>
|
||||
|
||||
<binding id="colorpicker-button">
|
||||
<binding id="colorpicker-button" extends="xul:menu">
|
||||
<resources>
|
||||
<stylesheet src="chrome://global/skin/colorpicker.css"/>
|
||||
</resources>
|
||||
@ -430,15 +430,13 @@
|
||||
<content>
|
||||
<xul:hbox class="colorpicker-button-colorbox" anonid="colorbox" flex="1" xbl:inherits="disabled"/>
|
||||
|
||||
<xul:popupset>
|
||||
<xul:popup class="colorpicker-button-menupopup" anonid="colorpopup"
|
||||
onmousedown="event.stopPropagation()"
|
||||
onpopupshowing="this._colorPicker.onPopupShowing()"
|
||||
onpopuphiding="this._colorPicker.onPopupHiding()"
|
||||
onselect="this._colorPicker.pickerChange()">
|
||||
<xul:colorpicker xbl:inherits="palettename,disabled" allowevents="true" anonid="colorpicker"/>
|
||||
</xul:popup>
|
||||
</xul:popupset>
|
||||
<xul:panel class="colorpicker-button-menupopup" anonid="colorpopup"
|
||||
onmousedown="event.stopPropagation()"
|
||||
onpopupshowing="this._colorPicker.onPopupShowing()"
|
||||
onpopuphiding="this._colorPicker.onPopupHiding()"
|
||||
onselect="this._colorPicker.pickerChange()">
|
||||
<xul:colorpicker xbl:inherits="palettename,disabled" allowevents="true" anonid="colorpicker"/>
|
||||
</xul:panel>
|
||||
</content>
|
||||
|
||||
<implementation implements="nsIAccessibleProvider, nsIDOMXULControlElement">
|
||||
@ -450,7 +448,9 @@
|
||||
</getter>
|
||||
</property>
|
||||
|
||||
<property name="open" onget="return this.mOpen"/>
|
||||
<property name="open"
|
||||
onget="return this.getAttribute('open') == 'true'"
|
||||
onset="this.showPopup();"/>
|
||||
<property name="color">
|
||||
<getter><![CDATA[
|
||||
return this.getAttribute("color");
|
||||
@ -464,8 +464,6 @@
|
||||
|
||||
<method name="initialize">
|
||||
<body><![CDATA[
|
||||
this.mOpen = false;
|
||||
|
||||
this.mColorBox = document.getAnonymousElementByAttribute(this, "anonid", "colorbox");
|
||||
this.mColorBox.style.backgroundColor = this.color;
|
||||
|
||||
@ -503,7 +501,7 @@
|
||||
|
||||
<method name="showPopup">
|
||||
<body><![CDATA[
|
||||
this.mPicker.parentNode.showPopup(this, -1, -1, "popup", "bottomleft", "topleft");
|
||||
this.mPicker.parentNode.openPopup(this, "after_start", 0, 0, false, false);
|
||||
]]></body>
|
||||
</method>
|
||||
|
||||
@ -515,22 +513,17 @@
|
||||
|
||||
<method name="onPopupShowing">
|
||||
<body><![CDATA[
|
||||
this.mOpen = true;
|
||||
this.setAttribute("open", "true");
|
||||
|
||||
if ("resetHover" in this.mPicker)
|
||||
this.mPicker.resetHover();
|
||||
this.mPicker.addKeyListener();
|
||||
this.mPicker.mIsPopup = true;
|
||||
// Initialize to current button's color
|
||||
this.mPicker.initColor(this.color);
|
||||
this.mPicker.addKeyListener();
|
||||
this.mPicker.mIsPopup = true;
|
||||
// Initialize to current button's color
|
||||
this.mPicker.initColor(this.color);
|
||||
]]></body>
|
||||
</method>
|
||||
|
||||
<method name="onPopupHiding">
|
||||
<body><![CDATA[
|
||||
this.mOpen = false;
|
||||
this.removeAttribute("open");
|
||||
// Removes the key listener
|
||||
this.mPicker.removeKeyListener();
|
||||
this.mPicker.mIsPopup = false;
|
||||
@ -555,23 +548,11 @@
|
||||
<handlers>
|
||||
<handler event="keydown"><![CDATA[
|
||||
// open popup if key is space/up/left/right/down and popup is closed
|
||||
if ( (event.keyCode == 32 || (event.keyCode > 36 && event.keyCode < 41)) && !this.mOpen)
|
||||
|
||||
if ( (event.keyCode == 32 || (event.keyCode > 36 && event.keyCode < 41)) && !this.open)
|
||||
this.showPopup();
|
||||
else if ( (event.keyCode == 27) && this.open)
|
||||
this.hidePopup();
|
||||
]]></handler>
|
||||
|
||||
<handler event="mousedown"><![CDATA[
|
||||
if (this.disabled)
|
||||
return;
|
||||
|
||||
// Though I would prefer the open the popup using the built-in
|
||||
// popup="_child" mechanism, I can't use that because I can't seem to
|
||||
// get it to recognize the popupalign and popupanchor attributes that way
|
||||
// So, I have to do it manually...
|
||||
this.focus();
|
||||
this.showPopup();
|
||||
]]></handler>
|
||||
|
||||
</handlers>
|
||||
</binding>
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user