content/base/test/test_bug345339.html

Thu, 22 Jan 2015 13:21:57 +0100

author
Michael Schloh von Bennewitz <michael@schloh.com>
date
Thu, 22 Jan 2015 13:21:57 +0100
branch
TOR_BUG_9701
changeset 15
b8a032363ba2
permissions
-rw-r--r--

Incorporate requested changes from Mozilla in review:
https://bugzilla.mozilla.org/show_bug.cgi?id=1123480#c6

     1 <!DOCTYPE HTML>
     2 <html>
     3 <!--
     4 https://bugzilla.mozilla.org/show_bug.cgi?id=345339
     5 -->
     6 <head>
     7   <title>Test for Bug 345339</title>
     8   <script type="text/javascript" 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=345339">Mozilla Bug 345339</a>
    13 <p id="display"></p>
    14 <div id="content" style="display: none">
    15 </div>
    16  <iframe id="testframe"
    17          src="http://mochi.test:8888/tests/content/base/test/345339_iframe.html">
    18  </iframe>
    19 <pre id="test">
    20 <script class="testbody" type="text/javascript">
    21 /** Test for Bug 345339 **/
    22 SimpleTest.waitForExplicitFinish();
    24 var filePath;
    26 function afterLoad() {
    27     var iframeDoc = $("testframe").contentDocument;
    29     /* change all the form controls */
    30     iframeDoc.getElementById("select").selectedIndex = 1;
    31     iframeDoc.getElementById("radio2").checked = true;
    32     iframeDoc.getElementById("password").value = "123456";
    33     iframeDoc.getElementById("hidden").value = "gecko";
    35     var file = SpecialPowers.Cc["@mozilla.org/file/directory_service;1"]
    36              .getService(SpecialPowers.Ci.nsIProperties)
    37              .get("TmpD", SpecialPowers.Ci.nsILocalFile);
    38     file.append("345339_test.file");
    39     file.createUnique(SpecialPowers.Ci.nsIFile.NORMAL_FILE_TYPE, 0666);
    40     filePath = file.path;
    42     SpecialPowers.wrap(iframeDoc).getElementById("file").value = filePath;
    44     /* Reload the page */
    45     $("testframe").setAttribute("onload", "afterReload()");
    46     iframeDoc.location.reload();
    47 }
    49 addLoadEvent(afterLoad);
    51 function afterReload() {
    52     var iframeDoc = $("testframe").contentDocument;
    54     is(iframeDoc.getElementById("select").selectedIndex, 1,
    55        "select element selected index preserved");
    56     is(iframeDoc.getElementById("radio1").checked, false,
    57        "radio button #1 value preserved");
    58     is(iframeDoc.getElementById("radio2").checked, true,
    59        "radio button #2 value preserved");
    60     isnot(iframeDoc.getElementById("password").value, "123456",
    61        "password field value forgotten");
    62     is(iframeDoc.getElementById("hidden").value, "gecko",
    63        "hidden field value preserved");
    64     is(SpecialPowers.wrap(iframeDoc).getElementById("file").value, filePath,
    65        "file field value preserved");
    67     SimpleTest.finish();
    68 }
    69 </script>
    70 </pre>
    71 </body>
    72 </html>

mercurial