tor-browser

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

attributes.sub.html (2602B)


      1 <!doctype html>
      2 <meta charset={{GET[encoding]}}> <!-- ends up as <meta charset> by default which is windows-1252 -->
      3 <meta name=variant content="?encoding=windows-1252">
      4 <meta name=variant content="?encoding=x-cp1251">
      5 <meta name=variant content="?encoding=utf8">
      6 <script src=/resources/testharness.js></script>
      7 <script src=/resources/testharnessreport.js></script>
      8 <link rel=help href=https://html.spec.whatwg.org/multipage/rendering.html#the-page>
      9 <link rel=help href=https://html.spec.whatwg.org/multipage/rendering.html#tables-2>
     10 <link rel=help href=https://html.spec.whatwg.org/multipage/#reflecting-content-attributes-in-idl-attributes>
     11 <div id=log></div>
     12 <script>
     13 function expected(encoding) {
     14  return "?" + {
     15    "UTF-8": "%C3%BF",
     16    "windows-1251": "%26%23255%3B",
     17    "windows-1252": "%FF"
     18  }[encoding];
     19 }
     20 
     21 function assert_ends_with(input, endsWith) {
     22  assert_true(input.endsWith(endsWith), input + " did not end with " + endsWith);
     23 }
     24 
     25 "body table thead tbody tfoot tr td th".split(" ").forEach(localName => {
     26  test(t => {
     27    const elm = document.createElement(localName);
     28    document.body.appendChild(elm);
     29    t.add_cleanup(() => { document.body.removeChild(elm); });
     30    elm.setAttribute("background", "?\u00FF");
     31    assert_ends_with(getComputedStyle(elm).backgroundImage, expected(document.characterSet) + "\")");
     32  }, "getComputedStyle <" + localName + " background>");
     33 });
     34 
     35 function test_url_reflecting(localName, attr, idlAttr) {
     36  idlAttr = idlAttr || attr;
     37  test(() => {
     38    let input = "?\u00FF";
     39    const elm = document.createElement(localName);
     40    assert_true(idlAttr in elm, idlAttr + " is not supported");
     41    elm.setAttribute(attr, input);
     42    assert_ends_with(elm[idlAttr], expected(document.characterSet));
     43  }, "Getting <" + localName + ">." + idlAttr);
     44 }
     45 
     46 ("iframe src, a href, area href, base href, link href, img src, embed src, object data, " +
     47 "track src, video src, audio src, input src, form action, input formaction formAction, " +
     48 "button formaction formAction, script src").split(", ").forEach(str => {
     49  const arr = str.split(" ");
     50  test_url_reflecting(arr[0], arr[1], arr[2]);
     51 });
     52 
     53 function test_string_reflecting(localName, attr) {
     54  test(() => {
     55    let input = "?\u00FF ?\u00FF";
     56    const elm = document.createElement(localName);
     57    assert_true(attr in elm, attr + " is not supported");
     58    elm.setAttribute(attr, input);
     59    assert_equals(elm[attr], input);
     60  }, "Getting <" + localName + ">." + attr);
     61 }
     62 
     63 "a ping, area ping".split(", ").forEach(str => {
     64  const arr = str.split(" ");
     65  test_string_reflecting(arr[0], arr[1]);
     66 });
     67 </script>