tor-browser

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

browser_aboutNetError_server_error.js (1410B)


      1 /* Any copyright is dedicated to the Public Domain.
      2 * http://creativecommons.org/publicdomain/zero/1.0/ */
      3 
      4 "use strict";
      5 
      6 const SERVER_ERROR_PAGE =
      7  "https://example.com/browser/browser/base/content/test/about/server_error.sjs";
      8 
      9 add_task(async function test_serverError() {
     10  let browser;
     11  let pageLoaded;
     12  await BrowserTestUtils.openNewForegroundTab(
     13    gBrowser,
     14    () => {
     15      gBrowser.selectedTab = BrowserTestUtils.addTab(
     16        gBrowser,
     17        SERVER_ERROR_PAGE
     18      );
     19      browser = gBrowser.selectedBrowser;
     20      pageLoaded = BrowserTestUtils.waitForErrorPage(browser);
     21    },
     22    false
     23  );
     24 
     25  info("Loading and waiting for the net error");
     26  await pageLoaded;
     27 
     28  await SpecialPowers.spawn(browser, [], function () {
     29    const doc = content.document;
     30    ok(
     31      doc.documentURI.startsWith("about:neterror"),
     32      "Should be showing error page"
     33    );
     34 
     35    const titleEl = doc.querySelector(".title-text");
     36    const actualDataL10nID = titleEl.getAttribute("data-l10n-id");
     37    is(
     38      actualDataL10nID,
     39      "serverError-title",
     40      "Correct error page title is set"
     41    );
     42    const responseStatusLabel = doc.getElementById(
     43      "response-status-label"
     44    ).textContent;
     45    is(
     46      responseStatusLabel,
     47      "Error code: 500 Internal Server Error",
     48      "Correct response status message is set"
     49    );
     50  });
     51 
     52  BrowserTestUtils.removeTab(gBrowser.selectedTab);
     53 });