Bug 544543 - Add some tests for xul textboxes to make sure their basic behavior and appearance does not regress; r=roc

This commit is contained in:
Ehsan Akhgari 2010-02-05 16:07:24 -05:00
parent c973cbafab
commit 6b88c58b00
40 changed files with 577 additions and 0 deletions

View File

@ -1,3 +1,6 @@
# include the XUL reftests
include xul/reftest.list
== newline-1.html newline-ref.html
== newline-2.html newline-ref.html
== newline-3.html newline-ref.html

View File

@ -0,0 +1,12 @@
<?xml version="1.0"?>
<?xml-stylesheet href="chrome://global/skin" type="text/css"?>
<window xmlns="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul"
xmlns:html="http://www.w3.org/1999/xhtml"
title="Textbox tests">
<script type="text/javascript" src="platform.js"/>
<textbox type="autocomplete" value="test"/>
</window>

View File

@ -0,0 +1,13 @@
<?xml version="1.0"?>
<?xml-stylesheet href="chrome://global/skin" type="text/css"?>
<?xml-stylesheet href="input.css" type="text/css"?>
<window xmlns="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul"
xmlns:html="http://www.w3.org/1999/xhtml"
title="Textbox tests">
<script type="text/javascript" src="platform.js"/>
<html:input class="ac" value="test"/>
</window>

View File

@ -0,0 +1,22 @@
<?xml version="1.0"?>
<?xml-stylesheet href="chrome://global/skin" type="text/css"?>
<window xmlns="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul"
xmlns:html="http://www.w3.org/1999/xhtml"
title="Textbox tests"
class="reftest-wait">
<script type="text/javascript" src="platform.js"/>
<script type="text/javascript">
<![CDATA[
// Wait for one second so that the emptytext attribute kicks in
window.setTimeout(function() {
document.documentElement.removeAttribute("class");
}, 1000);
]]>
</script>
<textbox emptytext="test"/>
</window>

View File

@ -0,0 +1,22 @@
<?xml version="1.0"?>
<?xml-stylesheet href="chrome://global/skin" type="text/css"?>
<window xmlns="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul"
xmlns:html="http://www.w3.org/1999/xhtml"
title="Textbox tests"
class="reftest-wait">
<script type="text/javascript" src="platform.js"/>
<script type="text/javascript">
<![CDATA[
// Wait for one second so that the emptytext attribute kicks in
window.setTimeout(function() {
document.documentElement.removeAttribute("class");
}, 1000);
]]>
</script>
<textbox emptytext="test" value="value"/>
</window>

View File

@ -0,0 +1,13 @@
<?xml version="1.0"?>
<?xml-stylesheet href="chrome://global/skin" type="text/css"?>
<?xml-stylesheet href="input.css" type="text/css"?>
<window xmlns="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul"
xmlns:html="http://www.w3.org/1999/xhtml"
title="Textbox tests">
<script type="text/javascript" src="platform.js"/>
<html:input class="empty" value="test"/>
</window>

View File

@ -0,0 +1,12 @@
<?xml version="1.0"?>
<?xml-stylesheet href="chrome://global/skin" type="text/css"?>
<window xmlns="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul"
xmlns:html="http://www.w3.org/1999/xhtml"
title="Textbox tests">
<script type="text/javascript" src="platform.js"/>
<textbox type="autocomplete"/>
</window>

View File

@ -0,0 +1,13 @@
<?xml version="1.0"?>
<?xml-stylesheet href="chrome://global/skin" type="text/css"?>
<?xml-stylesheet href="input.css" type="text/css"?>
<window xmlns="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul"
xmlns:html="http://www.w3.org/1999/xhtml"
title="Textbox tests">
<script type="text/javascript" src="platform.js"/>
<html:input class="ac"/>
</window>

View File

@ -0,0 +1,13 @@
<?xml version="1.0"?>
<?xml-stylesheet href="chrome://global/skin" type="text/css"?>
<?xml-stylesheet href="input.css" type="text/css"?>
<window xmlns="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul"
xmlns:html="http://www.w3.org/1999/xhtml"
title="Textbox tests">
<script type="text/javascript" src="platform.js"/>
<textbox multiline="true"/>
</window>

View File

@ -0,0 +1,13 @@
<?xml version="1.0"?>
<?xml-stylesheet href="chrome://global/skin" type="text/css"?>
<?xml-stylesheet href="input.css" type="text/css"?>
<window xmlns="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul"
xmlns:html="http://www.w3.org/1999/xhtml"
title="Textbox tests">
<script type="text/javascript" src="platform.js"/>
<textbox multiline="true" rows="10"/>
</window>

View File

@ -0,0 +1,13 @@
<?xml version="1.0"?>
<?xml-stylesheet href="chrome://global/skin" type="text/css"?>
<?xml-stylesheet href="input.css" type="text/css"?>
<window xmlns="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul"
xmlns:html="http://www.w3.org/1999/xhtml"
title="Textbox tests">
<script type="text/javascript" src="platform.js"/>
<html:textarea rows="10"/>
</window>

View File

@ -0,0 +1,12 @@
<?xml version="1.0"?>
<?xml-stylesheet href="chrome://global/skin" type="text/css"?>
<window xmlns="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul"
xmlns:html="http://www.w3.org/1999/xhtml"
title="Textbox tests">
<script type="text/javascript" src="platform.js"/>
<textbox/>
</window>

View File

@ -0,0 +1,12 @@
<?xml version="1.0"?>
<?xml-stylesheet href="chrome://global/skin" type="text/css"?>
<window xmlns="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul"
xmlns:html="http://www.w3.org/1999/xhtml"
title="Textbox tests">
<script type="text/javascript" src="platform.js"/>
<textbox type="password"/>
</window>

View File

@ -0,0 +1,12 @@
<?xml version="1.0"?>
<?xml-stylesheet href="chrome://global/skin" type="text/css"?>
<window xmlns="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul"
xmlns:html="http://www.w3.org/1999/xhtml"
title="Textbox tests">
<script type="text/javascript" src="platform.js"/>
<textbox type="number"/>
</window>

View File

@ -0,0 +1,12 @@
<?xml version="1.0"?>
<?xml-stylesheet href="chrome://global/skin" type="text/css"?>
<window xmlns="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul"
xmlns:html="http://www.w3.org/1999/xhtml"
title="Textbox tests">
<script type="text/javascript" src="platform.js"/>
<textbox type="search"/>
</window>

View File

@ -0,0 +1,12 @@
<?xml version="1.0"?>
<?xml-stylesheet href="chrome://global/skin" type="text/css"?>
<window xmlns="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul"
xmlns:html="http://www.w3.org/1999/xhtml"
title="Textbox tests">
<script type="text/javascript" src="platform.js"/>
<textbox type="timed"/>
</window>

View File

@ -0,0 +1,13 @@
<?xml version="1.0"?>
<?xml-stylesheet href="chrome://global/skin" type="text/css"?>
<?xml-stylesheet href="input.css" type="text/css"?>
<window xmlns="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul"
xmlns:html="http://www.w3.org/1999/xhtml"
title="Textbox tests">
<script type="text/javascript" src="platform.js"/>
<html:input/>
</window>

View File

@ -0,0 +1,69 @@
@namespace url('http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul');
@namespace html url('http://www.w3.org/1999/xhtml');
#mac html|input, #mac html|textarea {
margin: 4px;
padding: 0;
}
#win html|input, #win html|textarea {
margin: 2px 4px;
padding: 2px 2px 3px;
-moz-padding-start: 4px;
}
#win html|input:-moz-system-metric(windows-default-theme) {
padding: 1px 1px 2px;
-moz-padding-start: 3px;
}
#linux html|input, #linux html|textarea {
margin: 2px 4px;
padding: 2px 4px 3px;
}
textbox[multiline="true"], html|textarea {
border: none !important;
-moz-appearance: none !important;
-moz-border-radius-topright: 0;
-moz-border-radius-bottomleft: 0;
}
html|input, html|textarea {
font: inherit;
}
html|input.ac {
padding: 0 3px !important;
}
html|input.empty {
color: graytext;
}
html|input.empty:-moz-system-metric(windows-default-theme) {
font-style: italic;
}
html|input.num {
text-align: end;
}
#mac html|input.num {
-moz-margin-end: 8px;
}
#win html|input.num {
padding: 0 !important;
}
#linux html|input.num {
-moz-margin-end: 3px;
padding: 3px;
}
html|div.plainfield {
-moz-margin-start: 1px;
color: -moz-fieldtext;
}

View File

@ -0,0 +1,12 @@
<?xml version="1.0"?>
<?xml-stylesheet href="chrome://global/skin" type="text/css"?>
<window xmlns="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul"
xmlns:html="http://www.w3.org/1999/xhtml"
title="Textbox tests">
<script type="text/javascript" src="platform.js"/>
<textbox type="number"/>
</window>

View File

@ -0,0 +1,12 @@
<?xml version="1.0"?>
<?xml-stylesheet href="chrome://global/skin" type="text/css"?>
<window xmlns="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul"
xmlns:html="http://www.w3.org/1999/xhtml"
title="Textbox tests">
<script type="text/javascript" src="platform.js"/>
<textbox type="number" hidespinbuttons="false"/>
</window>

View File

@ -0,0 +1,12 @@
<?xml version="1.0"?>
<?xml-stylesheet href="chrome://global/skin" type="text/css"?>
<window xmlns="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul"
xmlns:html="http://www.w3.org/1999/xhtml"
title="Textbox tests">
<script type="text/javascript" src="platform.js"/>
<textbox type="number" hidespinbuttons="true"/>
</window>

View File

@ -0,0 +1,12 @@
<?xml version="1.0"?>
<?xml-stylesheet href="chrome://global/skin" type="text/css"?>
<window xmlns="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul"
xmlns:html="http://www.w3.org/1999/xhtml"
title="Textbox tests">
<script type="text/javascript" src="platform.js"/>
<textbox type="number" value="1" hidespinbuttons="true"/>
</window>

View File

@ -0,0 +1,12 @@
<?xml version="1.0"?>
<?xml-stylesheet href="chrome://global/skin" type="text/css"?>
<window xmlns="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul"
xmlns:html="http://www.w3.org/1999/xhtml"
title="Textbox tests">
<script type="text/javascript" src="platform.js"/>
<textbox type="number" value="test" hidespinbuttons="true"/>
</window>

View File

@ -0,0 +1,13 @@
<?xml version="1.0"?>
<?xml-stylesheet href="chrome://global/skin" type="text/css"?>
<?xml-stylesheet href="input.css" type="text/css"?>
<window xmlns="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul"
xmlns:html="http://www.w3.org/1999/xhtml"
title="Textbox tests">
<script type="text/javascript" src="platform.js"/>
<html:input value="0" class="num"/>
</window>

View File

@ -0,0 +1,12 @@
<?xml version="1.0"?>
<?xml-stylesheet href="chrome://global/skin" type="text/css"?>
<window xmlns="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul"
xmlns:html="http://www.w3.org/1999/xhtml"
title="Textbox tests">
<script type="text/javascript" src="platform.js"/>
<textbox type="number" value="123" hidespinbuttons="true"/>
</window>

View File

@ -0,0 +1,13 @@
<?xml version="1.0"?>
<?xml-stylesheet href="chrome://global/skin" type="text/css"?>
<?xml-stylesheet href="input.css" type="text/css"?>
<window xmlns="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul"
xmlns:html="http://www.w3.org/1999/xhtml"
title="Textbox tests">
<script type="text/javascript" src="platform.js"/>
<html:input value="123" class="num"/>
</window>

View File

@ -0,0 +1,12 @@
<?xml version="1.0"?>
<?xml-stylesheet href="chrome://global/skin" type="text/css"?>
<window xmlns="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul"
xmlns:html="http://www.w3.org/1999/xhtml"
title="Textbox tests">
<script type="text/javascript" src="platform.js"/>
<textbox type="password" value="test"/>
</window>

View File

@ -0,0 +1,12 @@
<?xml version="1.0"?>
<?xml-stylesheet href="chrome://global/skin" type="text/css"?>
<window xmlns="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul"
xmlns:html="http://www.w3.org/1999/xhtml"
title="Textbox tests">
<script type="text/javascript" src="platform.js"/>
<textbox type="password" value="abcd"/>
</window>

View File

@ -0,0 +1,12 @@
<?xml version="1.0"?>
<?xml-stylesheet href="chrome://global/skin" type="text/css"?>
<window xmlns="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul"
xmlns:html="http://www.w3.org/1999/xhtml"
title="Textbox tests">
<script type="text/javascript" src="platform.js"/>
<textbox value="test"/>
</window>

View File

@ -0,0 +1,13 @@
<?xml version="1.0"?>
<?xml-stylesheet href="chrome://global/skin" type="text/css"?>
<?xml-stylesheet href="input.css" type="text/css"?>
<window xmlns="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul"
xmlns:html="http://www.w3.org/1999/xhtml"
title="Textbox tests">
<script type="text/javascript" src="platform.js"/>
<html:input type="password" value="test"/>
</window>

View File

@ -0,0 +1,12 @@
<?xml version="1.0"?>
<?xml-stylesheet href="chrome://global/skin" type="text/css"?>
<window xmlns="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul"
xmlns:html="http://www.w3.org/1999/xhtml"
title="Textbox tests">
<script type="text/javascript" src="platform.js"/>
<textbox value="test" class="plain"/>
</window>

View File

@ -0,0 +1,13 @@
<?xml version="1.0"?>
<?xml-stylesheet href="chrome://global/skin" type="text/css"?>
<?xml-stylesheet href="input.css" type="text/css"?>
<window xmlns="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul"
xmlns:html="http://www.w3.org/1999/xhtml"
title="Textbox tests">
<script type="text/javascript" src="platform.js"/>
<html:div class="plainfield">test</html:div>
</window>

View File

@ -0,0 +1,21 @@
// The appearance of XUL elements is platform-specific, so we set the
// style of the root element according to the platform, so that the
// CSS code inside input.css can select the correct styles for each
// platform.
var id;
var ua = navigator.userAgent;
if (/Windows/.test(ua))
id = "win";
else if (/Linux/.test(ua))
id = "linux";
else if (/Mac OS X/.test(ua))
id = "mac";
if (id)
document.documentElement.setAttribute("id", id);
else
document.documentElement.appendChild(
document.createTextNode("Unrecognized platform")
);

View File

@ -0,0 +1,29 @@
== empty-1.xul empty-ref.xul
!= empty-2.xul empty-ref.xul
# There is no way to simulate an autocomplete textbox in windows Vista/7 default theme using CSS.
# Therefore, the equlity tests below should be marked as failing.
fails-if(windowsDefaultTheme&&/^Windows\x20NT\x206\.[01]$/.test(http.oscpu)) == autocomplete-1.xul autocomplete-ref.xul
fails-if(windowsDefaultTheme&&/^Windows\x20NT\x206\.[01]$/.test(http.oscpu)) == emptyautocomplete-1.xul emptyautocomplete-ref.xul
!= emptymultiline-1.xul emptymultiline-ref.xul
== emptymultiline-2.xul emptymultiline-ref.xul
== emptytextbox-1.xul emptytextbox-ref.xul
== emptytextbox-2.xul emptytextbox-ref.xul
!= emptytextbox-3.xul emptytextbox-ref.xul
!= emptytextbox-4.xul emptytextbox-ref.xul
== emptytextbox-5.xul emptytextbox-ref.xul
# There is no way to simulate a number textbox in windows Vista/7 default theme using CSS.
# Therefore, the equlity tests below should be marked as failing.
!= number-1.xul number-ref.xul
!= number-2.xul number-ref.xul
fails-if(windowsDefaultTheme&&/^Windows\x20NT\x206\.[01]$/.test(http.oscpu)) == number-3.xul number-ref.xul
!= number-4.xul number-ref.xul
fails-if(windowsDefaultTheme&&/^Windows\x20NT\x206\.[01]$/.test(http.oscpu)) == number-5.xul number-ref.xul
fails-if(windowsDefaultTheme&&/^Windows\x20NT\x206\.[01]$/.test(http.oscpu)) == numberwithvalue-1.xul numberwithvalue-ref.xul
== passwd-1.xul passwd-ref.xul
== passwd-2.xul passwd-ref.xul
!= passwd-3.xul passwd-ref.xul
== plain-1.xul plain-ref.xul
== textbox-1.xul textbox-ref.xul
!= textbox-disabled.xul textbox-ref.xul
# Read-only textboxes look like normal textboxes in windows Vista/7 default theme
fails-if(windowsDefaultTheme&&/^Windows\x20NT\x206\.[01]$/.test(http.oscpu)) != textbox-readonly.xul textbox-ref.xul

View File

@ -0,0 +1,12 @@
<?xml version="1.0"?>
<?xml-stylesheet href="chrome://global/skin" type="text/css"?>
<window xmlns="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul"
xmlns:html="http://www.w3.org/1999/xhtml"
title="Textbox tests">
<script type="text/javascript" src="platform.js"/>
<textbox value="test"/>
</window>

View File

@ -0,0 +1,12 @@
<?xml version="1.0"?>
<?xml-stylesheet href="chrome://global/skin" type="text/css"?>
<window xmlns="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul"
xmlns:html="http://www.w3.org/1999/xhtml"
title="Textbox tests">
<script type="text/javascript" src="platform.js"/>
<textbox value="test" disabled="true"/>
</window>

View File

@ -0,0 +1,12 @@
<?xml version="1.0"?>
<?xml-stylesheet href="chrome://global/skin" type="text/css"?>
<window xmlns="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul"
xmlns:html="http://www.w3.org/1999/xhtml"
title="Textbox tests">
<script type="text/javascript" src="platform.js"/>
<textbox value="test" readonly="true"/>
</window>

View File

@ -0,0 +1,13 @@
<?xml version="1.0"?>
<?xml-stylesheet href="chrome://global/skin" type="text/css"?>
<?xml-stylesheet href="input.css" type="text/css"?>
<window xmlns="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul"
xmlns:html="http://www.w3.org/1999/xhtml"
title="Textbox tests">
<script type="text/javascript" src="platform.js"/>
<html:input value="test"/>
</window>

View File

@ -305,6 +305,13 @@ function ReadManifest(aURL)
}
}
// Set a flag on sandbox if the windows default theme is active
var box = document.createElement("box");
box.setAttribute("id", "_box_windowsDefaultTheme");
document.documentElement.appendChild(box);
sandbox.windowsDefaultTheme = (getComputedStyle(box, null).display == "none");
document.documentElement.removeChild(box);
var line = {value:null};
var lineNo = 0;
var urlprefix = "";

View File

@ -34,6 +34,14 @@
- the terms of any one of the MPL, the GPL or the LGPL.
-
- ***** END LICENSE BLOCK ***** -->
<?xml-stylesheet type="text/css" href="data:text/css,
#_box_windowsDefaultTheme:-moz-system-metric(windows-default-theme) {
display: none;
}
" ?>
<window xmlns="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul"
id="reftest-window"
onload="OnRefTestLoad();"