133 lines
4.1 KiB
XML
133 lines
4.1 KiB
XML
<?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"?>
|
|
<!--
|
|
https://bugzilla.mozilla.org/show_bug.cgi?id=350525
|
|
-->
|
|
<window title="Mozilla Bug 350525"
|
|
xmlns:html="http://www.w3.org/1999/xhtml"
|
|
xmlns="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul"
|
|
xmlns:xul="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul">
|
|
|
|
<title>Test for Bug 350525</title>
|
|
<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>
|
|
<body xmlns="http://www.w3.org/1999/xhtml">
|
|
<a target="_blank" href="https://bugzilla.mozilla.org/show_bug.cgi?id=350525">Mozilla Bug 350525</a>
|
|
|
|
<p id="display"></p>
|
|
|
|
<pre id="test">
|
|
<script class="testbody" type="application/javascript">
|
|
|
|
/** Test for Bug 350525 **/
|
|
|
|
const Cc = Components.classes;
|
|
const Ci = Components.interfaces;
|
|
const Cr = Components.results;
|
|
|
|
// component
|
|
try {
|
|
Cc["@mozilla.org/browser/sessionstore;1"];
|
|
ok(1==1, "Able to reference the sessionstore component?");
|
|
} catch(ex) {
|
|
alert(ex);
|
|
ok(1==2, "Able to reference the sessionstore component?");
|
|
}
|
|
|
|
// service
|
|
try {
|
|
var ss = Cc["@mozilla.org/browser/sessionstore;1"].getService(Ci.nsISessionStore);
|
|
ok(true, "Able to reference the sessionstore service?");
|
|
} catch(ex) {
|
|
ok(false, "Able to reference the sessionstore service?");
|
|
}
|
|
|
|
// get current window, tabbrowser
|
|
var wm = Cc["@mozilla.org/appshell/window-mediator;1"].getService(Ci.nsIWindowMediator);
|
|
var windowEnumerator = wm.getEnumerator("navigator:browser");
|
|
var currentWindow = windowEnumerator.getNext();
|
|
var tabbrowser = currentWindow.getBrowser();
|
|
|
|
/*****************
|
|
undoCloseTab, getClosedTabCount
|
|
*****************/
|
|
|
|
// get closed tab count
|
|
var count = ss.getClosedTabCount(currentWindow);
|
|
ok(count > -1, "getClosedTabCount returns zero or more?");
|
|
|
|
// create a new tab
|
|
var newTab = tabbrowser.addTab("http://www.mozilla.org");
|
|
|
|
// remove tab
|
|
tabbrowser.removeTab(newTab);
|
|
|
|
// getClosedTabCount
|
|
var newcount = ss.getClosedTabCount(currentWindow);
|
|
todo(newcount > count, "After closing a tab, getClosedTabCount has been incremented? " + newcount + " > " + count);
|
|
|
|
// undoCloseTab
|
|
var undid = ss.undoCloseTab(currentWindow, null);
|
|
ok(undid != -1, "undoCloseTab throws?");
|
|
|
|
// clean up
|
|
tabbrowser.removeAllTabsBut(tabbrowser.selectedTab);
|
|
|
|
/*****************
|
|
setWindowValue
|
|
*****************/
|
|
var key = "key1";
|
|
var value = "value1";
|
|
|
|
// create a new tab
|
|
var newTab = tabbrowser.addTab("http://www.mozilla.org");
|
|
|
|
// test adding
|
|
ok(ss.setWindowValue(currentWindow, key, value) != -1, "Able to set a window value?");
|
|
|
|
// test retrieving
|
|
var storedValue = ss.getWindowValue(currentWindow, key);
|
|
is(value, storedValue, "Stored window value matches original?");
|
|
|
|
// test deleting
|
|
ok(ss.deleteWindowValue(currentWindow, key) != -1, "Delete window value?");
|
|
|
|
// value should not exist post-delete
|
|
is(ss.getWindowValue(currentWindow, key), "", "Fetching deleted window value fails?");
|
|
|
|
// clean up
|
|
tabbrowser.removeTab(newTab);
|
|
|
|
/*********************
|
|
tabValues
|
|
*********************/
|
|
key = "key1";
|
|
value = "value1";
|
|
|
|
// create a new tab
|
|
newTab = tabbrowser.addTab("http://www.mozilla.org");
|
|
|
|
// test adding
|
|
ok(ss.setTabValue(newTab, key, value) != -1, "Able to store a tab value?");
|
|
|
|
// test retrieving
|
|
var storedValue = ss.getTabValue(newTab, key);
|
|
ok(value==storedValue, "Stored tab value match original?");
|
|
|
|
// test deleting
|
|
ok(ss.deleteTabValue(newTab, key) != -1, "Able to delete a tab value?");
|
|
// value should not exist post-delete
|
|
ok(ss.getTabValue(newTab, key) == "", "Unable to retrieve deleted tab value?");
|
|
|
|
// clean up
|
|
tabbrowser.removeTab(newTab);
|
|
|
|
</script>
|
|
</pre>
|
|
</body>
|
|
|
|
</window>
|