tor-browser

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

test_notification_box_04.html (2111B)


      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 * Adding a mdnLink to a notification
      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    // Render notification
     31    const boxElement = React.createElement(NotificationBox);
     32    const notificationBox = TestUtils.renderIntoDocument(boxElement);
     33    const notificationNode = ReactDOM.findDOMNode(notificationBox);
     34 
     35    const mdnLink = "https://developer.mozilla.org/en-US/docs/Web/HTTP/Guides/CORS/Errors"
     36 
     37    const mdnLinkButton = {mdnUrl: mdnLink, label: "learn more about error" }
     38 
     39    // Append a notification with a learn-more link
     40    notificationBox.appendNotification(
     41      "Info message",
     42      "id1",
     43      null,
     44      PriorityLevels.PRIORITY_INFO_LOW,
     45      [mdnLinkButton],
     46      () => false,
     47    );
     48 
     49    const linkNode = notificationNode.querySelector(
     50      "a.learn-more-link");
     51 
     52    ok(linkNode, "Link is present");
     53 
     54    is(linkNode.title, "learn more about error", "link has correct title");
     55    ok(linkNode.classList.contains("devtools-button"), "link has correct class")
     56 
     57 
     58  } catch(e) {
     59    ok(false, "Got an error: " + DevToolsUtils.safeErrorString(e));
     60  } finally {
     61    SimpleTest.finish();
     62  }
     63 };
     64 </script>
     65 </pre>
     66 </body>
     67 </html>