tor-browser

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

test_notification_box_05.html (1887B)


      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 for Notification Box. The test is checking:
      8 * the close button is not present when displayCloseButton is false
      9 -->
     10 <head>
     11  <meta charset="utf-8">
     12  <title>Notification Box</title>
     13  <script src="chrome://mochikit/content/tests/SimpleTest/SimpleTest.js"></script>
     14  <link rel="stylesheet" type="text/css" href="chrome://mochikit/content/tests/SimpleTest/test.css">
     15 </head>
     16 <body>
     17 <pre id="test">
     18 <script src="head.js" type="application/javascript"></script>
     19 <script type="application/javascript">
     20 
     21 'use strict'
     22 
     23 
     24 window.onload = async function () {
     25  try {
     26    const ReactDOM = browserRequire("devtools/client/shared/vendor/react-dom");
     27    const React = browserRequire("devtools/client/shared/vendor/react");
     28    const { NotificationBox, PriorityLevels } = browserRequire("devtools/client/shared/components/NotificationBox");
     29 
     30    // Test rendering with close button disabled
     31    const boxElement = React.createElement(NotificationBox, {displayCloseButton: false});
     32    const notificationBox = TestUtils.renderIntoDocument(boxElement);
     33    const notificationNode = ReactDOM.findDOMNode(notificationBox);
     34 
     35 
     36 
     37    // Append a notification.
     38    notificationBox.appendNotification(
     39      "Info message",
     40      "id1",
     41      null,
     42      PriorityLevels.PRIORITY_INFO_LOW,
     43      [],
     44      () => false,
     45    );
     46 
     47    // Ensure close button is not present
     48    const linkNode = notificationNode.querySelector(
     49      ".messageCloseButton");
     50 
     51    ok(!linkNode, "Close button is not present");
     52 
     53  } catch(e) {
     54    ok(false, "Got an error: " + DevToolsUtils.safeErrorString(e));
     55  } finally {
     56    SimpleTest.finish();
     57  }
     58 };
     59 </script>
     60 </pre>
     61 </body>
     62 </html>