tor-browser

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

domparser-spurious-attributes.html (1250B)


      1 <!DOCTYPE html>
      2 <meta charset="utf-8">
      3 <title>Spurious attributes in DOMParser</title>
      4 <link rel="help" href="https://crbug.com/435995566">
      5 <script src="/resources/testharness.js"></script>
      6 <script src="/resources/testharnessreport.js"></script>
      7 <body>
      8 <script>
      9 test(() => {
     10  const html = `<div title="this-should-not-be-an-attribute=1>&quot;hello"></div>`;
     11  const doc = new DOMParser().parseFromString(html, "text/html");
     12  const div = doc.querySelector("div");
     13 
     14  assert_false(div.hasAttribute("this-should-not-be-an-attribute"));
     15  assert_equals(div.getAttribute("title"), 'this-should-not-be-an-attribute=1>"hello');
     16 }, 'Using ">" and HTML entities in an attribute creates no unexpected attributes.');
     17 
     18 test(() => {
     19  const html = `<div title="this-should-not-be-an-attribute=1>\rhello"></div>`;
     20  const doc = new DOMParser().parseFromString(html, "text/html");
     21  const div = doc.querySelector("div");
     22 
     23  assert_false(div.hasAttribute("this-should-not-be-an-attribute"));
     24  // Note: "\r" gets normalized to "\n" per https://infra.spec.whatwg.org/#normalize-newlines.
     25  assert_equals(div.getAttribute("title"), 'this-should-not-be-an-attribute=1>\nhello');
     26 }, 'Using ">" and "\\r" in an attribute creates no unexpected attributes.');
     27 
     28 </script>