RetroZilla/embedding/qa/jstests/xpcom/nsIProperties.html

233 lines
5.8 KiB
HTML
Raw Normal View History

2015-10-21 05:03:22 +02:00
<html>
<!-- ***** BEGIN LICENSE BLOCK *****
- Version: MPL 1.1/GPL 2.0/LGPL 2.1
-
- The contents of this file are subject to the Mozilla Public License Version
- 1.1 (the "License"); you may not use this file except in compliance with
- the License. You may obtain a copy of the License at
- http://www.mozilla.org/MPL/
-
- Software distributed under the License is distributed on an "AS IS" basis,
- WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
- for the specific language governing rights and limitations under the
- License.
-
- The Original Code is mozilla.org code.
-
- The Initial Developer of the Original Code is
- Netscape Communications Corporation.
- Portions created by the Initial Developer are Copyright (C) 1998
- the Initial Developer. All Rights Reserved.
-
- Contributor(s):
- Ashish Bhatt <ashishbhatt@netscape.com>
-
- Alternatively, the contents of this file may be used under the terms of
- either the GNU General Public License Version 2 or later (the "GPL"), or
- the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
- in which case the provisions of the GPL or the LGPL are applicable instead
- of those above. If you wish to allow use of your version of this file only
- under the terms of either the GPL or the LGPL, and not to allow others to
- use your version of this file under the terms of the MPL, indicate your
- decision by deleting the provisions above and replace them with the notice
- and other provisions required by the LGPL or the GPL. If you do not delete
- the provisions above, a recipient may use your version of this file under
- the terms of any one of the MPL, the GPL or the LGPL.
-
- ***** END LICENSE BLOCK ***** -->
<title>nsIProperties Tets case</title>
<head>
<script type="text/javascript" src="http://www.mozilla.org/quality/embed/jstests/accessibility/jslib/bridge.js"> </script>
<script type="text/javascript">
var gPropObject ;
var buffer ;
function getPropertyObject()
{
if (gPropObject)
return gPropObject ;
try{
netscape.security.PrivilegeManager.enablePrivilege("UniversalBrowserRead");
netscape.security.PrivilegeManager.enablePrivilege("UniversalXPConnect");
gPropObject = Components.classes["@mozilla.org/properties;1"].
createInstance(Components.interfaces.nsIProperties)
return gPropObject ;
}
catch(e){
if (isRunningStandalone())
alert("Exception: " + e);
else
WriteResults("Exception: " + e);
}
}
function WritePassFail(aValue,e)
{
if( aValue == "Pass")
{
buffer += "<td>"+ e +"</td>" ;
buffer += "<td>Pass</td>"
}
else
{
buffer += "<td>" +"Exception: " + e + "</td>" ;
buffer += "<td bgcolor='#FF0000'>Fail</td>"
}
buffer += "</tr>"
}
function RunAllTests()
{
// "<td bgcolor='#FF0000'>
buffer = "<b>Results for <a href='http://lxr.mozilla.org/seamonkey/source/xpcom/ds/nsIProperties.idl'>nsIProperties :</a></b><br><br>"
buffer += "<table border cols=4 width='70%'>"
buffer += "<tr>"
buffer += "<td><b>Property/Method</b></td>"
buffer += "<td><b>Params</b></td>"
buffer += "<td><b>Bug/Error</b></td>"
buffer += "<td><b>Result</b></td>"
buffer += "</tr>"
set();
get();
has();
undefine();
getKeys();
buffer += "</table>"
if (isRunningStandalone())
{
document.clear();
document.write(buffer);
}
else
WriteResults(buffer);
}
function set()
{
var prop = getPropertyObject();
buffer += "<tr>"
buffer += "<td>set()</td>"
buffer += "<td>Name, Value(nsISupports)</td>"
try{
netscape.security.PrivilegeManager.enablePrivilege("UniversalBrowserRead");
netscape.security.PrivilegeManager.enablePrivilege("UniversalXPConnect");
var ifaceReq = window.QueryInterface(Components.interfaces.nsIInterfaceRequestor).getInterface(Components.interfaces.nsIDOMWindow);
prop.set("Name", ifaceReq);
WritePassFail("Pass",ifaceReq);
}
catch(e){
WritePassFail("Fail",e);
}
}
function get()
{
var prop = getPropertyObject();
buffer += "<tr>"
buffer += "<td>get()</td>"
buffer += "<td>Name, Type(nsISupports)</td>"
try{
netscape.security.PrivilegeManager.enablePrivilege("UniversalBrowserRead");
netscape.security.PrivilegeManager.enablePrivilege("UniversalXPConnect");
var abc = prop.get("Name", Components.interfaces.nsIDOMWindow);
WritePassFail("Pass",abc);
}
catch(e){
WritePassFail("Fail",e);
}
}
function has()
{
var prop = getPropertyObject();
buffer += "<tr>"
buffer += "<td>has()</td>"
buffer += "<td>Name</td>"
try{
netscape.security.PrivilegeManager.enablePrivilege("UniversalBrowserRead");
netscape.security.PrivilegeManager.enablePrivilege("UniversalXPConnect");
var bhas = prop.has("Name");
if (bhas)
WritePassFail("Pass","true");
else
WritePassFail("Pass","false");
}
catch(e){
WritePassFail("Fail",e);
}
}
function getKeys()
{
var prop = getPropertyObject();
buffer += "<tr>"
buffer += "<td>getKeys()</td>"
buffer += "<td>Name, Type(nsISupports)</td>"
try{
netscape.security.PrivilegeManager.enablePrivilege("UniversalBrowserRead");
netscape.security.PrivilegeManager.enablePrivilege("UniversalXPConnect");
//prop.define("Name", Components.interfaces.nsIFile);
WritePassFail("Fail","Test case not ready");
//WritePassFail("Pass",1);
}
catch(e){
WritePassFail("Fail",e);
}
}
function undefine()
{
var prop = getPropertyObject();
buffer += "<tr>"
buffer += "<td>undefine()</td>"
buffer += "<td>Name</td>"
try{
netscape.security.PrivilegeManager.enablePrivilege("UniversalBrowserRead");
netscape.security.PrivilegeManager.enablePrivilege("UniversalXPConnect");
prop.undefine("Name");
WritePassFail("Pass","Undefine");
}
catch(e){
WritePassFail("Fail",e);
}
}
</script>
</head>
<body>
<script type="text/javascript">
RunAllTests();
</script>
</body>
</html>