tor-browser

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

browser_rules_urls-clickable.js (2766B)


      1 /* Any copyright is dedicated to the Public Domain.
      2 http://creativecommons.org/publicdomain/zero/1.0/ */
      3 
      4 "use strict";
      5 
      6 // Tests to make sure that URLs are clickable in the rule view
      7 
      8 const TEST_URI = URL_ROOT_SSL + "doc_urls_clickable.html";
      9 const TEST_IMAGE = URL_ROOT_SSL + "doc_test_image.png";
     10 const BASE_64_URL =
     11  "data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAAUAAAA" +
     12  "FCAYAAACNbyblAAAAHElEQVQI12P4//8/w38GIAXDIBKE0DHxgljNBAAO9TXL0Y4OHwAAAA" +
     13  "BJRU5ErkJggg==";
     14 
     15 add_task(async function () {
     16  await addTab(TEST_URI);
     17  const { inspector, view } = await openRuleView();
     18  await selectNodes(inspector, view);
     19 });
     20 
     21 async function selectNodes(inspector, ruleView) {
     22  const relative1 = ".relative1";
     23  const relative2 = ".relative2";
     24  const absolute = ".absolute";
     25  const inline = ".inline";
     26  const base64 = ".base64";
     27  const noimage = ".noimage";
     28  const inlineresolved = ".inline-resolved";
     29 
     30  await selectNode(relative1, inspector);
     31  let relativeLink = ruleView.styleDocument.querySelector(
     32    ".ruleview-propertyvaluecontainer a"
     33  );
     34  ok(relativeLink, "Link exists for relative1 node");
     35  is(relativeLink.getAttribute("href"), TEST_IMAGE, "href matches");
     36 
     37  await selectNode(relative2, inspector);
     38  relativeLink = ruleView.styleDocument.querySelector(
     39    ".ruleview-propertyvaluecontainer a"
     40  );
     41  ok(relativeLink, "Link exists for relative2 node");
     42  is(relativeLink.getAttribute("href"), TEST_IMAGE, "href matches");
     43 
     44  await selectNode(absolute, inspector);
     45  const absoluteLink = ruleView.styleDocument.querySelector(
     46    ".ruleview-propertyvaluecontainer a"
     47  );
     48  ok(absoluteLink, "Link exists for absolute node");
     49  is(absoluteLink.getAttribute("href"), TEST_IMAGE, "href matches");
     50 
     51  await selectNode(inline, inspector);
     52  const inlineLink = ruleView.styleDocument.querySelector(
     53    ".ruleview-propertyvaluecontainer a"
     54  );
     55  ok(inlineLink, "Link exists for inline node");
     56  is(inlineLink.getAttribute("href"), TEST_IMAGE, "href matches");
     57 
     58  await selectNode(base64, inspector);
     59  const base64Link = ruleView.styleDocument.querySelector(
     60    ".ruleview-propertyvaluecontainer a"
     61  );
     62  ok(base64Link, "Link exists for base64 node");
     63  is(base64Link.getAttribute("href"), BASE_64_URL, "href matches");
     64 
     65  await selectNode(inlineresolved, inspector);
     66  const inlineResolvedLink = ruleView.styleDocument.querySelector(
     67    ".ruleview-propertyvaluecontainer a"
     68  );
     69  ok(inlineResolvedLink, "Link exists for style tag node");
     70  is(inlineResolvedLink.getAttribute("href"), TEST_IMAGE, "href matches");
     71 
     72  await selectNode(noimage, inspector);
     73  const noimageLink = ruleView.styleDocument.querySelector(
     74    ".ruleview-propertyvaluecontainer a"
     75  );
     76  ok(!noimageLink, "There is no link for the node with no background image");
     77 }