Bug 1430697 - Fix tests regression introduced in e140335f1237. r=gandalf

MozReview-Commit-ID: HBXb2ECaTF9

--HG--
rename : intl/l10n/test/dom/test_domloc_translateElement.html => intl/l10n/test/dom/test_domloc_translateElements.html
extra : rebase_source : b909c575f90c032a179478457361dc1075114523
This commit is contained in:
Zibi Braniecki 2018-01-15 18:35:40 -08:00
parent 52132f44ef
commit 48af78525e
4 changed files with 22 additions and 5 deletions

View File

@ -504,6 +504,23 @@ class DOMLocalization extends Localization {
* Translate a DOM element or fragment asynchronously using this
* `DOMLocalization` object.
*
* Manually trigger the translation (or re-translation) of a DOM fragment.
* Use the `data-l10n-id` and `data-l10n-args` attributes to mark up the DOM
* with information about which translations to use.
*
* Returns a `Promise` that gets resolved once the translation is complete.
*
* @param {DOMFragment} frag - Element or DocumentFragment to be translated
* @returns {Promise}
*/
translateFragment(frag) {
return this.translateElements(this.getTranslatables(frag));
}
/**
* Translate a list of DOM elements asynchronously using this
* `DOMLocalization` object.
*
* Manually trigger the translation (or re-translation) of a list of elements.
* Use the `data-l10n-id` and `data-l10n-args` attributes to mark up the DOM
* with information about which translations to use.

View File

@ -1,6 +1,6 @@
[dom/test_domloc_getAttributes.html]
[dom/test_domloc_setAttributes.html]
[dom/test_domloc_translateElement.html]
[dom/test_domloc_translateElements.html]
[dom/test_domloc_translateFragment.html]
[dom/test_domloc_connectRoot.html]
[dom/test_domloc_disconnectRoot.html]

View File

@ -2,7 +2,7 @@
<html>
<head>
<meta charset="utf-8">
<title>Test DOMLocalization.prototype.translateElement</title>
<title>Test DOMLocalization.prototype.translateElements</title>
<script type="application/javascript" src="chrome://mochikit/content/tests/SimpleTest/SimpleTest.js"></script>
<link rel="stylesheet" type="text/css" href="chrome://mochikit/content/tests/SimpleTest/test.css">
<script type="application/javascript">
@ -31,10 +31,9 @@
const p1 = document.querySelectorAll('p')[0];
const link1 = document.querySelectorAll('a')[0];
await domLoc.translateElement(p1);
is(p1.textContent, "Hello World");
await domLoc.translateElements([p1, link1]);
await domLoc.translateElement(link1);
is(p1.textContent, "Hello World");
is(link1.getAttribute('title'), "Click me");
SimpleTest.finish();

View File

@ -7,6 +7,7 @@ const { DOMLocalization } =
add_task(function test_methods_presence() {
equal(typeof DOMLocalization.prototype.getAttributes, "function");
equal(typeof DOMLocalization.prototype.setAttributes, "function");
equal(typeof DOMLocalization.prototype.translateFragment, "function");
equal(typeof DOMLocalization.prototype.translateElements, "function");
equal(typeof DOMLocalization.prototype.connectRoot, "function");
equal(typeof DOMLocalization.prototype.disconnectRoot, "function");