tor-browser

The Tor Browser
git clone https://git.dasho.dev/tor-browser.git
Log | Files | Refs | README | LICENSE

test_docl10n_removeResourceIds.html (1872B)


      1 <!DOCTYPE HTML>
      2 <html>
      3 <head>
      4  <meta charset="utf-8">
      5  <title>Test DocumentL10n::RemoveResourceIds</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="toolkit/about/aboutAddons.ftl"/>
      9  <link rel="localization" href="toolkit/about/aboutSupport.ftl"/>
     10  <script type="application/javascript">
     11  "use strict";
     12  /* eslint-disable mozilla/prefer-formatValues */
     13 
     14  SimpleTest.waitForExplicitFinish();
     15 
     16  window.onload = async function() {
     17    {
     18      // 1. An example message from aboutAddons should be available.
     19      let value = await document.l10n.formatValue("shortcuts-browserAction2");
     20      is(!!value.length, true, "localized value retrieved");
     21    }
     22 
     23    {
     24      // 2. Remove aboutAddons.ftl
     25      let link = document.head.querySelector("link[href*=aboutAddons]");
     26      document.head.removeChild(link);
     27    }
     28 
     29    {
     30      // 3. An example message from aboutSupport should still be available.
     31      let value = await document.l10n.formatValue("support-addons-version");
     32      is(!!value.length, true, "localized value retrieved");
     33 
     34      // 4. An example message from aboutAddons should not be available.
     35      await document.l10n.formatValue("shortcuts-browserAction").then(
     36      () => {
     37        ok(false, "localization should not be available");
     38      },
     39      () => {
     40        ok(true, "localization should not be available");
     41      });
     42    }
     43 
     44    {
     45      // 5. Remove aboutSupport.ftl
     46      let link = document.head.querySelector("link[href*=aboutSupport]");
     47      document.head.removeChild(link);
     48 
     49      // 6. document.l10n should be null.
     50      is(document.l10n, null, "document.l10n should be null");
     51 
     52      SimpleTest.finish();
     53    }
     54  };
     55  </script>
     56 </head>
     57 <body>
     58 </body>
     59 </html>