2008-07-17 05:36:00 -07:00
|
|
|
<html>
|
|
|
|
|
|
|
|
<head>
|
|
|
|
<title>Text attributes tests</title>
|
|
|
|
<link rel="stylesheet" type="text/css" href="chrome://mochikit/content/tests/SimpleTest/test.css" />
|
|
|
|
|
|
|
|
<script type="application/javascript" src="chrome://mochikit/content/MochiKit/packed.js"></script>
|
|
|
|
<script type="application/javascript" src="chrome://mochikit/content/tests/SimpleTest/SimpleTest.js"></script>
|
|
|
|
|
|
|
|
<script type="application/javascript">
|
|
|
|
const nsIAccessibleRetrieval = Components.interfaces.nsIAccessibleRetrieval;
|
|
|
|
const nsIAccessibleText = Components.interfaces.nsIAccessibleText;
|
|
|
|
const nsIAccessibleEvent = Components.interfaces.nsIAccessibleEvent;
|
|
|
|
|
|
|
|
const nsIDOMNSEditableElement =
|
|
|
|
Components.interfaces.nsIDOMNSEditableElement;
|
|
|
|
const nsIObserverService = Components.interfaces.nsIObserverService;
|
|
|
|
|
|
|
|
var gAccRetrieval = null;
|
2008-09-11 07:41:11 -07:00
|
|
|
var gComputedStyle = null;
|
2008-07-17 05:36:00 -07:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Test text attributes.
|
|
|
|
*
|
|
|
|
* @param aID the ID of DOM element having text accessible
|
|
|
|
* @param aOffset the offset inside text accessible to fetch
|
|
|
|
* text attributes
|
|
|
|
* @param aAttrs the map of text attributes (name/value pairs)
|
|
|
|
* @param aStartOffset the start offset where text attributes are
|
|
|
|
* applied
|
|
|
|
* @param aEndOffset the end offset where text attribute are applied
|
|
|
|
*/
|
|
|
|
function testTextAttrs(aID, aOffset,
|
2008-08-28 01:31:01 -07:00
|
|
|
aAttrs, aStartOffset, aEndOffset)
|
2008-07-17 05:36:00 -07:00
|
|
|
{
|
2008-08-28 01:31:01 -07:00
|
|
|
var accessible = getTextAccessible(aID);
|
|
|
|
if (!accessible)
|
2008-07-17 05:36:00 -07:00
|
|
|
return;
|
|
|
|
|
|
|
|
var startOffset = { value: -1 };
|
|
|
|
var endOffset = { value: -1 };
|
|
|
|
var attrs = null;
|
|
|
|
try {
|
|
|
|
attrs = accessible.getTextAttributes(false,
|
|
|
|
aOffset,
|
|
|
|
startOffset, endOffset);
|
|
|
|
} catch (e) {
|
|
|
|
}
|
|
|
|
|
|
|
|
if (!attrs) {
|
|
|
|
ok(false, "Can't get text attributes for " + aID);
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2008-08-25 20:04:14 -07:00
|
|
|
var errorMsg = " for " + aID + " at offset " + aOffset;
|
2008-07-17 05:36:00 -07:00
|
|
|
is(startOffset.value, aStartOffset,
|
2008-07-23 08:09:11 -07:00
|
|
|
"Wrong start offset" + errorMsg);
|
2008-07-17 05:36:00 -07:00
|
|
|
is(endOffset.value, aEndOffset,
|
2008-07-23 08:09:11 -07:00
|
|
|
"Wrong end offset" + errorMsg);
|
2008-07-17 05:36:00 -07:00
|
|
|
|
2008-07-23 08:09:11 -07:00
|
|
|
compareTextAttrs(errorMsg, attrs, aAttrs);
|
2008-08-28 01:31:01 -07:00
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Test default text attributes.
|
|
|
|
*
|
|
|
|
* @param aID the ID of DOM element having text accessible
|
|
|
|
* @param aDefAttrs the list of default text attributes (name/value
|
|
|
|
* pairs)
|
|
|
|
*/
|
|
|
|
function testDefaultTextAttrs(aID, aDefAttrs)
|
|
|
|
{
|
|
|
|
var accessible = getTextAccessible(aID);
|
|
|
|
if (!accessible)
|
|
|
|
return;
|
2008-07-17 05:36:00 -07:00
|
|
|
|
|
|
|
var defAttrs = null;
|
|
|
|
try{
|
|
|
|
defAttrs = accessible.defaultTextAttributes;
|
|
|
|
} catch (e) {
|
|
|
|
}
|
|
|
|
|
|
|
|
if (!defAttrs) {
|
|
|
|
ok(false, "Can't get default attributes for " + aID);
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2008-08-28 01:31:01 -07:00
|
|
|
var errorMsg = ". Getting default attributes for " + aID;
|
2008-07-23 08:09:11 -07:00
|
|
|
compareTextAttrs(errorMsg, defAttrs, aDefAttrs);
|
2008-07-17 05:36:00 -07:00
|
|
|
}
|
|
|
|
|
2008-08-28 01:31:01 -07:00
|
|
|
function getTextAccessible(aID)
|
|
|
|
{
|
|
|
|
var node = document.getElementById(aID);
|
|
|
|
if (!node) {
|
|
|
|
ok(false, "Can't get the element with ID " + aID);
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
var accessible = null;
|
|
|
|
try {
|
|
|
|
accessible = gAccRetrieval.getAccessibleFor(node);
|
|
|
|
accessible.QueryInterface(nsIAccessibleText);
|
|
|
|
} catch (e) {
|
|
|
|
}
|
|
|
|
|
|
|
|
if (!accessible)
|
|
|
|
ok(false, "Can't query nsIAccessibleText interface for " + aID);
|
|
|
|
|
|
|
|
return accessible;
|
|
|
|
}
|
|
|
|
|
2008-07-23 08:09:11 -07:00
|
|
|
function compareTextAttrs(aErrorMsg, aAttrs, aExpectedAttrs)
|
2008-07-17 05:36:00 -07:00
|
|
|
{
|
|
|
|
var enumerate = aAttrs.enumerate();
|
|
|
|
while (enumerate.hasMoreElements()) {
|
|
|
|
var prop = enumerate.getNext().
|
|
|
|
QueryInterface(Components.interfaces.nsIPropertyElement);
|
|
|
|
|
|
|
|
if (!(prop.key in aExpectedAttrs))
|
2008-07-23 08:09:11 -07:00
|
|
|
ok(false,
|
2008-08-28 01:31:01 -07:00
|
|
|
"Unexpected attribute '" + prop.key + "' having '" + prop.value + "'" + aErrorMsg);
|
2008-07-17 05:36:00 -07:00
|
|
|
else
|
|
|
|
is(prop.value, aExpectedAttrs[prop.key],
|
2008-08-25 20:04:14 -07:00
|
|
|
"Attribute '" + prop.key + " 'has wrong value" + aErrorMsg);
|
2008-07-17 05:36:00 -07:00
|
|
|
}
|
|
|
|
|
|
|
|
for (var name in aExpectedAttrs) {
|
|
|
|
var value = "";
|
|
|
|
try {
|
|
|
|
value = aAttrs.getStringProperty(name);
|
|
|
|
} catch(e) {
|
|
|
|
}
|
|
|
|
|
|
|
|
if (!value)
|
2008-07-23 08:09:11 -07:00
|
|
|
ok(false,
|
2008-08-25 20:04:14 -07:00
|
|
|
"There is no expected attribute '" + name + "' " + aErrorMsg);
|
2008-07-17 05:36:00 -07:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
var gObserverService = null;
|
|
|
|
var gA11yEventObserver = null;
|
|
|
|
|
|
|
|
function testSpellTextAttrs()
|
|
|
|
{
|
|
|
|
gA11yEventObserver = {
|
|
|
|
observe: function observe(aSubject, aTopic, aData)
|
|
|
|
{
|
|
|
|
if (aTopic != "accessible-event")
|
|
|
|
return;
|
|
|
|
|
|
|
|
|
|
|
|
var event = aSubject.QueryInterface(nsIAccessibleEvent);
|
|
|
|
|
|
|
|
if (event.eventType == nsIAccessibleEvent.EVENT_TEXT_ATTRIBUTE_CHANGED)
|
|
|
|
this.mTextAttrChangedEventCounter++;
|
|
|
|
},
|
|
|
|
|
|
|
|
mTextAttrChangedEventCounter: 0
|
|
|
|
};
|
|
|
|
|
|
|
|
// Add accessibility event listeners
|
|
|
|
var gObserverService = Components.classes["@mozilla.org/observer-service;1"].
|
|
|
|
getService(nsIObserverService);
|
|
|
|
|
|
|
|
gObserverService.addObserver(gA11yEventObserver, "accessible-event",
|
|
|
|
false);
|
|
|
|
|
2008-07-23 08:09:11 -07:00
|
|
|
ID = "area8";
|
2008-07-17 05:36:00 -07:00
|
|
|
|
|
|
|
var node = document.getElementById(ID);
|
|
|
|
node.focus();
|
|
|
|
|
|
|
|
var editor = node.QueryInterface(nsIDOMNSEditableElement).editor;
|
|
|
|
var spellchecker = editor.getInlineSpellChecker(true);
|
|
|
|
spellchecker.enableRealTimeSpell = true;
|
|
|
|
|
|
|
|
window.setTimeout(function()
|
|
|
|
{
|
2008-09-11 07:41:11 -07:00
|
|
|
gComputedStyle = document.defaultView.getComputedStyle(node, "");
|
2008-07-17 05:36:00 -07:00
|
|
|
var defAttrs = {
|
2008-09-11 07:41:11 -07:00
|
|
|
"font-style": gComputedStyle.fontStyle,
|
|
|
|
"text-align": gComputedStyle.textAlign,
|
|
|
|
"font-size": gComputedStyle.fontSize,
|
|
|
|
"background-color": gComputedStyle.backgroundColor,
|
|
|
|
"font-weight": gComputedStyle.fontWeight,
|
|
|
|
"text-indent": gComputedStyle.textIndent,
|
|
|
|
"color": gComputedStyle.color,
|
|
|
|
"font-family": gComputedStyle.fontFamily,
|
|
|
|
"text-position": gComputedStyle.verticalAlign
|
2008-07-17 05:36:00 -07:00
|
|
|
};
|
2008-08-28 01:31:01 -07:00
|
|
|
testDefaultTextAttrs(ID, defAttrs);
|
2008-07-17 05:36:00 -07:00
|
|
|
|
2008-08-28 01:31:01 -07:00
|
|
|
var attrs = { };
|
2008-07-17 05:36:00 -07:00
|
|
|
var misspelledAttrs = {
|
|
|
|
"invalid": "spelling"
|
|
|
|
};
|
|
|
|
|
2008-08-28 01:31:01 -07:00
|
|
|
testTextAttrs(ID, 0, attrs, 0, 11);
|
|
|
|
testTextAttrs(ID, 11, misspelledAttrs, 11, 17);
|
|
|
|
testTextAttrs(ID, 17, attrs, 17, 18);
|
|
|
|
testTextAttrs(ID, 18, misspelledAttrs, 18, 22);
|
2008-07-17 05:36:00 -07:00
|
|
|
|
|
|
|
is(gA11yEventObserver.mTextAttrChangedEventCounter, 2,
|
|
|
|
"Wrong count of 'text attribute changed' events for " + ID);
|
|
|
|
|
|
|
|
// Remove a11y events listener
|
|
|
|
gObserverService.removeObserver(gA11yEventObserver,
|
|
|
|
"accessible-event");
|
|
|
|
|
|
|
|
SimpleTest.finish();
|
|
|
|
}, 0);
|
|
|
|
}
|
|
|
|
|
|
|
|
function doTest()
|
|
|
|
{
|
|
|
|
gAccRetrieval = Components.classes["@mozilla.org/accessibleRetrieval;1"].
|
|
|
|
getService(nsIAccessibleRetrieval);
|
|
|
|
|
|
|
|
//////////////////////////////////////////////////////////////////////////
|
|
|
|
// area1
|
|
|
|
var ID = "area1";
|
2008-09-11 07:41:11 -07:00
|
|
|
var tempElem = document.getElementById(ID);
|
|
|
|
gComputedStyle = document.defaultView.getComputedStyle(tempElem, "");
|
2008-07-17 05:36:00 -07:00
|
|
|
var defAttrs = {
|
2008-09-11 07:41:11 -07:00
|
|
|
"font-style": gComputedStyle.fontStyle,
|
|
|
|
"text-align": gComputedStyle.textAlign,
|
|
|
|
"font-size": gComputedStyle.fontSize,
|
2008-09-18 00:13:08 -07:00
|
|
|
"background-color": gComputedStyle.backgroundColor,
|
2008-09-11 07:41:11 -07:00
|
|
|
"font-weight": gComputedStyle.fontWeight,
|
|
|
|
"text-indent": gComputedStyle.textIndent,
|
|
|
|
"color": gComputedStyle.color,
|
|
|
|
"font-family": gComputedStyle.fontFamily,
|
|
|
|
"text-position": gComputedStyle.verticalAlign
|
2008-07-17 05:36:00 -07:00
|
|
|
};
|
|
|
|
|
2008-08-28 01:31:01 -07:00
|
|
|
testDefaultTextAttrs(ID, defAttrs);
|
|
|
|
|
2008-07-17 05:36:00 -07:00
|
|
|
var attrs = {};
|
2008-08-28 01:31:01 -07:00
|
|
|
testTextAttrs(ID, 0, attrs, 0, 7);
|
2008-07-17 05:36:00 -07:00
|
|
|
|
2008-09-11 07:41:11 -07:00
|
|
|
tempElem = tempElem.firstChild.nextSibling;
|
|
|
|
gComputedStyle = document.defaultView.getComputedStyle(tempElem, "");
|
|
|
|
attrs = {"font-weight": gComputedStyle.fontWeight};
|
2008-08-28 01:31:01 -07:00
|
|
|
testTextAttrs(ID, 7, attrs, 7, 11);
|
2008-07-17 05:36:00 -07:00
|
|
|
|
|
|
|
attrs = {};
|
2008-08-28 01:31:01 -07:00
|
|
|
testTextAttrs(ID, 12, attrs, 11, 18);
|
2008-07-17 05:36:00 -07:00
|
|
|
|
|
|
|
//////////////////////////////////////////////////////////////////////////
|
|
|
|
// area2
|
|
|
|
ID = "area2";
|
2008-09-11 07:41:11 -07:00
|
|
|
tempElem = document.getElementById(ID);
|
|
|
|
gComputedStyle = document.defaultView.getComputedStyle(tempElem, "");
|
2008-07-17 05:36:00 -07:00
|
|
|
defAttrs = {
|
2008-09-11 07:41:11 -07:00
|
|
|
"font-style": gComputedStyle.fontStyle,
|
|
|
|
"text-align": gComputedStyle.textAlign,
|
|
|
|
"font-size": gComputedStyle.fontSize,
|
2008-09-18 00:13:08 -07:00
|
|
|
"background-color": gComputedStyle.backgroundColor,
|
2008-09-11 07:41:11 -07:00
|
|
|
"font-weight": gComputedStyle.fontWeight,
|
|
|
|
"text-indent": gComputedStyle.textIndent,
|
|
|
|
"color": gComputedStyle.color,
|
|
|
|
"font-family": gComputedStyle.fontFamily,
|
|
|
|
"text-position": gComputedStyle.verticalAlign
|
2008-07-17 05:36:00 -07:00
|
|
|
};
|
|
|
|
|
2008-08-28 01:31:01 -07:00
|
|
|
testDefaultTextAttrs(ID, defAttrs);
|
|
|
|
|
2008-07-17 05:36:00 -07:00
|
|
|
attrs = {};
|
2008-08-28 01:31:01 -07:00
|
|
|
testTextAttrs(ID, 0, attrs, 0, 7);
|
2008-07-17 05:36:00 -07:00
|
|
|
|
2008-09-11 07:41:11 -07:00
|
|
|
tempElem = tempElem.firstChild.nextSibling;
|
|
|
|
gComputedStyle = document.defaultView.getComputedStyle(tempElem, "");
|
|
|
|
attrs = {"font-weight": gComputedStyle.fontWeight};
|
2008-08-28 01:31:01 -07:00
|
|
|
testTextAttrs(ID, 7, attrs, 7, 12);
|
2008-07-17 05:36:00 -07:00
|
|
|
|
2008-09-11 07:41:11 -07:00
|
|
|
tempElem = tempElem.firstChild.nextSibling;
|
|
|
|
gComputedStyle = document.defaultView.getComputedStyle(tempElem, "");
|
|
|
|
attrs = {"font-style": gComputedStyle.fontStyle,
|
|
|
|
"font-weight": gComputedStyle.fontWeight};
|
2008-08-28 01:31:01 -07:00
|
|
|
testTextAttrs(ID, 13, attrs, 12, 19);
|
2008-07-17 05:36:00 -07:00
|
|
|
|
2008-09-11 07:41:11 -07:00
|
|
|
tempElem = tempElem.parentNode;
|
|
|
|
gComputedStyle = document.defaultView.getComputedStyle(tempElem, "");
|
2008-07-17 05:36:00 -07:00
|
|
|
attrs = {"font-weight": "401"};
|
2008-08-28 01:31:01 -07:00
|
|
|
testTextAttrs(ID, 20, attrs, 19, 23);
|
2008-07-17 05:36:00 -07:00
|
|
|
|
|
|
|
attrs = {};
|
2008-08-28 01:31:01 -07:00
|
|
|
testTextAttrs(ID, 24, attrs, 23, 30);
|
2008-07-17 05:36:00 -07:00
|
|
|
|
|
|
|
//////////////////////////////////////////////////////////////////////////
|
|
|
|
// area3
|
|
|
|
ID = "area3";
|
2008-09-11 07:41:11 -07:00
|
|
|
tempElem = document.getElementById(ID);
|
|
|
|
gComputedStyle = document.defaultView.getComputedStyle(tempElem, "");
|
2008-07-17 05:36:00 -07:00
|
|
|
defAttrs = {
|
2008-09-11 07:41:11 -07:00
|
|
|
"font-style": gComputedStyle.fontStyle,
|
|
|
|
"text-align": gComputedStyle.textAlign,
|
|
|
|
"font-size": gComputedStyle.fontSize,
|
|
|
|
"background-color": gComputedStyle.backgroundColor,
|
|
|
|
"font-weight": gComputedStyle.fontWeight,
|
|
|
|
"text-indent": gComputedStyle.textIndent,
|
|
|
|
"color": gComputedStyle.color,
|
|
|
|
"font-family": gComputedStyle.fontFamily,
|
|
|
|
"text-position": gComputedStyle.verticalAlign
|
2008-07-17 05:36:00 -07:00
|
|
|
};
|
|
|
|
|
2008-08-28 01:31:01 -07:00
|
|
|
testDefaultTextAttrs(ID, defAttrs);
|
|
|
|
|
2008-09-11 07:41:11 -07:00
|
|
|
tempElem = tempElem.firstChild.nextSibling;
|
|
|
|
gComputedStyle = document.defaultView.getComputedStyle(tempElem, "");
|
|
|
|
attrs = {"color": gComputedStyle.color};
|
2008-08-28 01:31:01 -07:00
|
|
|
testTextAttrs(ID, 0, attrs, 0, 6);
|
2008-07-17 05:36:00 -07:00
|
|
|
|
2008-09-11 07:41:11 -07:00
|
|
|
tempElem = tempElem.firstChild.nextSibling;
|
|
|
|
gComputedStyle = document.defaultView.getComputedStyle(tempElem, "");
|
|
|
|
attrs = {"color": gComputedStyle.color};
|
2008-08-28 01:31:01 -07:00
|
|
|
testTextAttrs(ID, 6, attrs, 6, 26);
|
2008-07-17 05:36:00 -07:00
|
|
|
|
2008-09-11 07:41:11 -07:00
|
|
|
tempElem = tempElem.parentNode;
|
|
|
|
gComputedStyle = document.defaultView.getComputedStyle(tempElem, "");
|
|
|
|
attrs = {"color": gComputedStyle.color};
|
2008-08-28 01:31:01 -07:00
|
|
|
testTextAttrs(ID, 26, attrs, 26, 27);
|
|
|
|
|
2008-09-11 07:41:11 -07:00
|
|
|
tempElem = tempElem.nextSibling;
|
|
|
|
gComputedStyle = document.defaultView.getComputedStyle(tempElem, "");
|
|
|
|
attrs = {"color": gComputedStyle.color,
|
|
|
|
"background-color": gComputedStyle.backgroundColor};
|
2008-08-28 01:31:01 -07:00
|
|
|
testTextAttrs(ID, 27, attrs, 27, 50);
|
2008-07-17 05:36:00 -07:00
|
|
|
|
|
|
|
//////////////////////////////////////////////////////////////////////////
|
|
|
|
// area4
|
|
|
|
ID = "area4";
|
2008-09-11 07:41:11 -07:00
|
|
|
tempElem = document.getElementById(ID);
|
|
|
|
gComputedStyle = document.defaultView.getComputedStyle(tempElem, "");
|
2008-07-17 05:36:00 -07:00
|
|
|
defAttrs = {
|
2008-09-11 07:41:11 -07:00
|
|
|
"font-style": gComputedStyle.fontStyle,
|
|
|
|
"text-align": gComputedStyle.textAlign,
|
|
|
|
"font-size": gComputedStyle.fontSize,
|
2008-09-18 00:13:08 -07:00
|
|
|
"background-color": gComputedStyle.backgroundColor,
|
2008-09-11 07:41:11 -07:00
|
|
|
"font-weight": gComputedStyle.fontWeight,
|
|
|
|
"text-indent": gComputedStyle.textIndent,
|
|
|
|
"color": gComputedStyle.color,
|
|
|
|
"font-family": gComputedStyle.fontFamily,
|
|
|
|
"text-position": gComputedStyle.verticalAlign
|
2008-07-17 05:36:00 -07:00
|
|
|
};
|
|
|
|
|
2008-08-28 01:31:01 -07:00
|
|
|
testDefaultTextAttrs(ID, defAttrs);
|
|
|
|
|
2008-09-11 07:41:11 -07:00
|
|
|
tempElem = tempElem.firstChild.nextSibling;
|
|
|
|
gComputedStyle = document.defaultView.getComputedStyle(tempElem, "");
|
|
|
|
attrs = {"color": gComputedStyle.color};
|
2008-08-28 01:31:01 -07:00
|
|
|
testTextAttrs(ID, 0, attrs, 0, 16);
|
2008-07-17 05:36:00 -07:00
|
|
|
|
2008-09-11 07:41:11 -07:00
|
|
|
tempElem = tempElem.nextSibling.firstChild.nextSibling;
|
|
|
|
gComputedStyle = document.defaultView.getComputedStyle(tempElem, "");
|
|
|
|
attrs = {"color": gComputedStyle.color};
|
2008-08-28 01:31:01 -07:00
|
|
|
testTextAttrs(ID, 16, attrs, 16, 33);
|
2008-07-17 05:36:00 -07:00
|
|
|
|
2008-09-11 07:41:11 -07:00
|
|
|
tempElem = tempElem.parentNode;
|
|
|
|
gComputedStyle = document.defaultView.getComputedStyle(tempElem, "");
|
|
|
|
attrs = {"color": gComputedStyle.color};
|
2008-08-28 01:31:01 -07:00
|
|
|
testTextAttrs(ID, 34, attrs, 33, 46);
|
2008-07-17 05:36:00 -07:00
|
|
|
|
|
|
|
//////////////////////////////////////////////////////////////////////////
|
|
|
|
// area5
|
|
|
|
ID = "area5";
|
2008-09-11 07:41:11 -07:00
|
|
|
tempElem = document.getElementById(ID);
|
|
|
|
gComputedStyle = document.defaultView.getComputedStyle(tempElem, "");
|
2008-07-17 05:36:00 -07:00
|
|
|
defAttrs = {
|
2008-09-11 07:41:11 -07:00
|
|
|
"font-style": gComputedStyle.fontStyle,
|
|
|
|
"text-align": gComputedStyle.textAlign,
|
|
|
|
"font-size": gComputedStyle.fontSize,
|
2008-09-18 00:13:08 -07:00
|
|
|
"background-color": gComputedStyle.backgroundColor,
|
2008-09-11 07:41:11 -07:00
|
|
|
"font-weight": gComputedStyle.fontWeight,
|
|
|
|
"text-indent": gComputedStyle.textIndent,
|
|
|
|
"color": gComputedStyle.color,
|
|
|
|
"font-family": gComputedStyle.fontFamily,
|
|
|
|
"text-position": gComputedStyle.verticalAlign
|
2008-07-17 05:36:00 -07:00
|
|
|
};
|
|
|
|
|
2008-08-28 01:31:01 -07:00
|
|
|
testDefaultTextAttrs(ID, defAttrs);
|
|
|
|
|
2008-09-11 07:41:11 -07:00
|
|
|
tempElem = tempElem.firstChild.nextSibling;
|
|
|
|
gComputedStyle = document.defaultView.getComputedStyle(tempElem, "");
|
|
|
|
attrs = {"color": gComputedStyle.color};
|
2008-08-28 01:31:01 -07:00
|
|
|
testTextAttrs(ID, 0, attrs, 0, 5);
|
2008-07-17 05:36:00 -07:00
|
|
|
|
|
|
|
attrs = {};
|
2008-08-28 01:31:01 -07:00
|
|
|
testTextAttrs(ID, 7, attrs, 5, 8);
|
2008-07-17 05:36:00 -07:00
|
|
|
|
2008-09-11 07:41:11 -07:00
|
|
|
tempElem = tempElem.nextSibling.nextSibling.nextSibling.nextSibling;
|
|
|
|
gComputedStyle = document.defaultView.getComputedStyle(tempElem, "");
|
|
|
|
attrs = {"color": gComputedStyle.color};
|
2008-08-28 01:31:01 -07:00
|
|
|
testTextAttrs(ID, 9, attrs, 8, 11);
|
2008-07-17 05:36:00 -07:00
|
|
|
|
|
|
|
attrs = {};
|
2008-08-28 01:31:01 -07:00
|
|
|
testTextAttrs(ID, 11, attrs, 11, 18);
|
2008-07-17 05:36:00 -07:00
|
|
|
|
|
|
|
//////////////////////////////////////////////////////////////////////////
|
2008-07-23 08:09:11 -07:00
|
|
|
// area6 (CSS vertical-align property, bug 445938)
|
2008-07-17 05:36:00 -07:00
|
|
|
ID = "area6";
|
2008-09-11 07:41:11 -07:00
|
|
|
tempElem = document.getElementById(ID);
|
|
|
|
gComputedStyle = document.defaultView.getComputedStyle(tempElem, "");
|
2008-07-17 05:36:00 -07:00
|
|
|
defAttrs = {
|
2008-09-11 07:41:11 -07:00
|
|
|
"font-style": gComputedStyle.fontStyle,
|
|
|
|
"text-align": gComputedStyle.textAlign,
|
|
|
|
"font-size": gComputedStyle.fontSize,
|
2008-09-18 00:13:08 -07:00
|
|
|
"background-color": gComputedStyle.backgroundColor,
|
2008-09-11 07:41:11 -07:00
|
|
|
"font-weight": gComputedStyle.fontWeight,
|
|
|
|
"text-indent": gComputedStyle.textIndent,
|
|
|
|
"color": gComputedStyle.color,
|
|
|
|
"font-family": gComputedStyle.fontFamily,
|
|
|
|
"text-position": gComputedStyle.verticalAlign
|
2008-07-23 08:09:11 -07:00
|
|
|
};
|
|
|
|
|
2008-08-28 01:31:01 -07:00
|
|
|
testDefaultTextAttrs(ID, defAttrs);
|
|
|
|
|
2008-07-23 08:09:11 -07:00
|
|
|
attrs = {};
|
2008-08-28 01:31:01 -07:00
|
|
|
testTextAttrs(ID, 0, attrs, 0, 5);
|
2008-07-23 08:09:11 -07:00
|
|
|
|
2008-09-11 07:41:11 -07:00
|
|
|
tempElem = tempElem.firstChild.nextSibling;
|
|
|
|
gComputedStyle = document.defaultView.getComputedStyle(tempElem, "");
|
|
|
|
attrs = {"text-position": gComputedStyle.verticalAlign,
|
|
|
|
"font-size": gComputedStyle.fontSize};
|
2008-08-28 01:31:01 -07:00
|
|
|
testTextAttrs(ID, 5, attrs, 5, 13);
|
2008-07-23 08:09:11 -07:00
|
|
|
|
|
|
|
attrs = {};
|
2008-08-28 01:31:01 -07:00
|
|
|
testTextAttrs(ID, 13, attrs, 13, 27);
|
2008-07-23 08:09:11 -07:00
|
|
|
|
2008-09-11 07:41:11 -07:00
|
|
|
tempElem = tempElem.nextSibling.nextSibling;
|
|
|
|
gComputedStyle = document.defaultView.getComputedStyle(tempElem, "");
|
|
|
|
attrs = {"text-position": gComputedStyle.verticalAlign};
|
2008-08-28 01:31:01 -07:00
|
|
|
testTextAttrs(ID, 27, attrs, 27, 35);
|
2008-07-23 08:09:11 -07:00
|
|
|
|
|
|
|
attrs = {};
|
2008-08-28 01:31:01 -07:00
|
|
|
testTextAttrs(ID, 35, attrs, 35, 39);
|
2008-07-23 08:09:11 -07:00
|
|
|
|
2008-09-11 07:41:11 -07:00
|
|
|
tempElem = tempElem.nextSibling.nextSibling;
|
|
|
|
gComputedStyle = document.defaultView.getComputedStyle(tempElem, "");
|
|
|
|
attrs = {"text-position": gComputedStyle.verticalAlign,
|
|
|
|
"font-size": gComputedStyle.fontSize};
|
2008-08-28 01:31:01 -07:00
|
|
|
testTextAttrs(ID, 39, attrs, 39, 50);
|
2008-07-23 08:09:11 -07:00
|
|
|
|
|
|
|
attrs = {};
|
2008-08-28 01:31:01 -07:00
|
|
|
testTextAttrs(ID, 50, attrs, 50, 55);
|
2008-07-23 08:09:11 -07:00
|
|
|
|
2008-09-11 07:41:11 -07:00
|
|
|
tempElem = tempElem.nextSibling.nextSibling;
|
|
|
|
gComputedStyle = document.defaultView.getComputedStyle(tempElem, "");
|
|
|
|
attrs = {"text-position": gComputedStyle.verticalAlign};
|
2008-08-28 01:31:01 -07:00
|
|
|
testTextAttrs(ID, 55, attrs, 55, 64);
|
2008-07-23 08:09:11 -07:00
|
|
|
|
|
|
|
//////////////////////////////////////////////////////////////////////////
|
|
|
|
// area7
|
|
|
|
ID = "area7";
|
2008-09-11 07:41:11 -07:00
|
|
|
tempElem = document.getElementById(ID);
|
|
|
|
gComputedStyle = document.defaultView.getComputedStyle(tempElem, "");
|
2008-07-23 08:09:11 -07:00
|
|
|
defAttrs = {
|
2008-09-11 07:41:11 -07:00
|
|
|
"font-style": gComputedStyle.fontStyle,
|
|
|
|
"text-align": gComputedStyle.textAlign,
|
|
|
|
"font-size": gComputedStyle.fontSize,
|
2008-09-18 00:13:08 -07:00
|
|
|
"background-color": gComputedStyle.backgroundColor,
|
2008-09-11 07:41:11 -07:00
|
|
|
"font-weight": gComputedStyle.fontWeight,
|
|
|
|
"text-indent": gComputedStyle.textIndent,
|
|
|
|
"color": gComputedStyle.color,
|
|
|
|
"font-family": gComputedStyle.fontFamily,
|
|
|
|
"text-position": gComputedStyle.verticalAlign
|
2008-07-17 05:36:00 -07:00
|
|
|
};
|
|
|
|
|
2008-08-28 01:31:01 -07:00
|
|
|
testDefaultTextAttrs(ID, defAttrs);
|
|
|
|
|
2008-07-17 05:36:00 -07:00
|
|
|
attrs = {"language": "ru"};
|
2008-08-28 01:31:01 -07:00
|
|
|
testTextAttrs(ID, 0, attrs, 0, 12);
|
2008-07-17 05:36:00 -07:00
|
|
|
|
|
|
|
attrs = {"language": "en"};
|
2008-08-28 01:31:01 -07:00
|
|
|
testTextAttrs(ID, 12, attrs, 12, 13);
|
2008-07-17 05:36:00 -07:00
|
|
|
|
2008-09-11 07:41:11 -07:00
|
|
|
tempElem = tempElem.firstChild.nextSibling.nextSibling.nextSibling;
|
|
|
|
gComputedStyle = document.defaultView.getComputedStyle(tempElem, "");
|
|
|
|
attrs = {"language" :"en",
|
|
|
|
"background-color": gComputedStyle.backgroundColor};
|
2008-08-28 01:31:01 -07:00
|
|
|
testTextAttrs(ID, 13, attrs, 13, 26);
|
2008-07-17 05:36:00 -07:00
|
|
|
|
|
|
|
attrs = {"language": "en" };
|
2008-08-28 01:31:01 -07:00
|
|
|
testTextAttrs(ID, 26, attrs, 26, 27);
|
2008-07-17 05:36:00 -07:00
|
|
|
|
|
|
|
attrs = {"language": "de"};
|
2008-08-28 01:31:01 -07:00
|
|
|
testTextAttrs(ID, 27, attrs, 27, 42);
|
2008-07-17 05:36:00 -07:00
|
|
|
|
|
|
|
attrs = {"language": "en"};
|
2008-08-28 01:31:01 -07:00
|
|
|
testTextAttrs(ID, 42, attrs, 42, 43);
|
2008-07-17 05:36:00 -07:00
|
|
|
|
|
|
|
attrs = {};
|
2008-08-28 01:31:01 -07:00
|
|
|
testTextAttrs(ID, 43, attrs, 43, 50);
|
2008-07-17 05:36:00 -07:00
|
|
|
|
2008-09-11 07:41:11 -07:00
|
|
|
tempElem = tempElem.nextSibling.nextSibling.nextSibling.nextSibling.firstChild.nextSibling;
|
|
|
|
gComputedStyle = document.defaultView.getComputedStyle(tempElem, "");
|
|
|
|
attrs = {"color": gComputedStyle.color};
|
2008-08-28 01:31:01 -07:00
|
|
|
testTextAttrs(ID, 50, attrs, 50, 57);
|
2008-07-17 05:36:00 -07:00
|
|
|
|
2008-09-11 07:41:11 -07:00
|
|
|
tempElem = tempElem.firstChild.nextSibling;
|
|
|
|
gComputedStyle = document.defaultView.getComputedStyle(tempElem, "");
|
|
|
|
attrs = {"font-weight": gComputedStyle.fontWeight,
|
|
|
|
"color": gComputedStyle.color};
|
2008-08-28 01:31:01 -07:00
|
|
|
testTextAttrs(ID, 57, attrs, 57, 61);
|
2008-07-17 05:36:00 -07:00
|
|
|
|
2008-09-11 07:41:11 -07:00
|
|
|
tempElem = tempElem.parentNode;
|
|
|
|
gComputedStyle = document.defaultView.getComputedStyle(tempElem, "");
|
|
|
|
attrs = {"color": gComputedStyle.color};
|
2008-08-28 01:31:01 -07:00
|
|
|
testTextAttrs(ID, 61, attrs, 61, 68);
|
2008-07-17 05:36:00 -07:00
|
|
|
|
|
|
|
//////////////////////////////////////////////////////////////////////////
|
|
|
|
// test spelling text attributes
|
|
|
|
testSpellTextAttrs(); // Will call SimpleTest.finish();
|
|
|
|
}
|
|
|
|
|
|
|
|
SimpleTest.waitForExplicitFinish();
|
|
|
|
addLoadEvent(doTest);
|
|
|
|
</script>
|
|
|
|
</head>
|
|
|
|
<body>
|
|
|
|
|
|
|
|
<a target="_blank"
|
|
|
|
href="https://bugzilla.mozilla.org/show_bug.cgi?id=345759"
|
|
|
|
title="Implement text attributes">
|
|
|
|
Mozilla Bug 345759
|
|
|
|
</a>
|
|
|
|
<p id="display"></p>
|
|
|
|
<div id="content" style="display: none"></div>
|
|
|
|
<pre id="test">
|
|
|
|
</pre>
|
|
|
|
|
|
|
|
<p id="area1">Normal <b>Bold</b> Normal</p>
|
|
|
|
<p id="area2">Normal <b>Bold <i>Italic </i>Bold</b> Normal</p>
|
2008-08-28 01:31:01 -07:00
|
|
|
<p id="area3" style="background-color: blue;">
|
|
|
|
<span style="color: green; background-color: rgb(0, 0, 255)">
|
2008-07-17 05:36:00 -07:00
|
|
|
Green
|
|
|
|
<span style="color: red">but children are red</span>
|
2008-08-28 01:31:01 -07:00
|
|
|
</span><span style="color: green; background-color: rgb(255, 255, 0);">
|
2008-07-17 05:36:00 -07:00
|
|
|
Another green section.
|
|
|
|
</span>
|
|
|
|
</p>
|
|
|
|
<p id="area4">
|
|
|
|
<span style="color: green">
|
|
|
|
Green
|
|
|
|
</span><span style="color: green">
|
|
|
|
Green too
|
|
|
|
<span style="color: red">with red children</span>
|
|
|
|
Green again
|
|
|
|
</span>
|
|
|
|
</p>
|
|
|
|
<p id="area5">
|
|
|
|
<span style="color: green">Green</span>
|
|
|
|
<img src="moz.png" alt="image"/>
|
|
|
|
<span style="color: red">Red</span>Normal
|
|
|
|
</p>
|
2008-07-23 08:09:11 -07:00
|
|
|
<p id="area6">
|
|
|
|
This <sup>sentence</sup> has the word
|
|
|
|
<span style="vertical-align:super;">sentence</span> in
|
|
|
|
<sub>superscript</sub> and
|
|
|
|
<span style="vertical-align:sub;">subscript</span>
|
|
|
|
</p>
|
|
|
|
|
|
|
|
<p lang="en" id="area7">
|
2008-07-17 05:36:00 -07:00
|
|
|
<span lang="ru">Привет</span>
|
|
|
|
<span style="background-color: blue">Blue BG color</span>
|
|
|
|
<span lang="de">Ich bin/Du bist</span>
|
|
|
|
<span lang="en">
|
|
|
|
Normal
|
|
|
|
<span style="color: magenta">Magenta<b>Bold</b>Magenta</span>
|
|
|
|
</span>
|
|
|
|
</p>
|
|
|
|
|
2008-07-23 08:09:11 -07:00
|
|
|
<input id="area8" value="valid text inalid tixt"/>
|
2008-07-17 05:36:00 -07:00
|
|
|
|
|
|
|
<p id="output"/>
|
|
|
|
</body>
|
|
|
|
</html>
|