/* Any copyright is dedicated to the Public Domain.
http://creativecommons.org/publicdomain/zero/1.0/ */
"use strict";
/**
* Request 2x longer timeout for this test.
* There are lot of test cases in this file, but they are all of the same nature,
* and it makes the most sense to have them all in this single test file.
*/
requestLongerTimeout(2);
add_task(
async function test_direction_ltr_to_rtl_basic_content_not_attributes() {
const { translate, htmlMatches, cleanup } = await createTranslationsDoc(
/* html */ `
This block of content should get RTL direction.
Div text.
Span within a div.
Span text.
Div within a span.
`,
{ sourceLanguage: "en", targetLanguage: "ar" }
);
translate();
await htmlMatches(
'LTR to RTL (basic): content elements get dir="rtl", but attribute-only elements do not.',
/* html */ `
THIS BLOCK OF CONTENT SHOULD GET RTL DIRECTION.
DIV TEXT.
SPAN WITHIN A DIV.
SPAN TEXT.
DIV WITHIN A SPAN.
`
);
cleanup();
}
);
add_task(async function test_direction_ltr_to_rtl_lists_ul_basic() {
const { translate, htmlMatches, cleanup } = await createTranslationsDoc(
/* html */ `
Span within list item.
Span inside list item.
Div within list item.
Div inside list item.
`,
{ sourceLanguage: "en", targetLanguage: "ar" }
);
translate();
await htmlMatches(
"LTR to RTL (UL basic): and with simple nested inline/block content.",
/* html */ `
SPAN WITHIN LIST ITEM.
SPAN INSIDE LIST ITEM.
DIV WITHIN LIST ITEM.
DIV INSIDE LIST ITEM.
`
);
cleanup();
});
add_task(async function test_direction_ltr_to_rtl_lists_ul_nested_combos() {
const { translate, htmlMatches, cleanup } = await createTranslationsDoc(
/* html */ `
Div within span within list item.
Div inside span inside list item.
`,
{ sourceLanguage: "en", targetLanguage: "ar" }
);
translate();
await htmlMatches(
"LTR to RTL (UL nested combos): nested inline/block permutations.",
/* html */ `
DIV WITHIN SPAN WITHIN LIST ITEM.
DIV INSIDE SPAN INSIDE LIST ITEM.
`
);
cleanup();
});
add_task(async function test_direction_ltr_to_rtl_lists_ol_basic() {
const { translate, htmlMatches, cleanup } = await createTranslationsDoc(
/* html */ `
List item.
Span within list item.
Span inside list item.
Div within list item.
Div inside list item.
`,
{ sourceLanguage: "en", targetLanguage: "ar" }
);
translate();
await htmlMatches(
"LTR to RTL (OL basic): and with simple nested inline/block content.",
/* html */ `
LIST ITEM.
SPAN WITHIN LIST ITEM.
SPAN INSIDE LIST ITEM.
DIV WITHIN LIST ITEM.
DIV INSIDE LIST ITEM.
`
);
cleanup();
});
add_task(async function test_direction_ltr_to_rtl_lists_ol_nested_combos() {
const { translate, htmlMatches, cleanup } = await createTranslationsDoc(
/* html */ `
Span within div within list item.
Span inside div inside list item.
Div within span within list item.
Div inside span inside list item.
`,
{ sourceLanguage: "en", targetLanguage: "ar" }
);
translate();
await htmlMatches(
"LTR to RTL (OL nested combos): nested inline/block permutations.",
/* html */ `
SPAN WITHIN DIV WITHIN LIST ITEM.
SPAN INSIDE DIV INSIDE LIST ITEM.
DIV WITHIN SPAN WITHIN LIST ITEM.
DIV INSIDE SPAN INSIDE LIST ITEM.
`
);
cleanup();
});
add_task(
async function test_direction_rtl_to_ltr_basic_content_not_attributes() {
const { translate, htmlMatches, cleanup } = await createTranslationsDoc(
/* html */ `
This block of content should get LTR direction.
Div text.
Span within a div.
Span text.
Div within a span.
`,
{ sourceLanguage: "ar", targetLanguage: "en" }
);
translate();
await htmlMatches(
'RTL to LTR (basic): content elements get dir="ltr", but attribute-only elements do not.',
/* html */ `
THIS BLOCK OF CONTENT SHOULD GET LTR DIRECTION.
DIV TEXT.
SPAN WITHIN A DIV.
SPAN TEXT.
DIV WITHIN A SPAN.
`
);
cleanup();
}
);
add_task(async function test_direction_rtl_to_ltr_lists_ul_basic() {
const { translate, htmlMatches, cleanup } = await createTranslationsDoc(
/* html */ `
Span within list item.
Span inside list item.
Div within list item.
Div inside list item.
`,
{ sourceLanguage: "ar", targetLanguage: "en" }
);
translate();
await htmlMatches(
"RTL to LTR (UL basic): and with simple nested inline/block content.",
/* html */ `
SPAN WITHIN LIST ITEM.
SPAN INSIDE LIST ITEM.
DIV WITHIN LIST ITEM.
DIV INSIDE LIST ITEM.
`
);
cleanup();
});
add_task(async function test_direction_rtl_to_ltr_lists_ul_nested_combos() {
const { translate, htmlMatches, cleanup } = await createTranslationsDoc(
/* html */ `
Div within span within list item.
Div inside span inside list item.
`,
{ sourceLanguage: "ar", targetLanguage: "en" }
);
translate();
await htmlMatches(
"RTL to LTR (UL nested combos): nested inline/block permutations.",
/* html */ `
DIV WITHIN SPAN WITHIN LIST ITEM.
DIV INSIDE SPAN INSIDE LIST ITEM.
`
);
cleanup();
});
add_task(async function test_direction_rtl_to_ltr_lists_ol_basic() {
const { translate, htmlMatches, cleanup } = await createTranslationsDoc(
/* html */ `
List item.
Span within list item.
Span inside list item.
Div within list item.
Div inside list item.
`,
{ sourceLanguage: "ar", targetLanguage: "en" }
);
translate();
await htmlMatches(
"RTL to LTR (OL basic): and with simple nested inline/block content.",
/* html */ `
LIST ITEM.
SPAN WITHIN LIST ITEM.
SPAN INSIDE LIST ITEM.
DIV WITHIN LIST ITEM.
DIV INSIDE LIST ITEM.
`
);
cleanup();
});
add_task(async function test_direction_rtl_to_ltr_lists_ol_nested_combos() {
const { translate, htmlMatches, cleanup } = await createTranslationsDoc(
/* html */ `
Span within div within list item.
Span inside div inside list item.
Div within span within list item.
Div inside span inside list item.
`,
{ sourceLanguage: "ar", targetLanguage: "en" }
);
translate();
await htmlMatches(
"RTL to LTR (OL nested combos): nested inline/block permutations.",
/* html */ `
SPAN WITHIN DIV WITHIN LIST ITEM.
SPAN INSIDE DIV INSIDE LIST ITEM.
DIV WITHIN SPAN WITHIN LIST ITEM.
DIV INSIDE SPAN INSIDE LIST ITEM.
`
);
cleanup();
});
add_task(async function test_direction_ltr_to_rtl_tables_basic() {
const { translate, htmlMatches, cleanup } = await createTranslationsDoc(
/* html */ `
Span within cell.
Span inside cell.
Div within cell.
Div inside cell.
`,
{ sourceLanguage: "en", targetLanguage: "ar" }
);
translate();
await htmlMatches(
"LTR to RTL (TABLE basic): and / with simple nested inline/block content.",
/* html */ `
SPAN WITHIN CELL.
SPAN INSIDE CELL.
DIV WITHIN CELL.
DIV INSIDE CELL.
`
);
cleanup();
});
add_task(async function test_direction_ltr_to_rtl_tables_nested_combos() {
const { translate, htmlMatches, cleanup } = await createTranslationsDoc(
/* html */ `
Span within div within cell.
Span inside div inside cell.
Div within span within cell.
Div inside span inside cell.
`,
{ sourceLanguage: "en", targetLanguage: "ar" }
);
translate();
await htmlMatches(
"LTR to RTL (TABLE nested combos): nested inline/block permutations.",
/* html */ `
SPAN WITHIN DIV WITHIN CELL.
SPAN INSIDE DIV INSIDE CELL.
DIV WITHIN SPAN WITHIN CELL.
DIV INSIDE SPAN INSIDE CELL.
`
);
cleanup();
});
add_task(async function test_direction_rtl_to_ltr_tables_basic() {
const { translate, htmlMatches, cleanup } = await createTranslationsDoc(
/* html */ `
Span within cell.
Span inside cell.
Div within cell.
Div inside cell.
`,
{ sourceLanguage: "ar", targetLanguage: "en" }
);
translate();
await htmlMatches(
"RTL to LTR (TABLE basic): and / with simple nested inline/block content.",
/* html */ `
SPAN WITHIN CELL.
SPAN INSIDE CELL.
DIV WITHIN CELL.
DIV INSIDE CELL.
`
);
cleanup();
});
add_task(async function test_direction_rtl_to_ltr_tables_nested_combos() {
const { translate, htmlMatches, cleanup } = await createTranslationsDoc(
/* html */ `
Span within div within cell.
Span inside div inside cell.
Div within span within cell.
Div inside span inside cell.
`,
{ sourceLanguage: "ar", targetLanguage: "en" }
);
translate();
await htmlMatches(
"RTL to LTR (TABLE nested combos): nested inline/block permutations.",
/* html */ `
SPAN WITHIN DIV WITHIN CELL.
SPAN INSIDE DIV INSIDE CELL.
DIV WITHIN SPAN WITHIN CELL.
DIV INSIDE SPAN INSIDE CELL.
`
);
cleanup();
});