This commit is contained in:
mark.finkle@gmail.com 2007-06-12 13:31:02 -07:00
Родитель 8fd7d4c19c
Коммит 36c86d446a
6 изменённых файлов: 0 добавлений и 498 удалений

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

@ -1,31 +0,0 @@
<?xml version="1.0"?>
<?xml-stylesheet href="chrome://global/skin" type="text/css"?>
<?xml-stylesheet href="chrome://mochikit/content/tests/SimpleTest/test.css" type="text/css"?>
<window title="Testing Application"
xmlns="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul"
xmlns:html="http://www.w3.org/1999/xhtml">
<script type="application/javascript" src="chrome://mochikit/content/MochiKit/packed.js"></script>
<script type="application/javascript" src="chrome://mochikit/content/tests/SimpleTest/SimpleTest.js"></script>
<script type="application/javascript" src="chrome://mochikit/content/tests/SimpleTest/EventUtils.js"></script>
<body xmlns="http://www.w3.org/1999/xhtml" />
<script type="application/javascript">
<![CDATA[
test_Application();
function test_Application() {
ok(Application, "Check global access to Application");
// I'd test these against a specific value, but that is bound to flucuate
ok(Application.id, "Check to see if an ID exists for the Application");
ok(Application.name, "Check to see if a name exists for the Application");
ok(Application.version, "Check to see if a version exists for the Application");
}
]]>
</script>
</window>

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

@ -1,181 +0,0 @@
<?xml version="1.0"?>
<?xml-stylesheet href="chrome://global/skin" type="text/css"?>
<?xml-stylesheet href="chrome://mochikit/content/tests/SimpleTest/test.css" type="text/css"?>
<window title="Testing Application Prefs"
xmlns="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul"
xmlns:html="http://www.w3.org/1999/xhtml">
<script type="application/javascript" src="chrome://mochikit/content/MochiKit/packed.js"></script>
<script type="application/javascript" src="chrome://mochikit/content/tests/SimpleTest/SimpleTest.js"></script>
<script type="application/javascript" src="chrome://mochikit/content/tests/SimpleTest/EventUtils.js"></script>
<body xmlns="http://www.w3.org/1999/xhtml" />
<script type="application/javascript">
<![CDATA[
// The various properties that we'll be testing
var test = {
missing: "fuel.fuel-test-missing",
dummy: "fuel.fuel-test",
string: "browser.active_color",
integer: "permissions.default.image",
boolean: "browser.blink_allowed"
};
test_Preferences();
function test_Preferences() {
// test getting non-existing values
var itemValue = Application.prefs.getValue(test.missing, "default");
is(itemValue, "default", "Check 'Application.prefs.getValue' for non-existing item");
is(Application.prefs.get(test.missing), null, "Check 'Application.prefs.get' for non-existing item");
// test setting and getting a value
Application.prefs.setValue(test.dummy, "dummy");
itemValue = Application.prefs.getValue(test.dummy, "default");
is(itemValue, "dummy", "Check 'Application.prefs.getValue' for existing item");
// test for overwriting an existing value
Application.prefs.setValue(test.dummy, "smarty");
itemValue = Application.prefs.getValue(test.dummy, "default");
is(itemValue, "smarty", "Check 'Application.prefs.getValue' for overwritten item");
// test setting and getting a value
Application.prefs.get(test.dummy).value = "dummy2";
itemValue = Application.prefs.get(test.dummy).value;
is(itemValue, "dummy2", "Check 'Application.prefs.get().value' for existing item");
// test resetting a pref [since there is no default value, the pref should disappear]
Application.prefs.get(test.dummy).reset();
var itemValue = Application.prefs.getValue(test.dummy, "default");
is(itemValue, "default", "Check 'Application.prefs.getValue' for reset pref");
// test to see if a non-existant property exists
ok(!Application.prefs.has(test.dummy), "Check non-existant property for existance");
// PREF: string browser.active_color == #EE0000
// test to see if an existing string property exists
ok(Application.prefs.has(test.string), "Check existing string property for existance");
// test accessing a non-existant string property
var val = Application.prefs.getValue(test.dummy, "default");
is(val, "default", "Check non-existant string property for expected value");
// test accessing an existing string property
var val = Application.prefs.getValue(test.string, "default");
is(val, "#EE0000", "Check existing string property for expected value");
// test manipulating an existing string property
Application.prefs.setValue(test.string, "#EF0000");
var val = Application.prefs.getValue(test.string, "default");
is(val, "#EF0000", "Set existing string property");
// test resetting an existing string property
Application.prefs.get(test.string).reset();
var val = Application.prefs.getValue(test.string, "default");
is(val, "#EE0000", "Reset existing string property");
// PREF: integer permissions.default.image == 1
// test to see if an existing integer property exists
ok(Application.prefs.has(test.integer), "Check existing integer property for existance");
// test accessing a non-existant integer property
var val = Application.prefs.getValue(test.dummy, 0);
is(val, 0, "Check non-existant integer property for expected value");
// test accessing an existing integer property
var val = Application.prefs.getValue(test.integer, 0);
is(val, 1, "Check existing integer property for expected value");
// test manipulating an existing integer property
Application.prefs.setValue(test.integer, 0);
var val = Application.prefs.getValue(test.integer, 1);
is(val, 0, "Set existing integer property");
// test resetting an existing integer property
Application.prefs.get(test.integer).reset();
var val = Application.prefs.getValue(test.integer, 0);
is(val, 1, "Reset existing integer property");
// PREF: boolean browser.blink_allowed == true
// test to see if an existing boolean property exists
ok(Application.prefs.has(test.boolean), "Check existing boolean property for existance");
// test accessing a non-existant boolean property
var val = Application.prefs.getValue(test.dummy, true);
ok(val, "Check non-existant boolean property for expected value");
// test accessing an existing boolean property
var val = Application.prefs.getValue(test.boolean, false);
ok(val, "Check existing boolean property for expected value");
// test manipulating an existing boolean property
Application.prefs.setValue(test.boolean, false);
var val = Application.prefs.getValue(test.boolean, true);
ok(!val, "Set existing boolean property");
// test resetting an existing boolean property
Application.prefs.get(test.boolean).reset();
var val = Application.prefs.getValue(test.boolean, false);
ok(val, "Reset existing string property for expected value");
// test getting all preferences
var allPrefs = Application.prefs.all;
ok(allPrefs.length >= 800, "Check 'Application.prefs.all' for the right number of preferences");
is(allPrefs[0].name, "capability.policy.default.Window.parent.get", "Check 'Application.prefs.all' for the right starting preference");
// test the value of the preference root
is(Application.prefs.root, "", "Check the Application preference root");
// test for user changed preferences
ok(Application.prefs.get("browser.shell.checkDefaultBrowser").modified, "A single preference is marked as modified.");
ok(!Application.prefs.get(test.string).modified, "A single preference is marked as not modified.");
// test for a locked preference
var pref = Application.prefs.get(test.string);
ok(!pref.locked, "A single preference should not be locked.");
pref.locked = true;
ok(pref.locked, "A single preference should be locked.");
try {
prev.value = "test value";
ok(false, "A locked preference should not be able to be modified.");
} catch(e){
ok(true, "A locked preference should not be able to be modified.");
}
pref.locked = false;
ok(!pref.locked, "A single preference should not be locked.");
// check for change event when setting a value
SimpleTest.waitForExplicitFinish();
Application.prefs.events.addListener("change", onPrefChange);
Application.prefs.setValue("fuel.fuel-test", "change event");
}
function onPrefChange(evt) {
is(evt.data, test.dummy, "Check 'Application.prefs.set' fired a change event");
Application.prefs.events.removeListener("change", onPrefChange);
Application.prefs.get("fuel.fuel-test").events.addListener("change", onPrefChange2);
Application.prefs.setValue("fuel.fuel-test", "change event2");
}
function onPrefChange2(evt) {
is(evt.data, test.dummy, "Check 'Application.prefs.set' fired a change event for a single preference");
Application.prefs.events.removeListener("change", onPrefChange2);
SimpleTest.finish();
}
]]>
</script>
</window>

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

@ -1,53 +0,0 @@
<?xml version="1.0"?>
<?xml-stylesheet href="chrome://global/skin" type="text/css"?>
<?xml-stylesheet href="chrome://mochikit/content/tests/SimpleTest/test.css" type="text/css"?>
<window title="Testing Application Storage"
xmlns="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul"
xmlns:html="http://www.w3.org/1999/xhtml">
<script type="application/javascript" src="chrome://mochikit/content/MochiKit/packed.js"></script>
<script type="application/javascript" src="chrome://mochikit/content/tests/SimpleTest/SimpleTest.js"></script>
<script type="application/javascript" src="chrome://mochikit/content/tests/SimpleTest/EventUtils.js"></script>
<body xmlns="http://www.w3.org/1999/xhtml" />
<script type="application/javascript">
<![CDATA[
test_Storage();
function test_Storage() {
// test for existence of values
var hasItem = Application.storage.has("fuel-test-missing");
is(hasItem, false, "Check 'Application.storage.has' for non-existing item");
Application.storage.set("fuel-test", "dummy");
hasItem = Application.storage.has("fuel-test");
is(hasItem, true, "Check 'Application.storage.has' for existing item");
// test getting non-existing and existing values
var itemValue = Application.storage.get("fuel-test-missing", "default");
is(itemValue, "default", "Check 'Application.storage.get' for non-existing item");
itemValue = Application.storage.get("fuel-test", "default");
is(itemValue, "dummy", "Check 'Application.storage.get' for existing item");
// test for overwriting an existing value
Application.storage.set("fuel-test", "smarty");
itemValue = Application.storage.get("fuel-test", "default");
is(itemValue, "smarty", "Check 'Application.storage.get' for overwritten item");
// check for change event when setting a value
SimpleTest.waitForExplicitFinish();
Application.storage.events.addListener("change", onStorageChange);
Application.storage.set("fuel-test", "change event");
}
function onStorageChange(evt) {
is(evt.data, "fuel-test", "Check 'Application.storage.set' fired a change event");
Application.storage.events.removeListener("change", onStorageChange);
SimpleTest.finish();
}
]]>
</script>
</window>

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

@ -1,136 +0,0 @@
<?xml version="1.0"?>
<?xml-stylesheet href="chrome://global/skin" type="text/css"?>
<?xml-stylesheet href="chrome://mochikit/content/tests/SimpleTest/test.css" type="text/css"?>
<window title="Testing Bookmarks"
xmlns="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul"
xmlns:html="http://www.w3.org/1999/xhtml">
<script type="application/javascript" src="chrome://mochikit/content/MochiKit/packed.js"></script>
<script type="application/javascript" src="chrome://mochikit/content/tests/SimpleTest/SimpleTest.js"></script>
<script type="application/javascript" src="chrome://mochikit/content/tests/SimpleTest/EventUtils.js"></script>
<body xmlns="http://www.w3.org/1999/xhtml" />
<script type="application/javascript">
<![CDATA[
var gLastFolderAction = "";
var gLastBookmarkAction = "";
test_Bookmarks();
function test_Bookmarks() {
var root = Application.bookmarks;
ok(root, "Check access to bookmark root");
ok(!root.parent, "Check root parent (should be null)");
var rootKidCount = root.all.length;
// test adding folders
var testFolder = root.addFolder("FUEL");
ok(testFolder, "Check folder creation");
is(testFolder.type, "folder", "Check 'folder.type' after creation");
ok(testFolder.parent, "Check parent after folder creation");
rootKidCount++;
is(root.all.length, rootKidCount, "Check root folder child count after adding a child folder");
testFolder.events.addListener("change", onFolderChange);
testFolder.description = "FUEL folder";
is(testFolder.description, "FUEL folder", "Check setting 'folder.description'");
is(gLastFolderAction, "bookmarkProperties/description", "Check event handler for setting 'folder.description'");
testFolder.title = "fuel-is-cool";
is(testFolder.title, "fuel-is-cool", "Check setting 'folder.title'");
is(gLastFolderAction, "title", "Check event handler for setting 'folder.title'");
testFolder.annotations.set("testing/folder", "annotate-this", 0);
ok(testFolder.annotations.has("testing/folder"), "Checking existence of added annotation");
is(gLastFolderAction, "testing/folder", "Check event handler for setting annotation");
gLastFolderAction = "";
is(testFolder.annotations.get("testing/folder"), "annotate-this", "Checking existence of added annotation");
testFolder.annotations.remove("testing/folder");
ok(!testFolder.annotations.has("testing/folder"), "Checking existence of removed annotation");
is(gLastFolderAction, "testing/folder", "Check event handler for removing annotation");
testFolder.events.addListener("addchild", onFolderAddChild);
testFolder.events.addListener("removechild", onFolderRemoveChild);
var testBookmark = testFolder.addBookmark("Mozilla", "http://www.mozilla.com/");
ok(testBookmark, "Check bookmark creation");
ok(testBookmark.parent, "Check parent after bookmark creation");
is(gLastFolderAction, "addchild", "Check event handler for adding a child to a folder");
is(testBookmark.type, "bookmark", "Check 'bookmark.type' after creation");
is(testBookmark.title, "Mozilla", "Check 'bookmark.title' after creation");
is(testBookmark.uri, "http://www.mozilla.com/", "Check 'bookmark.uri' after creation");
is(testFolder.all.length, 1, "Check test folder child count after adding a child bookmark");
testBookmark.events.addListener("change", onBookmarkChange);
testBookmark.description = "mozcorp";
is(testBookmark.description, "mozcorp", "Check setting 'bookmark.description'");
is(gLastBookmarkAction, "bookmarkProperties/description", "Check event handler for setting 'bookmark.description'");
testBookmark.keyword = "moz"
is(testBookmark.keyword, "moz", "Check setting 'bookmark.keyword'");
is(gLastBookmarkAction, "keyword", "Check event handler for setting 'bookmark.keyword'");
testBookmark.title = "MozCorp"
is(testBookmark.title, "MozCorp", "Check setting 'bookmark.title'");
is(gLastBookmarkAction, "title", "Check event handler for setting 'bookmark.title'");
testBookmark.uri = "http://www.mozilla.org/"
is(testBookmark.uri, "http://www.mozilla.org/", "Check setting 'bookmark.uri'");
is(gLastBookmarkAction, "uri", "Check event handler for setting 'bookmark.uri'");
testBookmark.annotations.set("testing/bookmark", "annotate-this", 0);
ok(testBookmark.annotations.has("testing/bookmark"), "Checking existence of added annotation");
is(gLastBookmarkAction, "testing/bookmark", "Check event handler for setting annotation");
gLastBookmarkAction = "";
is(testBookmark.annotations.get("testing/bookmark"), "annotate-this", "Checking existence of added annotation");
testBookmark.annotations.remove("testing/bookmark");
ok(!testBookmark.annotations.has("testing/bookmark"), "Checking existence of removed annotation");
is(gLastBookmarkAction, "testing/bookmark", "Check event handler for removing annotation");
testBookmark.events.addListener("remove", onBookmarkRemove);
testBookmark.remove();
is(gLastBookmarkAction, "remove", "Check event handler for removing bookmark");
is(gLastFolderAction, "removechild", "Check event handler for removing a child from a folder");
is(testFolder.all.length, 0, "Check test folder child count after removing a child bookmark");
testFolder.events.addListener("remove", onFolderRemove);
testFolder.remove();
is(gLastFolderAction, "remove", "Check event handler for removing child folder");
rootKidCount--;
is(root.all.length, rootKidCount, "Check root folder child count after removing a child folder");
}
function onFolderChange(evt) {
gLastFolderAction = evt.data;
}
function onFolderRemove(evt) {
gLastFolderAction = evt.type;
}
function onFolderAddChild(evt) {
gLastFolderAction = evt.type;
}
function onFolderRemoveChild(evt) {
gLastFolderAction = evt.type;
}
function onBookmarkChange(evt) {
gLastBookmarkAction = evt.data;
}
function onBookmarkRemove(evt) {
gLastBookmarkAction = evt.type;
}
]]>
</script>
</window>

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

@ -1,43 +0,0 @@
<?xml version="1.0"?>
<?xml-stylesheet href="chrome://global/skin" type="text/css"?>
<?xml-stylesheet href="chrome://mochikit/content/tests/SimpleTest/test.css" type="text/css"?>
<window title="Testing Browser"
xmlns="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul"
xmlns:html="http://www.w3.org/1999/xhtml">
<script type="application/javascript" src="chrome://mochikit/content/MochiKit/packed.js"></script>
<script type="application/javascript" src="chrome://mochikit/content/tests/SimpleTest/SimpleTest.js"></script>
<script type="application/javascript" src="chrome://mochikit/content/tests/SimpleTest/EventUtils.js"></script>
<body xmlns="http://www.w3.org/1999/xhtml" />
<script type="application/javascript">
<![CDATA[
test_Browser();
function test_Browser() {
var browsers = Application.browsers;
ok(browsers, "Check access to browser windows");
ok(browsers.length, "There should be at least one browser window open");
var activeBrowser = Application.activeBrowser;
var moz = activeBrowser.open("http://mozilla.org/");
var goog = activeBrowser.open("http://google.com/");
goog.focus();
is(activeBrowser.tabs.length, 3, "Checking length of 'Browser.tabs' after opening 2 additional tabs");
is(activeBrowser.activeTab.index, goog.index, "Checking 'Browser.activeTab' after setting focus");
// need to wait for the url's to be refreshed during the load
function checkURL() {
is(moz.url, "http://mozilla.org/", "Checking 'BrowserTab.url' after opening");
is(goog.url, "http://google.com/", "Checking 'BrowserTab.url' after opening");
}
setTimeout(checkURL, 50);
}
]]>
</script>
</window>

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

@ -1,54 +0,0 @@
<?xml version="1.0"?>
<?xml-stylesheet href="chrome://global/skin" type="text/css"?>
<?xml-stylesheet href="chrome://mochikit/content/tests/SimpleTest/test.css" type="text/css"?>
<window title="Testing Extensions"
xmlns="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul"
xmlns:html="http://www.w3.org/1999/xhtml">
<script type="application/javascript" src="chrome://mochikit/content/MochiKit/packed.js"></script>
<script type="application/javascript" src="chrome://mochikit/content/tests/SimpleTest/SimpleTest.js"></script>
<script type="application/javascript" src="chrome://mochikit/content/tests/SimpleTest/EventUtils.js"></script>
<body xmlns="http://www.w3.org/1999/xhtml" />
<script type="application/javascript">
<![CDATA[
// The various pieces that we'll be testing
var test = {
dummyid: "fuel-dummy-extension@mozilla.org",
dummyname: "Dummy Extension",
inspectorid: "inspector@mozilla.org",
inspectorname: "DOM Inspector"
};
test_Extensions();
function test_Extensions() {
// test to see if a non-existant extension exists
ok(!Application.extensions.has(test.dummyid), "Check non-existant extension for existance");
// test to see if an extension exists
ok(Application.extensions.has(test.inspectorid), "Check extension for existance");
var inspector = Application.extensions.get(test.inspectorid);
is(inspector.id, test.inspectorid, "Check 'Extension.id' for known extension");
is(inspector.name, test.inspectorname, "Check 'Extension.name' for known extension");
// The known version number changes too frequently to hardcode in
ok(inspector.version, "Check 'Extension.version' for known extension");
ok(inspector.firstRun, "Check 'Extension.firstRun' for known extension");
// test to see if extension find works
is(Application.extensions.all.length, 1, "Check a find for all extensions");
// test the value of the preference root
is(Application.extensions.all[0].prefs.root, "extensions.inspector@mozilla.org.", "Check an extension preference root");
// Reset the install event preference, so that we can test it again later
inspector.prefs.get("install-event-fired").reset();
}
]]>
</script>
</window>