Backed out changeset 9d9e289013de (bug 899213) due to various regressions caused by it.

This commit is contained in:
Ryan VanderMeulen 2013-09-05 15:39:56 -04:00
parent cdfb28768d
commit c4745b3b08
5 changed files with 15 additions and 135 deletions

View File

@ -25,7 +25,7 @@ interface nsIDOMNode;
* |gBrowser.tabContainer| such as e.g. |gBrowser.selectedTab|.
*/
[scriptable, uuid(7ffd8bfa-0a8f-11e3-b1c0-1e3faed8a8ba)]
[scriptable, uuid(700756cc-f5c7-11e2-b842-59d9dc830245)]
interface nsISessionStore : nsISupports
{
/**
@ -208,25 +208,6 @@ interface nsISessionStore : nsISupports
*/
void deleteTabValue(in nsIDOMNode aTab, in AString aKey);
/**
* @param aKey is the value's name.
*
* @returns A string value or an empty string if none is set.
*/
AString getGlobalValue(in AString aKey);
/**
* @param aKey is the value's name.
* @param aStringValue is the value itself (use JSON.stringify/parse before setting JS objects).
*/
void setGlobalValue(in AString aKey, in AString aStringValue);
/**
* @param aTab is the browser tab to get the value for.
* @param aKey is the value's name.
*/
void deleteGlobalValue(in AString aKey);
/**
* @param aName is the name of the attribute to save/restore for all tabbrowser tabs.
*/

View File

@ -256,18 +256,6 @@ this.SessionStore = {
SessionStoreInternal.deleteTabValue(aTab, aKey);
},
getGlobalValue: function ss_getGlobalValue(aKey) {
return SessionStoreInternal.getGlobalValue(aKey);
},
setGlobalValue: function ss_setGlobalValue(aKey, aStringValue) {
SessionStoreInternal.setGlobalValue(aKey, aStringValue);
},
deleteGlobalValue: function ss_deleteGlobalValue(aKey) {
SessionStoreInternal.deleteGlobalValue(aKey);
},
persistTabAttribute: function ss_persistTabAttribute(aName) {
SessionStoreInternal.persistTabAttribute(aName);
},
@ -326,9 +314,6 @@ let SessionStoreInternal = {
// states for all recently closed windows
_closedWindows: [],
// state saved globally for a session
_globalValues: {},
// collection of session states yet to be restored
_statesToRestore: {},
@ -1716,20 +1701,6 @@ let SessionStoreInternal = {
this.saveStateDelayed(aTab.ownerDocument.defaultView);
},
getGlobalValue: function ssi_getGlobalValue(aKey) {
return this._globalValues[aKey] || "";
},
setGlobalValue: function ssi_setGlobalValue(aKey, aStringValue) {
this._globalValues[aKey] = aStringValue;
this.saveStateDelayed();
},
deleteGlobalValue: function ssi_deleteGlobalValue(aKey) {
delete this._globalValues[aKey];
this.saveStateDelayed();
},
persistTabAttribute: function ssi_persistTabAttribute(aName) {
if (TabAttributes.persist(aName)) {
TabStateCache.clear();
@ -1824,8 +1795,9 @@ let SessionStoreInternal = {
this._capClosedWindows();
}
this._setGlobalValuesFromState(aState);
this._restoreScratchPads();
if (lastSessionState.scratchpads) {
ScratchpadManager.restoreSession(lastSessionState.scratchpads);
}
// Set data that persists between sessions
this._recentCrashes = lastSessionState.session &&
@ -1837,26 +1809,6 @@ let SessionStoreInternal = {
this._lastSessionState = null;
},
_setGlobalValuesFromState: function ssi_setGlobalValuesFromState(aState) {
if (aState && aState.global) {
this._globalValues = aState.global;
}
},
_restoreScratchPads: function ssi_restoreScratchPads() {
let scratchpads;
try {
scratchpads = JSON.parse(this.getGlobalValue('scratchpads'));
} catch (ex) {
// Ignore any errors when attempting to decode the scratchpads.
Cu.reportError(ex);
}
if (scratchpads) {
ScratchpadManager.restoreSession(scratchpads);
}
},
/**
* See if aWindow is usable for use when restoring a previous session via
* restoreLastSession. If usable, prepare it for use.
@ -2487,14 +2439,14 @@ let SessionStoreInternal = {
};
// get open Scratchpad window states too
this.setGlobalValue('scratchpads', JSON.stringify(ScratchpadManager.getSessionState()));
var scratchpads = ScratchpadManager.getSessionState();
let state = {
windows: total,
selectedWindow: ix + 1,
_closedWindows: lastClosedWindowsCopy,
session: session,
global: this._globalValues
scratchpads: scratchpads
};
// Persist the last session if we deferred restoring it
@ -2738,8 +2690,9 @@ let SessionStoreInternal = {
this.restoreHistoryPrecursor(aWindow, tabs, winData.tabs,
(overwriteTabs ? (parseInt(winData.selected) || 1) : 0), 0, 0);
this._setGlobalValuesFromState(aState);
this._restoreScratchPads();
if (aState.scratchpads) {
ScratchpadManager.restoreSession(aState.scratchpads);
}
// set smoothScroll back to the original value
tabstrip.smoothScroll = smoothScroll;

View File

@ -16,7 +16,6 @@ MOCHITEST_BROWSER_FILES = \
browser_form_restore_events_sample.html \
browser_formdata_format.js \
browser_formdata_format_sample.html \
browser_global_store.js \
browser_input.js \
browser_input_sample.html \
browser_pageshow.js \

View File

@ -1,20 +1,16 @@
/* Any copyright is dedicated to the Public Domain.
http://creativecommons.org/publicdomain/zero/1.0/ */
const scratchpads = [
{ text: "text1", executionContext: 1 },
{ text: "", executionContext: 2, filename: "test.js" }
];
const testState = {
windows: [{
tabs: [
{ entries: [{ url: "about:blank" }] },
]
}],
global: {
scratchpads: JSON.stringify(scratchpads)
}
scratchpads: [
{ text: "text1", executionContext: 1 },
{ text: "", executionContext: 2, filename: "test.js" }
]
};
// only finish() when correct number of windows opened
@ -22,8 +18,8 @@ var restored = [];
function addState(state) {
restored.push(state);
if (restored.length == scratchpads.length) {
ok(statesMatch(restored, scratchpads),
if (restored.length == testState.scratchpads.length) {
ok(statesMatch(restored, testState.scratchpads),
"Two scratchpad windows restored");
Services.ww.unregisterNotification(windowObserver);

View File

@ -1,49 +0,0 @@
/* Any copyright is dedicated to the Public Domain.
http://creativecommons.org/publicdomain/zero/1.0/ */
// Tests the API for saving global session data.
function runTests() {
const key1 = "Unique name 1: " + Date.now();
const key2 = "Unique name 2: " + Date.now();
const value1 = "Unique value 1: " + Math.random();
const value2 = "Unique value 2: " + Math.random();
let global = {};
global[key1] = value1;
const testState = {
windows: [
{
tabs: [
{ entries: [{ url: "about:blank" }] },
]
}
],
global: global
};
function testRestoredState() {
is(ss.getGlobalValue(key1), value1, "restored state has global value");
}
function testGlobalStore() {
is(ss.getGlobalValue(key2), "", "global value initially not set");
ss.setGlobalValue(key2, value1);
is(ss.getGlobalValue(key2), value1, "retreived value matches stored");
ss.setGlobalValue(key2, value2);
is(ss.getGlobalValue(key2), value2, "previously stored value was overwritten");
ss.deleteGlobalValue(key2);
is(ss.getGlobalValue(key2), "", "global value was deleted");
}
yield waitForBrowserState(testState, next);
testRestoredState();
testGlobalStore();
}
function test() {
TestRunner.run();
}