blob: a9e6a4146ec0e2f42aea80b5bfefd4167f0b1136 [file] [log] [blame]
<!DOCTYPE html>
<html>
<head>
<script src="../resources/testharness.js"></script>
<script src="../resources/testharnessreport.js"></script>
<!-- The second language in the meta tag should be ignored. -->
<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');
});
async_test((t) => {
assert_equals(window.axBody.language, 'AXLanguage: en',
'The meta tag has not been changed yet.');
let meta = document.querySelector('meta[http-equiv="content-language"]');
assert_not_equals(meta, undefined);
meta.content = 'fr';
assert_equals(window.axBody.language, 'AXLanguage: fr',
'The contents of the meta tag have changed.');
assert_equals(window.axParagraph.language, 'AXLanguage: pl',
'The lang attribute should take priority over the meta tag.');
assert_equals(window.axSpan.language, 'AXLanguage: pl',
'The lang attribute should take priority over the meta tag.');
meta.remove();
let newMeta = document.createElement('meta');
newMeta.httpEquiv = 'content-language';
newMeta.content = 'ja';
document.head.appendChild(newMeta);
t.step_timeout(() => {
assert_equals(window.axBody.language, 'AXLanguage: ja',
'The whole of the meta tag has been replaced.');
assert_equals(window.axParagraph.language, 'AXLanguage: pl',
'The lang attribute should take priority over the meta tag.');
assert_equals(window.axSpan.language, 'AXLanguage: pl',
'The lang attribute should take priority over the meta tag.');
newMeta.remove();
meta.content = 'en';
document.head.appendChild(meta);
t.done();
}, 0);
}, 'Tests if dynamically changing the content-language meta tag is picked up by the accessibility component.');
</script>
</body>
</html>