docshell/test/chrome/bug294258_window.xul

changeset 0
6474c204b198
     1.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     1.2 +++ b/docshell/test/chrome/bug294258_window.xul	Wed Dec 31 06:09:35 2014 +0100
     1.3 @@ -0,0 +1,76 @@
     1.4 +<?xml version="1.0"?>
     1.5 +<?xml-stylesheet href="chrome://global/skin" type="text/css"?>
     1.6 +
     1.7 +<window id="294258Test"
     1.8 +        xmlns="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul"
     1.9 +        width="600"
    1.10 +        height="600"
    1.11 +        onload="setTimeout(nextTest,0);"
    1.12 +        title="bug 294258 test">
    1.13 +
    1.14 +  <script type="application/javascript" src= "chrome://mochikit/content/chrome-harness.js" />
    1.15 +  <script type="application/javascript" src="docshell_helpers.js" />
    1.16 +  <script type="application/javascript"><![CDATA[
    1.17 +  
    1.18 +    // Define the generator-iterator for the tests.
    1.19 +    var tests = testIterator();
    1.20 +
    1.21 +    ////
    1.22 +    // Execute the next test in the generator function.
    1.23 +    //
    1.24 +    function nextTest() {
    1.25 +      tests.next();
    1.26 +    }
    1.27 +
    1.28 +    function $(id) { return TestWindow.getDocument().getElementById(id); }
    1.29 +
    1.30 +    ////
    1.31 +    // Generator function for test steps for bug 294258:  
    1.32 +    // Form values should be preserved on reload.
    1.33 +    //
    1.34 +    function testIterator()
    1.35 +    {
    1.36 +      // Load a page containing a form.
    1.37 +      doPageNavigation( {
    1.38 +          uri: getHttpUrl("bug294258_testcase.html"),
    1.39 +          onNavComplete: nextTest
    1.40 +        } );
    1.41 +      yield undefined;
    1.42 +      
    1.43 +      // Change the data for each of the form fields, and reload.
    1.44 +      $("text").value = "text value";
    1.45 +      $("checkbox").checked = true;
    1.46 +      var file = Components.classes["@mozilla.org/file/directory_service;1"]
    1.47 +             .getService(Components.interfaces.nsIProperties)
    1.48 +             .get("TmpD", Components.interfaces.nsILocalFile);
    1.49 +      file.append("294258_test.file");
    1.50 +      file.createUnique(Components.interfaces.nsIFile.NORMAL_FILE_TYPE, 0666);
    1.51 +      filePath = file.path;
    1.52 +      $("file").value = filePath;
    1.53 +      $("textarea").value = "textarea value";
    1.54 +      $("radio1").checked = true;
    1.55 +      $("select").selectedIndex = 2;
    1.56 +      doPageNavigation( {
    1.57 +          reload: true,
    1.58 +          onNavComplete: nextTest
    1.59 +        } );
    1.60 +      yield undefined;
    1.61 +      
    1.62 +      // Verify that none of the form data has changed.
    1.63 +      is($("text").value, "text value", "Text value changed");
    1.64 +      is($("checkbox").checked, true, "Checkbox value changed");
    1.65 +      is($("file").value, filePath, "File value changed");
    1.66 +      is($("textarea").value, "textarea value", "Textarea value changed");
    1.67 +      is($("radio1").checked, true, "Radio value changed");
    1.68 +      is($("select").selectedIndex, 2, "Select value changed");
    1.69 +
    1.70 +      // Tell the framework the test is finished.  Include the final 'yield' 
    1.71 +      // statement to prevent a StopIteration exception from being thrown.
    1.72 +      finish();
    1.73 +      yield undefined;
    1.74 +    }
    1.75 +    
    1.76 +  ]]></script>
    1.77 +
    1.78 +  <browser type="content-primary" flex="1" id="content" src="about:blank"/>
    1.79 +</window>

mercurial