Bug 464947 - Clear Recent History dialog should clear form data by timespan. r=mconnor
[wine-gecko.git] / embedding / qa / jstests / nsIWebBrowserPersistTest2.txt
blob15de75aca7a93ae0808d1037844ee2c8f560a503
1 <!doctype html public "-//w3c//dtd html 4.0 transitional//en">
2 <html>
3 <title> nsIWebBrowserPersist Interface Test</title>
4 <!--
5      Descrpt: This Test Case tests saveDocument method.
6      Author: dsirnapalli@netscape.com
7      Revs: 10.03.01 - Created
8      Last Run On: 10.24.01.
9 -->
10 <!-- ***** BEGIN LICENSE BLOCK *****
11    - Version: MPL 1.1/GPL 2.0/LGPL 2.1
12    -
13    - The contents of this file are subject to the Mozilla Public License Version
14    - 1.1 (the "License"); you may not use this file except in compliance with
15    - the License. You may obtain a copy of the License at
16    - http://www.mozilla.org/MPL/
17    -
18    - Software distributed under the License is distributed on an "AS IS" basis,
19    - WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
20    - for the specific language governing rights and limitations under the
21    - License.
22    -
23    - The Original Code is Mozilla Communicator Test Cases.
24    -
25    - The Initial Developer of the Original Code is
26    - Netscape Communications Corporation.
27    - Portions created by the Initial Developer are Copyright (C) 1999
28    - the Initial Developer. All Rights Reserved.
29    -
30    - Contributor(s):
31    -   dsirnapalli@netscape.com
32    -
33    - Alternatively, the contents of this file may be used under the terms of
34    - either the GNU General Public License Version 2 or later (the "GPL"), or
35    - the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
36    - in which case the provisions of the GPL or the LGPL are applicable instead
37    - of those above. If you wish to allow use of your version of this file only
38    - under the terms of either the GPL or the LGPL, and not to allow others to
39    - use your version of this file under the terms of the MPL, indicate your
40    - decision by deleting the provisions above and replace them with the notice
41    - and other provisions required by the LGPL or the GPL. If you do not delete
42    - the provisions above, a recipient may use your version of this file under
43    - the terms of any one of the MPL, the GPL or the LGPL.
44    -
45    - ***** END LICENSE BLOCK ***** -->
47 <head>
49 <!-- script below is ngdriverspecific  -->
50 <script TYPE="text/javascript" SRC="http://bubblegum/ngdriver/suites/testlib.js">
51 </script>
53 <script TYPE="text/javascript">
54 file = "c:\\test2.htm";
55 data = "c:\\test2_data";
56 astatus = new Array();
57 i = 0;
59 function saveDocument()
61   try {
62     netscape.security.PrivilegeManager.enablePrivilege("UniversalXPConnect");
64     localFile = Components.classes["@mozilla.org/file/local;1"]
65                .createInstance(Components.interfaces.nsILocalFile);
66     localFile.initWithPath(file)
68     dataPath = Components.classes["@mozilla.org/file/local;1"]
69               .createInstance(Components.interfaces.nsILocalFile)
70     dataPath.initWithPath(data)
72     persistListener = new PersistProgressListener;
73     persist = Components.classes["@mozilla.org/embedding/browser/nsWebBrowserPersist;1"]
74              .createInstance(Components.interfaces.nsIWebBrowserPersist);
76     persist.progressListener = persistListener;
77     persist.saveDocument(document, localFile, dataPath);
78     //persist.cancelSave();
79   }
80   catch(e) {
81     alert("Exception: " + e);
82   }
85 function setStatus(text)
87   astatus[i] = text;
88   i++;
91 function setProgress(current, max)
93   progress = current + " out of " + max;
96 function PersistProgressListener()
98   this.init();
101 PersistProgressListener.prototype =
103   QueryInterface : function(aIID)
104   {
105     if(aIID.equals(Components.interfaces.nsIWebProgressListener))
106       return this;
107     throw Components.results.NS_NOINTERFACE;
108   },
110   init : function()
111   {
112   },
114   destroy : function()
115   {
116   },
118   // nsIWebProgressListener
119   onProgressChange : function (aWebProgress, aRequest,
120                                aCurSelfProgress, aMaxSelfProgress,
121                                aCurTotalProgress, aMaxTotalProgress)
122   {
123     setProgress(aCurTotalProgress, aMaxTotalProgress);
124   },
126   onStateChange : function(aWebProgress, aRequest, aStateFlags, aStatus)
127   {
128   },
130   onLocationChange : function(aWebProgress, aRequest, aLocation)
131   {
132   },
134   onStatusChange : function(aWebProgress, aRequest, aStatus, aMessage)
135   {
136     setStatus(aMessage);
137   },
139   onSecurityChange : function(aWebProgress, aRequest, aState)
140   {
141   }
144 function constructResults()
146   var results = "";
147   results = results + "<html><br>";
148   results = results + "<b><u> Interface:nsIWebBrowserPersist</u></b><br>";
149   results = results + "<b><u>Method:saveDocument()</u></b><br><br>";
150   results = results + "<b> Result: </b><br>";
151   results = results + "If " + "<b>" + file + "</b>" + " exist physically and " + "<b><br>";
152   results = results + "If " + data + "</b>" + " exist physically and if " + data +
153                       " contains file1_htm, testlib.js, file_1.data folder then the Result is Pass" +  "<br><br>";
154   results = results + "<b> Status: </b><br>";
155   for(i=0;i<astatus.length;i++)
156     results = results + astatus[i] + "<br>";
157   results = results + "<br>";
158   results = results + "<b> Progress: </b><br>";
159   results = results + progress + "<br>";
160   results = results + "</html>";
162   displayResults(results);
165 function displayResults(results)
167   document.results.textarea.value = results;
168   if (top.name == "testWindow")
169   {
170     fixSubmit();
171   }
172   else
173   {
174     document.write(document.results.textarea.value);
175   }
178 </script>
179 </head>
180 <body>
182 <!-- form below is ngdriverspecific  -->
183 <form name="results" action="/ngdriver/cgi-bin/writeresults.cgi" method="post">
184 <script TYPE="text/javascript">
185 document.write('<input name="resultsfile" type="hidden" value="' + window.opener.document.resultsform.resultsfile.value + '">');
186 </script>
187 <input type="hidden" name="textarea">
188 </form>
190 <p>This is nsIWebBrowserPersist Interface test case</p>
191 <p>This is the IFRAME used for testing</p>
192 <iframe id="frame1" width="100%" height="480" src="http://www.mozilla.org/"/>
194 <script TYPE="text/javascript">
195 setTimeout("saveDocument();", 2000);
196 setTimeout("constructResults();", 5000);
197 </script>
199 </body>
200 </html>