Bug 551285 - Drop backwards compatibility for Firefox 2/3 [r=zeniko]

This commit is contained in:
Paul O’Shannessy 2010-03-15 10:51:10 -07:00
Родитель 669c5430f9
Коммит 2dd161f3c9
1 изменённых файлов: 5 добавлений и 60 удалений

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

@ -2113,14 +2113,6 @@ SessionStoreService.prototype = {
Array.filter(tab.attributes, function(aAttr) {
return (_this.xulAttributes.indexOf(aAttr.name) > -1);
}).forEach(tab.removeAttribute, tab);
if (tabData.xultab) {
// restore attributes from the legacy Firefox 2.0/3.0 format
tabData.xultab.split(" ").forEach(function(aAttr) {
if (/^([^\s=]+)=(.*)/.test(aAttr)) {
tab.setAttribute(RegExp.$1, decodeURI(RegExp.$2));
}
});
}
for (let name in tabData.attributes)
tab.setAttribute(name, tabData.attributes[name]);
@ -2149,7 +2141,6 @@ SessionStoreService.prototype = {
// which are not preserved in the plain history entries
// (mainly scroll state and text data)
browser.__SS_restore_data = tabData.entries[activeIndex] || {};
browser.__SS_restore_text = tabData.text || "";
browser.__SS_restore_pageStyle = tabData.pageStyle || "";
browser.__SS_restore_tab = tab;
browser.__SS_restore = this.restoreDocument_proxy;
@ -2222,14 +2213,8 @@ SessionStoreService.prototype = {
shEntry.setScrollPosition(scrollPos[0], scrollPos[1]);
}
var postdata;
if (aEntry.postdata_b64) { // Firefox 3
postdata = atob(aEntry.postdata_b64);
} else if (aEntry.postdata) { // Firefox 2
postdata = aEntry.postdata;
}
if (postdata) {
if (aEntry.postdata_b64) {
var postdata = atob(aEntry.postdata_b64);
var stream = Cc["@mozilla.org/io/string-input-stream;1"].
createInstance(Ci.nsIStringInputStream);
stream.setData(postdata, postdata.length);
@ -2258,7 +2243,7 @@ SessionStoreService.prototype = {
}
}
if (aEntry.owner_b64) { // Firefox 3
if (aEntry.owner_b64) {
var ownerInput = Cc["@mozilla.org/io/string-input-stream;1"].
createInstance(Ci.nsIStringInputStream);
var binaryData = atob(aEntry.owner_b64);
@ -2269,11 +2254,8 @@ SessionStoreService.prototype = {
try { // Catch possible deserialization exceptions
shEntry.owner = binaryStream.readObject(true);
} catch (ex) { debug(ex); }
} else if (aEntry.ownerURI) { // Firefox 2
var uriObj = IOSvc.newURI(aEntry.ownerURI, null, null);
shEntry.owner = SecuritySvc.getCodebasePrincipal(uriObj);
}
if (aEntry.children && shEntry instanceof Ci.nsISHContainer) {
for (var i = 0; i < aEntry.children.length; i++) {
//XXXzpao Wallpaper patch for bug 514751
@ -2320,25 +2302,6 @@ SessionStoreService.prototype = {
function hasExpectedURL(aDocument, aURL)
!aURL || aURL.replace(/#.*/, "") == aDocument.location.href.replace(/#.*/, "");
// restore text data saved by Firefox 2.0/3.0
var textArray = this.__SS_restore_text ? this.__SS_restore_text.split(" ") : [];
function restoreTextData(aContent, aPrefix, aURL) {
textArray.forEach(function(aEntry) {
if (/^((?:\d+\|)*)(#?)([^\s=]+)=(.*)$/.test(aEntry) &&
RegExp.$1 == aPrefix && hasExpectedURL(aContent.document, aURL)) {
var document = aContent.document;
var node = RegExp.$2 ? document.getElementById(RegExp.$3) : document.getElementsByName(RegExp.$3)[0] || null;
if (node && "value" in node && node.type != "file") {
node.value = decodeURI(RegExp.$4);
var event = document.createEvent("UIEvents");
event.initUIEvent("input", true, true, aContent, 0);
node.dispatchEvent(event);
}
}
});
}
function restoreFormData(aDocument, aData, aURL) {
for (let key in aData) {
if (!hasExpectedURL(aDocument, aURL))
@ -2382,8 +2345,6 @@ SessionStoreService.prototype = {
function restoreTextDataAndScrolling(aContent, aData, aPrefix) {
if (aData.formdata)
restoreFormData(aContent.document, aData.formdata, aData.url);
else
restoreTextData(aContent, aPrefix, aData.url);
if (aData.innerHTML) {
window.setTimeout(function() {
if (aContent.document.designMode == "on" &&
@ -2426,7 +2387,6 @@ SessionStoreService.prototype = {
this.removeEventListener("load", this.__SS_restore, true);
delete this.__SS_restore_data;
delete this.__SS_restore_text;
delete this.__SS_restore_pageStyle;
delete this.__SS_restore_tab;
delete this.__SS_restore;
@ -2523,26 +2483,11 @@ SessionStoreService.prototype = {
},
/**
* Restores cookies (accepting both Firefox 2.0 and current format)
* Restores cookies
* @param aCookies
* Array of cookie objects
*/
restoreCookies: function sss_restoreCookies(aCookies) {
if (aCookies.count && aCookies.domain1) {
// convert to the new cookie serialization format
var converted = [];
for (var i = 1; i <= aCookies.count; i++) {
// for simplicity we only accept the format we produced ourselves
var parsed = aCookies["value" + i].match(/^([^=;]+)=([^;]*);(?:domain=[^;]+;)?(?:path=([^;]*);)?(secure;)?(httponly;)?/);
if (parsed && /^https?:\/\/([^\/]+)/.test(aCookies["domain" + i]))
converted.push({
host: RegExp.$1, path: parsed[3], name: parsed[1], value: parsed[2],
secure: parsed[4], httponly: parsed[5]
});
}
aCookies = converted;
}
// MAX_EXPIRY should be 2^63-1, but JavaScript can't handle that precision
var MAX_EXPIRY = Math.pow(2, 62);
for (i = 0; i < aCookies.length; i++) {