blob: 3e3ba91d4ccb212fe738e0bbef04df733ab969dc [file] [log] [blame]
<!DOCTYPE html>
<html>
<head>
<script src="../resources/testharness.js"></script>
<script src="../resources/testharnessreport.js"></script>
<meta http-equiv="content-language" content="en, es">
</head>
<body id="body" role="main">
<p id="paragraph" lang="pl">Polish.
<span id="span">Possibly in another language.</span>
</p>
<script>
setup(() => {
window.axBody = accessibilityController.accessibleElementById('body');
window.axParagraph = accessibilityController.accessibleElementById('paragraph');
window.axSpan = accessibilityController.accessibleElementById('span');
});
test(() => {
assert_equals(window.axBody.language, 'AXLanguage: en',
'The first language in the meta tag should apply.');
assert_equals(window.axParagraph.language, 'AXLanguage: pl',
'The language in the lang attribute should apply.');
assert_equals(window.axSpan.language, 'AXLanguage: pl',
'The language in the lang attribute is inherited.');
}, 'Tests if the content-language meta tag and the lang attribute are picked up by the accessibility component.');
test(() => {
assert_equals(window.axBody.language, 'AXLanguage: en',
'The lang attribute has not been changed yet.');
document.documentElement.lang = 'ru';
assert_equals(window.axBody.language, 'AXLanguage: ru',
'The lang attribute on the html element has changed.');
assert_equals(window.axParagraph.language, 'AXLanguage: pl',
'The lang attribute on the html element should not affect the lang attribute on the paragraph.');
assert_equals(window.axSpan.language, 'AXLanguage: pl',
'The lang attribute on the html element should not affect the lang attribute on the span.');
document.documentElement.lang = '';
document.getElementById('paragraph').lang = 'it';
assert_equals(window.axParagraph.language, 'AXLanguage: it',
'The lang attribute on the paragraph has changed.');
assert_equals(window.axSpan.language, 'AXLanguage: it',
'The lang attribute on the paragraph has changed.');
document.getElementById('paragraph').lang = 'pl';
document.getElementById('span').lang = 'es';
assert_equals(window.axSpan.language, 'AXLanguage: es',
'The lang attribute on the span has changed.');
document.getElementById('span').lang = '';
}, 'Tests if dynamically changing lang attributes is picked up by the accessibility component.');
</script>
</body>
</html>