test_docl10n_ready_rejected.html (1147B)
1 <!DOCTYPE HTML> 2 <html> 3 <head> 4 <meta charset="utf-8"> 5 <title>Test mozIDOMLocalization.ready rejected state</title> 6 <script src="chrome://mochikit/content/tests/SimpleTest/SimpleTest.js"></script> 7 <link rel="stylesheet" type="text/css" href="chrome://mochikit/content/tests/SimpleTest/test.css"> 8 <link rel="localization" href="path/to_non_existing.ftl"/> 9 <script type="application/javascript"> 10 "use strict"; 11 SimpleTest.waitForExplicitFinish(); 12 13 document.addEventListener("DOMContentLoaded", async function() { 14 /** 15 * Outside of tests, even when we fail to localize all elements, 16 * we will still resolve the `ready` promise to communicate that 17 * the initial translation phase is now completed. 18 * 19 * In tests, the promise will be rejected to allow errors to be caught. 20 */ 21 document.l10n.ready.then(() => { 22 is(1, 2, "the ready should not resolve"); 23 SimpleTest.finish(); 24 }, (_err) => { 25 is(1, 1, "the ready should reject"); 26 SimpleTest.finish(); 27 }); 28 }); 29 </script> 30 </head> 31 <body> 32 <h1 data-l10n-id="non-existing-id"></h1> 33 </body> 34 </html>