adding .txt files for js scripts

This commit is contained in:
depstein%netscape.com 2001-07-17 18:43:30 +00:00
Родитель 2263ed2c10
Коммит 06a7222ab4
5 изменённых файлов: 634 добавлений и 0 удалений

Просмотреть файл

@ -0,0 +1,86 @@
<HTML>
<!--
Written by Dharma.
Test last run on 07/02/01.
-->
<TITLE> nsIFontList </TITLE>
<HEAD>
<SCRIPT TYPE="text/javascript">
var langgroup = new Array("x-western", "ar", "el", "he", "ja", "ko", "th",
"tr", "x-baltic", "x-central-euro", "x-cyrillic",
"zh-CN", "zh-TW");
var fonttype = new Array("serif" , "sans-serif", "cursive", "fantasy", "monospace");
function getFontList()
{
try
{
netscape.security.PrivilegeManager.enablePrivilege("UniversalXPConnect");
var fontListObj = Components.classes["@mozilla.org/gfx/fontlist;1"].createInstance();
if (fontListObj)
fontListObj = fontListObj.QueryInterface(Components.interfaces.nsIFontList);
/*
this can be done in a single stmt.
var fontListObj = Components.classes["@mozilla.org/gfx/fontlist;1"].
createInstance(Components.interfaces.nsIFontList);
*/
}
catch(e) {
alert("Exception: " + e);
}
return fontListObj;
}
</SCRIPT>
<SCRIPT LANGUAGE="JAVASCRIPT">
function getBrowserVersion()
{
document.write("<b><h2>Browser Info </h2></b>");
document.write("<p><li><b>App Name:<TAB> </b>" + navigator.appName);
document.write("<p><li><b>User Agent:<TAB> </b>" + navigator.userAgent);
document.write("<p><li><b>Code Name:<TAB> </b>" + navigator.appCodeName);
document.write("<p><li><b>App Version:<TAB> </b>" + navigator.appVersion);
document.write("<p><li><b>Language:<TAB> </b>" + navigator.language);
document.write("<p><li><b>Platform:<TAB> </b>" + navigator.platform);
}
</SCRIPT>
</HEAD>
<BODY>
<SCRIPT TYPE="text/javascript">
getBrowserVersion();
var fontList = getFontList();
try
{
netscape.security.PrivilegeManager.enablePrivilege("UniversalXPConnect");
document.writeln("<H2><B>" + "Available Fonts" + "</B></H2>");
for(i=0; i<langgroup.length; i++)
{
document.writeln("<BR><B><U>" + langgroup[i] + "</U></B> <BR>");
for(j=0; j<fonttype.length; j++)
{
document.writeln("<B>" + fonttype[j] + "</B> <BR>");
var fontEnumerator = fontList.availableFonts(langgroup[i], fonttype[j]);
while (fontEnumerator.hasMoreElements())
{
fontName = fontEnumerator.getNext();
fontName = fontName.QueryInterface(Components.interfaces.nsISupportsWString);
var fontNameStr = fontName.toString();
document.writeln(fontNameStr + "<BR>");
}
}
}
document.writeln("<B>" + "-------------------" + "</B>");
}
catch(e) {
alert("Exception: " + e);
}
</SCRIPT>
</BODY>
</HTML>

Просмотреть файл

@ -0,0 +1,142 @@
<html>
<!--
Written by Dharma.
Test last run on 05/09/01.
-->
<head>
<title> Testing nsIPrefBranch Interface </title>
<script type="text/javascript">
function getnsIPrefServiceObj()
{
try {
netscape.security.PrivilegeManager.enablePrivilege("UniversalBrowserRead");
netscape.security.PrivilegeManager.enablePrivilege("UniversalXPConnect");
prefObj = Components.classes["@mozilla.org/preferences-service;1"].
getService(Components.interfaces.nsIPrefService);
}
catch(e) {
alert("Exception: " + e);
}
return prefObj;
}
</script>
</head>
<body>
<script type="text/javascript">
// First get the nsIPrefService object.
var nsIPrefServiceObj = getnsIPrefServiceObj();
try {
netscape.security.PrivilegeManager.enablePrivilege("UniversalXPConnect");
// get the nsIPrefBranch object.
// if you use getBranch() then the preference file that gets affected is prefs.js.
var nsIPrefBranchObj = nsIPrefServiceObj.getBranch("browser.startup.");
// verifying the attribute root.
alert("root: " + nsIPrefBranchObj.root);
// checking getPrefType method.
var prefType = nsIPrefBranchObj.getPrefType("homepage");
alert("prefType: " + prefType);
// checking getBoolPref method.
var boo = nsIPrefBranchObj.getBoolPref("homepage_override.1");
alert("boo: " + boo);
// checking setBoolPref method.
nsIPrefBranchObj.setBoolPref("homepage_override.1", 0);
nsIPrefServiceObj.savePrefFile(null);
// checking getCharPref method.
var result = nsIPrefBranchObj.getCharPref("homepage");
alert("charPref: " + result);
// checking setCharPref method.
nsIPrefBranchObj.setCharPref("homepage", "http://mozilla.org")
nsIPrefServiceObj.savePrefFile(null);
// checking getIntPref method.
/*
var result = nsIPrefBranchObj.getIntPref("editor.table.delete_key");
alert(result);
*/
// checking setIntPref method.
/*
nsIPrefBranchObj.setIntPref("editor.table.delete_key", 1)
nsIPrefServiceObj.savePrefFile(null);
*/
// checking clearUserPref method.
/*
nsIPrefBranchObj.clearUserPref("homepage_override.1");
nsIPrefServiceObj.savePrefFile(null);
*/
// checking lockPref method.
var boo = nsIPrefBranchObj.prefIsLocked("homepage_override.1");
alert ("prefIsLocked: " + boo);
nsIPrefBranchObj.lockPref("homepage_override.1");
nsIPrefServiceObj.savePrefFile(null);
// checking prefIsLocked method.
var boo = nsIPrefBranchObj.prefIsLocked("homepage_override.1");
alert ("prefIsLocked: " + boo);
/*
nsIPrefBranchObj.setBoolPref("homepage_override.1", 0);
nsIPrefServiceObj.savePrefFile(null);
*/
// checking unlockPref method.
nsIPrefBranchObj.unlockPref("homepage_override.1");
nsIPrefServiceObj.savePrefFile(null);
alert("parefIsLocked: " + nsIPrefBranchObj.prefIsLocked("homepage_override.1"));
// checking deleteBranch
// Filed a bug related to this method. for details see the bug #80108.
// after reading the bug tried by settting the root to "font" without a dot and
// it deletes the branch.
/*
nsIPrefBranchObj.deleteBranch(null);
nsIPrefServiceObj.savePrefFile(null);
*/
// checking resetBranch
/*
nsIPrefBranchObj.resetBranch("size.fixed.x-western");
nsIPrefServiceObj.savePrefFile(null);
*/
// checking getChildList method.
var aCount = {value:0};
var childArray = nsIPrefBranchObj.getChildList(null , aCount);
alert("aCount: " + aCount.value);
//alert("Array length: " + childArray.length);
alert("Array content: " + childArray.toString());
/*
var defaultName = nsIPrefBranchObj.getComplexValue("browser.search.defaultenginename" , Components.interfaces.nsIPrefLocalizedString);
alert(defaultName);
*/
alert("End");
}
catch(e) {
alert("Exception: " + e);
}
</script>
</body>
</html>

Просмотреть файл

@ -0,0 +1,158 @@
<HTML>
<HEAD>
<TITLE> Testing nsIPrompt Interface </TITLE>
<!--
Written by Dharma.
Tests last run on 04/30/01.
Tests last run on 05/08/01.
-->
<SCRIPT TYPE="text/javascript">
function getnsIPromptObj()
{
// get an implementation of nsIPrompt.
// (interface definition is embedding/browser/webBrowser)
try {
netscape.security.PrivilegeManager.enablePrivilege("UniversalBrowserRead");
netscape.security.PrivilegeManager.enablePrivilege("UniversalXPConnect");
var ww = Components.classes["@mozilla.org/embedcomp/window-watcher;1"].
getService(Components.interfaces.nsIWindowWatcher);
// window is javascript window which is always available.
var prompter = ww.getNewPrompter(window); // nsIPrompt
}
catch(e) {
alert("Exception: " + e);
}
return prompter;
}
</SCRIPT>
</HEAD>
<BODY>
<SCRIPT TYPE="text/javascript">
var promptObj = getnsIPromptObj();
try {
netscape.security.PrivilegeManager.enablePrivilege("UniversalXPConnect");
// checking the alert() method.
/*
promptObj.alert("alert dialog", "text here");
*/
// checking the alertCheck method.
/*
var checkbox = {value:1};
promptObj.alertCheck("alertcheck dialog","text message",
"check or uncheck",checkbox);
alert(checkbox.value);
*/
// checking the confirm method
/*
var boo = promptObj.confirm("confirm dialog", " Do you want to continue");
//var boo = promptObj.confirm("confirm dialog","first", "second");
alert(boo);
*/
// checking the confirmCheck method.
/*
var checkbox = {value:0};
var boo = promptObj.confirmCheck("confirmcheck dialog",
"Do you want to continue",
"check or uncheck", checkbox);
alert("Checkbox checked: " + checkbox.value);
alert("Confirmation accepted: " + boo);
*/
// checking the confirmEx method.
var checkbox = {value:1};
var buttonPressed = {value:0};
// first variation.
/*
var std_buttons = (promptObj.BUTTON_TITLE_OK * promptObj.BUTTON_POS_0) +
(promptObj.BUTTON_TITLE_CANCEL * promptObj.BUTTON_POS_1) +
(promptObj.BUTTON_TITLE_SAVE * promptObj.BUTTON_POS_2);
*/
// second variation.
/*
var std_buttons = (promptObj.BUTTON_TITLE_IS_STRING * promptObj.BUTTON_POS_0) +
(promptObj.BUTTON_TITLE_IS_STRING * promptObj.BUTTON_POS_1) +
(promptObj.BUTTON_TITLE_IS_STRING * promptObj.BUTTON_POS_2);
promptObj.confirmEx("confirmEx dialog", "text message", std_buttons,
"Button0", "Button1", "Button2",
"check or uncheck", checkbox, buttonPressed);
alert("Checkbox checked: " + checkbox.value);
alert("Button pressed: " + buttonPressed.value);
*/
// checking the prompt method.
/*
var val = {value:"default value"};
var checkbox = {value:1};
*/
/** notes
Passing var checkbox = {value:null}; is not null.
If you don't want the checkbox, you need to pass null, not a value
which contains null.
Since checkbox is an inout param,it can never be null when called from js.
Q.Make check message as null.(in this case "check or uncheck").Default title
should be shown.Its not showing default title and its not showing the checkbox also.
A.The comment in the API will have to change, not the code. The idea was, if
checkMsg == null && checkValue != null, to use a default title for the checkbox.
Since checkValue is an inout param, it isn't possible to pass null from JS as it
is from C++. So, the prompt implementation requires both the message and the
value to be non-null in order to show the checkbox.
**/
/*
var boo = promptObj.prompt("prompt dialog", "text message",
val, "check or uncheck", checkbox);
alert("Value: " + val.value);
alert("Checkbox checked: " + checkbox.value);
alert("Confirmation accepted: " + boo);
*/
// checking the promptPassword method.
/*
var password = {value:"dharma"};
var checkbox = {value:1};
var boo = promptObj.promptPassword("promptPassword dialog", "Enter the password",
password, "check or uncheck", checkbox);
alert("pass: " + password.value);
alert("checkbox checked: " + checkbox.value);
alert("confirmation accepted: " + boo);
*/
// checking the promptUsernameAndPassword method.
/*
var username = {value:"Dharma"};
var password = {value:"Gopal"};
var checkbox = {value:1};
var boo = promptObj.promptUsernameAndPassword("promptUsernameAndPassword dialog",
"Enter Username and Password", username, password,
"check or uncheck", checkbox);
alert("username: " + username.value);
alert("pass: " + password.value);
alert("checkbox checked: " + checkbox.value);
alert("confirmation accepted: " + boo);
*/
// Checking the select method.
selectList = new Array("first","second","third","fourth");
var outSelection = {value:0};
var boo = promptObj.select("select dialog", "Select one:",
4, selectList, outSelection);
alert("outSelection: " + outSelection.value);
alert("confirmation accepted: " + boo);
}
catch(e) {
alert("Exception: " + e);
}
alert("END");
</script>
</body>
</html>

Просмотреть файл

@ -0,0 +1,141 @@
<HTML>
<HEAD>
<TITLE> Testing nsIURI Interface </TITLE>
<!--
Written by Dharma.
Tests last run on 05/22/01.
-->
<SCRIPT TYPE="text/javascript">
function getnsIURIObj()
{
// get an implementation of nsIURI.
try {
netscape.security.PrivilegeManager.enablePrivilege("UniversalBrowserRead");
netscape.security.PrivilegeManager.enablePrivilege("UniversalXPConnect");
// using standard url contractid. later on try with simple uri contractid.
var nsUriObj = Components.classes["@mozilla.org/network/standard-url;1"].
createInstance(Components.interfaces.nsIURI);
//var nsUriObj = Components.classes["@mozilla.org/network/standard-url;1"].
// getService(Components.interfaces.nsIURI);
}
catch(e) {
alert("Exception: " + e);
}
return nsUriObj;
}
</SCRIPT>
</HEAD>
<BODY>
<SCRIPT TYPE="text/javascript">
var uriObj = getnsIURIObj();
// newuriObj object is used for testing equals method.
var newuriObj = getnsIURIObj();
try {
netscape.security.PrivilegeManager.enablePrivilege("UniversalXPConnect");
// checking attribute spec.
uriObj.spec = "http://username:password@www.mozilla.org:9090/quality/embed/index.html";
newuriObj.spec = "http://username:password@www.mozilla.org:9090/quality/embed/index.html";
/*
alert(uriObj.spec);
*/
// checking attribute prepath.
/*
alert(uriObj.prePath);
// setting the prepath is not yet implemented.
uriObj.prePath="http://username:password@www.yahoo.com";
alert(uriObj.prePath);
*/
// checking attribute scheme.
/*
alert(uriObj.scheme);
uriObj.scheme="ftp";
alert(uriObj.scheme);
*/
// checking attribute preHost.
/*
alert(uriObj.preHost);
uriObj.preHost = "giveusername:givepassword";
alert(uriObj.preHost);
*/
// checking attribute username.
/*
alert(uriObj.username);
uriObj.username = "giveusername";
alert(uriObj.username);
*/
// checking attribute password.
/*
alert(uriObj.password);
uriObj.password = "givepassword";
alert(uriObj.password);
*/
// checking attribute host.
/*
alert(uriObj.host);
uriObj.host = "www.yahoo.com";
alert(uriObj.host);
*/
// checking attribute port.
/*
alert(uriObj.port);
uriObj.port = -1;
alert(uriObj.port);
*/
// checking attribute path.
alert(uriObj.path);
uriObj.path = "projects/ui/";
alert(uriObj.path);
// checking the equals method.
/*
var boo = uriObj.equals(newuriObj);
alert(boo);
*/
// checking the schemeIs method.
/*
var boo = uriObj.schemeIs("ftp");
alert(boo);
*/
// checking the clone method.
/*
var cloneuriObj = uriObj.clone();
alert(cloneuriObj.port);
alert(cloneuriObj.path);
*/
// checking the resolve method.
/*
var absuri = uriObj.resolve("projects/ui/accessibility/");
alert(absuri);
*/
}
catch(e) {
alert("Exception: " + e);
}
alert("END");
</SCRIPT>
</BODY>
</HTML>

Просмотреть файл

@ -0,0 +1,107 @@
<HTML>
<HEAD>
<TITLE> Testing nsIURL Interface </TITLE>
<!--
Written by Dharma.
Tests last run on 05/25/01.
-->
<SCRIPT TYPE="text/javascript">
function getnsIURLObj()
{
// get an implementation of nsIURL.
try {
netscape.security.PrivilegeManager.enablePrivilege("UniversalBrowserRead");
netscape.security.PrivilegeManager.enablePrivilege("UniversalXPConnect");
var nsUrlObj = Components.classes["@mozilla.org/network/standard-url;1"].
createInstance(Components.interfaces.nsIURL);
}
catch(e) {
alert("Exception: " + e);
}
return nsUrlObj;
}
</SCRIPT>
</HEAD>
<BODY>
<SCRIPT TYPE="text/javascript">
var urlObj = getnsIURLObj();
try {
netscape.security.PrivilegeManager.enablePrivilege("UniversalXPConnect");
urlObj.spec = "http://directory/newdir/fileBaseName.fileExtension?query";
// checking the filePath attribute.
/*
alert(urlObj.filePath);
urlObj.filePath = "/modifieddir/modifiedfile.ext";
alert(urlObj.spec);
*/
// checking param attribute.
/*
alert(urlObj.param);
urlObj.param = "newparam";
alert(urlObj.spec);
*/
// checking query attribute.
/*
alert(urlObj.query);
urlObj.query = "newquery";
alert(urlObj.spec);
*/
// checking ref attribute.
/*
alert(urlObj.ref);
urlObj.ref = "newref";
alert(urlObj.spec);
*/
// checking directory attribute
/*
alert(urlObj.directory);
urlObj.directory = "modifieddir";
alert(urlObj.spec);
*/
// checking fileName attribute.
/*
alert(urlObj.fileName);
urlObj.fileName = "newfilename";
alert(urlObj.spec);
*/
// checking fileBaseName attribute.
/*
alert(urlObj.fileBaseName);
urlObj.fileBaseName = "newfileBaseName";
alert(urlObj.spec);
*/
// checking fileExtension attribute.
/*
alert(urlObj.fileExtension);
urlObj.fileExtension = "newfileExtension";
alert(urlObj.spec);
*/
// checking escapedQuery attribute.
alert(urlObj.escapedQuery);
urlObj.escapedQuery = "escapedQuery";
alert(urlObj.spec);
}
catch(e) {
alert("Exception: " + e);
}
alert("END");
</SCRIPT>
</BODY>
</HTML>