mirror of
https://gitlab.winehq.org/wine/wine-gecko.git
synced 2024-09-13 09:24:08 -07:00
235 lines
7.8 KiB
HTML
235 lines
7.8 KiB
HTML
<html>
|
|
|
|
<head>
|
|
<title>nsIAccessible::name calculation</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 nsIAccessibleRole = Components.interfaces.nsIAccessibleRole;
|
|
|
|
var gAccRetrieval = null;
|
|
|
|
function testName(aID, aName)
|
|
{
|
|
var elm = document.getElementById(aID);
|
|
if (!elm) {
|
|
ok(false, "There is no element with ID " + aID);
|
|
return;
|
|
}
|
|
|
|
var acc = null;
|
|
try {
|
|
acc = gAccRetrieval.getAccessibleFor(elm);
|
|
} catch(e) {
|
|
}
|
|
|
|
if (!acc) {
|
|
ok(false, "There is no accessible for " + aID);
|
|
return;
|
|
}
|
|
|
|
is(acc.name, aName, "Wrong name of the accessible for " + aID);
|
|
}
|
|
|
|
function doTest()
|
|
{
|
|
gAccRetrieval = Components.classes["@mozilla.org/accessibleRetrieval;1"].
|
|
getService(nsIAccessibleRetrieval);
|
|
|
|
|
|
//////////////////////////////////////////////////////////////////////////
|
|
// aria-labelledby
|
|
|
|
// Single relation. The value of 'aria-labelledby' contains the ID of
|
|
// an element. Gets the name from text node of that element.
|
|
testName("btn_labelledby_text", "text");
|
|
|
|
// Multiple relations. The value of 'aria-labelledby' contains the IDs
|
|
// of elements. Gets the name from text nodes of those elements.
|
|
testName("btn_labelledby_texts", "text1 text2");
|
|
|
|
|
|
//////////////////////////////////////////////////////////////////////////
|
|
// Name from subtree (single relation labelled_by).
|
|
|
|
// Gets the name from text nodes contained by nested elements
|
|
testName("btn_labelledby_mixed", "nomore text");
|
|
|
|
// Gets the name from text nodes contained by nested elements having block
|
|
// representation (every text node value in the name should be devided by
|
|
// spaces)
|
|
testName("btn_labelledby_mixed_block", "text more text");
|
|
|
|
// Gets the name from text nodes contained by html:td (every text node
|
|
// value in the name should be devided by spaces).
|
|
// XXX: this case is rather a feature than strong wanted behaviour.
|
|
testName("btn_labelledby_mixed_table", "text space text");
|
|
|
|
// Gets the name from image accessible.
|
|
testName("btn_labelledby_mixed_img", "text image");
|
|
|
|
// Gets the name from input accessibles
|
|
// Note: if input have label elements then the name isn't calculated
|
|
// from them.
|
|
testName("btn_labelledby_mixed_input",
|
|
"input button Submit Query Reset input image");
|
|
|
|
// Gets the name from the title of object element.
|
|
testName("btn_labelledby_mixed_object", "object");
|
|
|
|
// Gets the name from text nodes. Element br adds space between them.
|
|
testName("btn_labelledby_mixed_br", "text text");
|
|
|
|
|
|
//////////////////////////////////////////////////////////////////////////
|
|
// label element
|
|
|
|
// The label element contains the button. The name is calculated from
|
|
// this button.
|
|
// Note: the name contains the content of the button.
|
|
testName("btn_label_inside", "text10text");
|
|
|
|
// The label element and the button are placed in the same form. Gets
|
|
// the name from the label subtree.
|
|
testName("btn_label_inform", "in form");
|
|
|
|
// The label element is placed outside of form where the button is.
|
|
// Do not take into account the label.
|
|
testName("btn_label_outform", "12");
|
|
|
|
// The label element and the button are in the same document. Gets the
|
|
// name from the label subtree.
|
|
testName("btn_label_indocument", "in document");
|
|
|
|
|
|
//////////////////////////////////////////////////////////////////////////
|
|
// name from children
|
|
|
|
// ARIA role button is presented allowing the name calculation from
|
|
// children.
|
|
testName("btn_children", "14");
|
|
|
|
|
|
//////////////////////////////////////////////////////////////////////////
|
|
// title attribute
|
|
|
|
// If nothing is left. Let's try title attribute.
|
|
testName("btn_title", "title");
|
|
|
|
SimpleTest.finish();
|
|
}
|
|
|
|
SimpleTest.waitForExplicitFinish();
|
|
addLoadEvent(doTest);
|
|
</script>
|
|
|
|
</head>
|
|
|
|
<body>
|
|
|
|
<a target="_blank"
|
|
href="https://bugzilla.mozilla.org/show_bug.cgi?id=444279"
|
|
title="mochitest for accessible name calculating">
|
|
Mozilla Bug 444279
|
|
</a>
|
|
<p id="display"></p>
|
|
<div id="content" style="display: none"></div>
|
|
<pre id="test">
|
|
</pre>
|
|
|
|
<!-- aria-labelledby, single relation -->
|
|
<span id="labelledby_text">text</span>
|
|
<button id="btn_labelledby_text"
|
|
aria-labelledby="labelledby_text">1</button>
|
|
<br/>
|
|
|
|
<!-- aria-labelledby, multiple relations -->
|
|
<span id="labelledby_text1">text1</span>
|
|
<span id="labelledby_text2">text2</span>
|
|
<button id="btn_labelledby_texts"
|
|
aria-labelledby="labelledby_text1 labelledby_text2">2</button>
|
|
<br/>
|
|
|
|
<!-- the name from subtree, mixed content -->
|
|
<span id="labelledby_mixed">no<span>more text</span></span>
|
|
<button id="btn_labelledby_mixed"
|
|
aria-labelledby="labelledby_mixed">3</button>
|
|
<br/>
|
|
|
|
<!-- the name from subtree, mixed content, block structure -->
|
|
<div id="labelledby_mixed_block"><div>text</div>more text</div></div>
|
|
<button id="btn_labelledby_mixed_block"
|
|
aria-labelledby="labelledby_mixed_block">4</button>
|
|
<br/>
|
|
|
|
<!-- the name from subtree, mixed content, table structure -->
|
|
<table><tr>
|
|
<td id="labelledby_mixed_table">text<span>space</span>text</td>
|
|
</tr></table>
|
|
<button id="btn_labelledby_mixed_table"
|
|
aria-labelledby="labelledby_mixed_table">5</button>
|
|
<br/>
|
|
|
|
<!-- the name from subtree, child img -->
|
|
<span id="labelledby_mixed_img">text<img alt="image"/></span>
|
|
<button id="btn_labelledby_mixed_img"
|
|
aria-labelledby="labelledby_mixed_img">6</button>
|
|
<br/>
|
|
|
|
<!-- the name from subtree, child inputs -->
|
|
<span id="labelledby_mixed_input">
|
|
<input type="button" id="input_button" title="input button"/>
|
|
<input type="submit" id="input_submit"/>
|
|
<input type="reset" id="input_reset"/>
|
|
<input type="image" id="input_image" title="input image"/>
|
|
</span>
|
|
<button id="btn_labelledby_mixed_input"
|
|
aria-labelledby="labelledby_mixed_input">7</button>
|
|
<br/>
|
|
|
|
<!-- the name from subtree, child object -->
|
|
<span id="labelledby_mixed_object">
|
|
<object data="about:blank" title="object"></object>
|
|
</span>
|
|
<button id="btn_labelledby_mixed_object"
|
|
aria-labelledby="labelledby_mixed_object">8</button>
|
|
<br/>
|
|
|
|
<!-- the name from subtree, child br -->
|
|
<span id="labelledby_mixed_br">text<br/>text</span>
|
|
<button id="btn_labelledby_mixed_br"
|
|
aria-labelledby="labelledby_mixed_br">9</button>
|
|
<br/>
|
|
|
|
<!-- label element, label contains the button -->
|
|
<label>text<button id="btn_label_inside">10</button>text</label>
|
|
<br/>
|
|
|
|
<!-- label element, label and the button are in the same form -->
|
|
<form>
|
|
<label for="btn_label_inform">in form</label>
|
|
<button id="btn_label_inform">11</button>
|
|
</form>
|
|
|
|
<!-- label element, label is outside of the form of the button -->
|
|
<label for="btn_label_outform">out form</label>
|
|
<form>
|
|
<button id="btn_label_outform">12</button>
|
|
</form>
|
|
|
|
<!-- label element, label and the button are in the same document -->
|
|
<label for="btn_label_indocument">in document</label>
|
|
<button id="btn_label_indocument">13</button>
|
|
|
|
<!-- name from children -->
|
|
<span id="btn_children" role="button">14</span>
|
|
|
|
<!-- name from title attribute -->
|
|
<span id="btn_title" role="group" title="title">15</span>
|
|
</body>
|
|
</html>
|