tor-browser

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

test_bug607145.html (2755B)


      1 <!DOCTYPE HTML>
      2 <html>
      3 <!--
      4 https://bugzilla.mozilla.org/show_bug.cgi?id=607145
      5 -->
      6 <head>
      7  <title>Test for Bug 607145</title>
      8  <script src="/tests/SimpleTest/SimpleTest.js"></script>
      9  <link rel="stylesheet" type="text/css" href="/tests/SimpleTest/test.css"/>
     10 </head>
     11 <body>
     12 <a target="_blank" href="https://bugzilla.mozilla.org/show_bug.cgi?id=607145">Mozilla Bug 607145</a>
     13 <p id="display"></p>
     14 <pre id="test">
     15 <script type="application/javascript">
     16 
     17 var xoriginParams;
     18 /** Test for Bug 607145 */
     19 
     20 /**
     21 * This is not really reflecting an URL as the HTML5 specs want to.
     22 * It's how .action is reflected in Gecko (might change later).
     23 *
     24 * If this changes, add reflectURL for "formAction" in
     25 * dom/html/test/forms/test_input_attributes_reflection.html and
     26 * "action" in
     27 * dom/html/test/forms/test_form_attributes_reflection.html
     28 */
     29 function reflectURL(aElement, aAttr)
     30 {
     31  var idl = aAttr;
     32  var attr = aAttr.toLowerCase();
     33  var elmtName = aElement.tagName.toLowerCase();
     34 
     35  var url = location.href.replace(/\?.*/, "");
     36  var dir = url.replace(/test_bug607145.html[^\/]*$/, "");
     37  var parentDir = dir.replace(/test\/$/, "");
     38  ok(idl in aElement, idl + " should be available in " + elmtName);
     39 
     40  // Default values.
     41  is(aElement[idl].split("?")[0], url, "." + idl + " default value should be the document's URL");
     42  is(aElement.getAttribute(attr), null,
     43     "@" + attr + " default value should be null");
     44 
     45  var values = [
     46    /* value to set, resolved value */
     47    [ "foo.html", dir + "foo.html" ],
     48    [ "data:text/html,<html></html>", "data:text/html,<html></html>" ],
     49    [ "http://example.org/", "http://example.org/" ],
     50    [ "//example.org/", "http://example.org/" ],
     51    [ "?foo=bar", url + "?foo=bar" ],
     52    [ "#foo", url + "#foo" ],
     53    [ "", url ],
     54    [ " ", url ],
     55    [ "../", parentDir ],
     56    [ "...", dir + "..." ],
     57    // invalid URL
     58    [ "http://a b/", "http://a b/" ], // TODO: doesn't follow the specs, should be "".
     59  ];
     60 
     61  for (var value of values) {
     62    aElement[idl] = value[0];
     63    is(aElement[idl].replace(xoriginParams, ""), value[1], "." + idl + " value should be " + value[1]);
     64    is(aElement.getAttribute(attr), value[0],
     65       "@" + attr + " value should be " + value[0]);
     66  }
     67 
     68  for (var value of values) {
     69    aElement.setAttribute(attr, value[0]);
     70    is(aElement[idl].replace(xoriginParams, ""), value[1], "." + idl + " value should be " + value[1]);
     71    is(aElement.getAttribute(attr), value[0],
     72       "@" + attr + " value should be " + value[0]);
     73  }
     74 }
     75 
     76 
     77 xoriginParams = window.location.search;
     78 
     79 reflectURL(document.createElement("form"), "action");
     80 reflectURL(document.createElement("input"), "formAction");
     81 reflectURL(document.createElement("button"), "formAction");
     82 
     83 </script>
     84 </pre>
     85 </body>
     86 </html>