1 <!doctype html public "-//w3c//dtd html 4.0 transitional//en">
3 <title> nsIWebBrowserPersist Interface Test</title>
5 Descrpt: This Test Case tests saveDocument method.
6 Author: dsirnapalli@netscape.com
7 Revs: 10.03.01 - Created
10 <!-- ***** BEGIN LICENSE BLOCK *****
11 - Version: MPL 1.1/GPL 2.0/LGPL 2.1
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/
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
23 - The Original Code is Mozilla Communicator Test Cases.
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.
31 - dsirnapalli@netscape.com
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.
45 - ***** END LICENSE BLOCK ***** -->
49 <!-- script below is ngdriverspecific -->
50 <script TYPE="text/javascript" SRC="http://bubblegum/ngdriver/suites/testlib.js">
53 <script TYPE="text/javascript">
54 file = "c:\\test2.htm";
55 data = "c:\\test2_data";
56 astatus = new Array();
59 function saveDocument()
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();
81 alert("Exception: " + e);
85 function setStatus(text)
91 function setProgress(current, max)
93 progress = current + " out of " + max;
96 function PersistProgressListener()
101 PersistProgressListener.prototype =
103 QueryInterface : function(aIID)
105 if(aIID.equals(Components.interfaces.nsIWebProgressListener))
107 throw Components.results.NS_NOINTERFACE;
118 // nsIWebProgressListener
119 onProgressChange : function (aWebProgress, aRequest,
120 aCurSelfProgress, aMaxSelfProgress,
121 aCurTotalProgress, aMaxTotalProgress)
123 setProgress(aCurTotalProgress, aMaxTotalProgress);
126 onStateChange : function(aWebProgress, aRequest, aStateFlags, aStatus)
130 onLocationChange : function(aWebProgress, aRequest, aLocation)
134 onStatusChange : function(aWebProgress, aRequest, aStatus, aMessage)
139 onSecurityChange : function(aWebProgress, aRequest, aState)
144 function constructResults()
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")
174 document.write(document.results.textarea.value);
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 + '">');
187 <input type="hidden" name="textarea">
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);