tor-browser

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

test_sidebar_toggle.html (1763B)


      1 <!-- This Source Code Form is subject to the terms of the Mozilla Public
      2   - License, v. 2.0. If a copy of the MPL was not distributed with this
      3   - file, You can obtain one at http://mozilla.org/MPL/2.0/. -->
      4 <!DOCTYPE HTML>
      5 <html>
      6 <!--
      7 Test sidebar toggle button
      8 -->
      9 <head>
     10  <meta charset="utf-8">
     11  <title>Sidebar toggle button test</title>
     12  <script src="chrome://mochikit/content/tests/SimpleTest/SimpleTest.js"></script>
     13  <link rel="stylesheet" type="text/css" href="chrome://mochikit/content/tests/SimpleTest/test.css">
     14 </head>
     15 <body>
     16 <pre id="test">
     17 <script src="head.js" type="application/javascript"></script>
     18 <script type="application/javascript">
     19 
     20 'use strict'
     21 
     22 window.onload = async function () {
     23  const SidebarToggle = React.createFactory(browserRequire("devtools/client/shared/components/SidebarToggle.js"));
     24 
     25  try {
     26    await test();
     27  } catch(e) {
     28    ok(false, "Got an error: " + DevToolsUtils.safeErrorString(e));
     29  } finally {
     30    SimpleTest.finish();
     31  }
     32 
     33  async function test() {
     34    const { element: output1 } = await createComponentTest(SidebarToggle, {
     35      collapsed: false,
     36      collapsePaneTitle: "Expand",
     37      expandPaneTitle: "Collapse"
     38    });
     39 
     40    is(output1.tagName, "BUTTON", "Output is a button element");
     41    is(output1.title, "Expand", "Proper title is set");
     42    is(output1.className.indexOf("pane-collapsed"), -1,
     43      "Proper class name is set");
     44 
     45    const { element: output2 } = await createComponentTest(SidebarToggle, {
     46      collapsed: true,
     47      collapsePaneTitle: "Expand",
     48      expandPaneTitle: "Collapse"
     49    });
     50 
     51    is(output2.title, "Collapse", "Proper title is set");
     52    ok(output2.className.includes("pane-collapsed"),
     53      "Proper class name is set");
     54  }
     55 };
     56 </script>
     57 </pre>
     58 </body>
     59 </html>