1 <!-- ***** BEGIN LICENSE BLOCK *****
2 - Version: MPL 1.1/GPL 2.0/LGPL 2.1
4 - The contents of this file are subject to the Mozilla Public License Version
5 - 1.1 (the "License"); you may not use this file except in compliance with
6 - the License. You may obtain a copy of the License at
7 - http://www.mozilla.org/MPL/
9 - Software distributed under the License is distributed on an "AS IS" basis,
10 - WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
11 - for the specific language governing rights and limitations under the
14 - The Original Code is Mozilla Communicator Test Cases.
16 - The Initial Developer of the Original Code is Netscape Communications
17 - Corp. Portions created by Netscape Communications Corp. are
18 - Copyright (C) 2001 Netscape Communications Corp. All
22 - dsirnapalli@netscape.com.
24 - Alternatively, the contents of this file may be used under the terms of
25 - either the GNU General Public License Version 2 or later (the "GPL"), or
26 - the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
27 - in which case the provisions of the GPL or the LGPL are applicable instead
28 - of those above. If you wish to allow use of your version of this file only
29 - under the terms of either the GPL or the LGPL, and not to allow others to
30 - use your version of this file under the terms of the MPL, indicate your
31 - decision by deleting the provisions above and replace them with the notice
32 - and other provisions required by the LGPL or the GPL. If you do not delete
33 - the provisions above, a recipient may use your version of this file under
34 - the terms of any one of the MPL, the GPL or the LGPL.
36 - ***** END LICENSE BLOCK ***** -->
38 <!doctype html public "-//w3c//dtd html 4.0 transitional//en">
40 <title> nsIWebBrowserPersist Interface Test</title>
41 <!-- Descrpt: This Test Case tests the attribute persistFlags.
42 Author: dsirnapalli@netscape.com
43 Revs: 10.03.01 - Created
44 Last Run On: 10.24.01.
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:\\test3.htm";
55 data = "c:\\test3_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.persistFlags = persist.PERSIST_FLAGS_IGNORE_IFRAMES;
78 persist.saveDocument(document, localFile, dataPath);
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() & Attribute:persistFlags</u></b><br>";
150 results = results + "persistFlags is set to ignore IFRAME content,"
151 + " so no information regarding IFRAME is saved physically." + "<br><br>";
152 results = results + "<b> Result: </b><br>";
153 results = results + "If " + "<b>" + file + "</b>" + " exist physically and " + "<b><br>";
154 results = results + "If " + data + "</b>" + " exist physically and if " + data +
155 " contains only testlib.js then the Result is Pass" + "<br><br>";
158 results = results + "<b> Status: </b><br>";
159 for(i=0;i<astatus.length;i++)
160 results = results + astatus[i] + "<br>";
161 results = results + "<br>";
162 results = results + "<b> Progress: </b><br>";
163 results = results + progress + "<br>";
164 results = results + "</html>";
166 displayResults(results);
169 function displayResults(results)
171 document.results.textarea.value = results;
172 if (top.name == "testWindow")
178 document.write(document.results.textarea.value);
186 <!-- form below is ngdriverspecific -->
187 <form name="results" action="/ngdriver/cgi-bin/writeresults.cgi" method="post">
188 <script TYPE="text/javascript">
189 document.write('<input name="resultsfile" type="hidden" value="' + window.opener.document.resultsform.resultsfile.value + '">');
191 <input type="hidden" name="textarea">
194 <p>This is nsIWebBrowserPersist Interface test case</p>
195 <p>This is the IFRAME used for testing</p>
196 <iframe id="frame1" width="100%" height="480" src="http://www.mozilla.org/"/>
198 <script TYPE="text/javascript">
199 setTimeout("saveDocument();", 2000);
200 setTimeout("constructResults();", 5000);