102 lines
3.3 KiB
XML
102 lines
3.3 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=393716
|
|
-->
|
|
<window title="Mozilla Bug 393716"
|
|
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 393716</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=393716">Mozilla Bug 393716</a>
|
|
|
|
<p id="display"></p>
|
|
|
|
<pre id="test">
|
|
<script class="testbody" type="application/javascript">
|
|
<![CDATA[
|
|
|
|
const Cc = Components.classes;
|
|
const Ci = Components.interfaces;
|
|
|
|
// set up the basics (SessionStore service, tabbrowser)
|
|
try {
|
|
var ss = Cc["@mozilla.org/browser/sessionstore;1"].getService(Ci.nsISessionStore);
|
|
} catch (ex) {
|
|
ok(false, "SessionStore service available?");
|
|
}
|
|
try {
|
|
var windowEnumerator = Cc["@mozilla.org/appshell/window-mediator;1"].
|
|
getService(Ci.nsIWindowMediator).
|
|
getEnumerator("navigator:browser");
|
|
var currentWindow = windowEnumerator.getNext();
|
|
var tabbrowser = currentWindow.getBrowser();
|
|
} catch (ex) {
|
|
ok(false, "tabbrowser available?");
|
|
}
|
|
|
|
/**************
|
|
* getTabState
|
|
**************/
|
|
var key = "key1", value = "value1";
|
|
|
|
// create a new tab
|
|
var newTab = tabbrowser.addTab();
|
|
ss.setTabValue(newTab, key, value);
|
|
|
|
// get the tab's state
|
|
var state = ss.getTabState(newTab);
|
|
ok(state, "Able to get the tab's state?");
|
|
|
|
// verify the tab state's integrity
|
|
state = eval("(" + state + ")");
|
|
ok(state instanceof Object && state.entries instanceof Array && state.entries.length > 0,
|
|
"Got a valid state object?");
|
|
ok(state.entries.length == 1 && state.entries[0].url == "about:blank",
|
|
"Got the expected state object (test URL)?");
|
|
ok(state.extData && state.extData[key] == value,
|
|
"Got the expected state object (test manually set tab value)?");
|
|
|
|
// clean up
|
|
tabbrowser.removeTab(newTab);
|
|
|
|
/*****************************
|
|
* setTabState / duplicateTab
|
|
*****************************/
|
|
key = "key2";
|
|
value = "value2";
|
|
state = { entries: [{ url: "about:blank" }], extData: { key2: value } };
|
|
|
|
// create a new tab
|
|
newTab = tabbrowser.addTab();
|
|
|
|
// set the tab's state
|
|
ss.setTabState(newTab, state.toSource());
|
|
|
|
// verify the correctness of the restored tab
|
|
ok(ss.getTabValue(newTab, key) == value, "Correctly restored the tab's state?");
|
|
|
|
// duplicate the tab
|
|
var duplicateTab = ss.duplicateTab(currentWindow, newTab);
|
|
|
|
// verify the correctness of the duplicated tab
|
|
ok(ss.getTabValue(duplicateTab, key) == value, "Correctly duplicated the tab's state?");
|
|
|
|
// clean up
|
|
tabbrowser.removeTab(newTab);
|
|
tabbrowser.removeTab(duplicateTab);
|
|
|
|
]]>
|
|
</script>
|
|
</pre>
|
|
</body>
|
|
|
|
</window>
|