[Pkg-mozext-commits] [tabmixplus] 102/147: Follow up bug 1307736 - Store triggeringPrincipal with all history entries
David Prévot
taffit at moszumanska.debian.org
Sat Aug 5 15:27:41 UTC 2017
This is an automated email from the git hooks/post-receive script.
taffit pushed a commit to branch master
in repository tabmixplus.
commit a8c6b06eaf6c7645f2e3f72b15fb8d0f698b1430
Author: onemen <tabmix.onemen at gmail.com>
Date: Sun Jan 29 15:45:43 2017 +0200
Follow up bug 1307736 - Store triggeringPrincipal with all history entries
---
chrome/content/minit/tablib.js | 4 ++++
chrome/content/places/places.js | 7 ++++++-
chrome/content/session/session.js | 24 +++++++++++-------------
chrome/content/session/sessionStore.js | 28 +++++++++++++++++++++++++---
modules/TabmixSvc.jsm | 7 +++++++
5 files changed, 53 insertions(+), 17 deletions(-)
diff --git a/chrome/content/minit/tablib.js b/chrome/content/minit/tablib.js
index 275a549..7dbaba4 100644
--- a/chrome/content/minit/tablib.js
+++ b/chrome/content/minit/tablib.js
@@ -1012,6 +1012,10 @@ var tablib = { // eslint-disable-line
var activeIndex = (tabState.index || tabState.entries.length) - 1;
var entriesToRemove = 0;
var newEntry = {url: aHref}; // we don't know the page title at this moment
+ let triggeringPrincipal = TabmixSvc.SERIALIZED_SYSTEMPRINCIPAL;
+ if (triggeringPrincipal) {
+ newEntry.triggeringPrincipal_base64 = triggeringPrincipal;
+ }
tabState.entries.splice(activeIndex + 1, entriesToRemove, newEntry);
tabState.index++;
} catch (ex) {
diff --git a/chrome/content/places/places.js b/chrome/content/places/places.js
index 0cf79a3..f7f9af9 100644
--- a/chrome/content/places/places.js
+++ b/chrome/content/places/places.js
@@ -281,6 +281,7 @@ var TMP_Places = {
var tabPos, index;
var multiple = bmGroup.length > 1;
let tabs = [], tabsData = [];
+ let savePrincipal = TabmixSvc.SERIALIZED_SYSTEMPRINCIPAL;
for (i = 0; i < bmGroup.length; i++) {
let url = bmGroup[i];
if (i < reuseTabs.length) {
@@ -310,7 +311,11 @@ var TMP_Places = {
this.setTabTitle(aTab, url, bmIds[i]);
if (loadProgressively) {
tabs.push(aTab);
- tabsData.push({entries: [{url, title: aTab.label}], index: 0});
+ let entry = {url, title: aTab.label};
+ if (savePrincipal) {
+ entry.triggeringPrincipal_base64 = TabmixSvc.SERIALIZED_SYSTEMPRINCIPAL;
+ }
+ tabsData.push({entries: [entry], index: 0});
}
if (!tabToSelect)
diff --git a/chrome/content/session/session.js b/chrome/content/session/session.js
index f0fd575..c1ea289 100644
--- a/chrome/content/session/session.js
+++ b/chrome/content/session/session.js
@@ -2963,7 +2963,7 @@ TabmixSessionManager = {
}
this.setLiteral(aNode, "image", aData.image || "");
this.setLiteral(aNode, "properties", aData.properties);
- this.setLiteral(aNode, "history", aData.history);
+ this.setLiteral(aNode, "historyData", aData.history);
this.setLiteral(aNode, "scroll", aData.scroll);
if (aData.closedAt)
this.setLiteral(aNode, "closedAt", aData.closedAt);
@@ -3000,23 +3000,21 @@ TabmixSessionManager = {
for (let j = historyStart; j < historyEnd; j++) {
try {
let historyEntry = entries[j];
- history.push(historyEntry.title || "");
- history.push(historyEntry.url);
- history.push(saveScroll && historyEntry.scroll || "0,0");
+ let entry = {
+ url: historyEntry.url,
+ title: historyEntry.title || "",
+ scroll: saveScroll && historyEntry.scroll || "0,0",
+ };
+ if (historyEntry.triggeringPrincipal_base64) {
+ entry.triggeringPrincipal_base64 = historyEntry.triggeringPrincipal_base64;
+ }
+ history.push(entry);
} catch (ex) {
Tabmix.assert(ex, "serializeHistory error at index " + j);
}
}
- // generate unique separator and combine the array to one string
- var separator = "][", extraSeparator = "@";
- for (var i = 0; i < history.length; ++i) {
- while (history[i].indexOf(separator) > -1)
- separator += extraSeparator;
- }
return {
- // insert the separator to history so we can extract it in
- // TabmixConvertSession.getHistoryState
- history: separator + "|-|" + encodeURI(history.join(separator)),
+ history: encodeURI(JSON.stringify(history)),
index,
scroll: currentScroll
};
diff --git a/chrome/content/session/sessionStore.js b/chrome/content/session/sessionStore.js
index 83d70c7..b7dfe36 100644
--- a/chrome/content/session/sessionStore.js
+++ b/chrome/content/session/sessionStore.js
@@ -861,9 +861,11 @@ var TabmixConvertSession = {
getTabState: function cs_getTabState(rdfNodeTab, aClosedTab, internal) {
var tabData = {entries: [], index: 0, zoom: 1, disallow: "", text: ""};
- tabData.entries = this.getHistoryState(rdfNodeTab);
- if (!tabData.entries.length)
+ const entries = this.getHistoryState(rdfNodeTab);
+ if (!entries.length) {
return null;
+ }
+ tabData.entries = this.addTriggeringPrincipal(entries);
tabData.image = TabmixSessionManager.getLiteralValue(rdfNodeTab, "image", null);
let index = TabmixSessionManager.getIntValue(rdfNodeTab, "index");
tabData.index = Math.max(1, Math.min(index + 1, tabData.entries.length));
@@ -963,6 +965,13 @@ var TabmixConvertSession = {
},
getHistoryState: function cs_getHistoryState(rdfNodeTab) {
+ // starting with version 0.5.0.3 history data serialized with JSON.stringify
+ let isJSONData = TabmixSessionManager.nodeHasArc(rdfNodeTab, "historyData");
+ if (isJSONData) {
+ const state = TabmixSessionManager.getLiteralValue(rdfNodeTab, "historyData");
+ return JSON.parse(decodeURI(state));
+ }
+
let decodeData = function(data, decode) {
return decode ? TabmixSessionManager.getDecodedLiteralValue(null, data) : data;
};
@@ -989,5 +998,18 @@ var TabmixConvertSession = {
}
}
return entries;
- }
+ },
+
+ // add triggeringPrincipal to history entries that was saved before Firefox 54 (Bug 1307736)
+ addTriggeringPrincipal(entries) {
+ if (!TabmixSvc.SERIALIZED_SYSTEMPRINCIPAL) {
+ return entries;
+ }
+ return entries.map(entry => {
+ if (!entry.triggeringPrincipal_base64) {
+ entry.triggeringPrincipal_base64 = TabmixSvc.SERIALIZED_SYSTEMPRINCIPAL;
+ }
+ return entry;
+ });
+ },
};
diff --git a/modules/TabmixSvc.jsm b/modules/TabmixSvc.jsm
index c36f4b2..8d5aeec 100644
--- a/modules/TabmixSvc.jsm
+++ b/modules/TabmixSvc.jsm
@@ -365,6 +365,13 @@ XPCOMUtils.defineLazyGetter(TabmixSvc, "SessionStore", function() {
return this.SessionStoreGlobal.SessionStoreInternal;
});
+// Firefox 54
+// Bug 1307736 - Assert history loads pass a valid triggeringPrincipal for docshell loads
+XPCOMUtils.defineLazyGetter(TabmixSvc, "SERIALIZED_SYSTEMPRINCIPAL", function() {
+ return this.SessionStoreGlobal.Utils &&
+ this.SessionStoreGlobal.Utils.SERIALIZED_SYSTEMPRINCIPAL || null;
+});
+
tabStateCache = {
saveTabAttributes(tab, attrib, save = true) {
if (TabmixSvc.isPaleMoon) {
--
Alioth's /usr/local/bin/git-commit-notice on /srv/git.debian.org/git/pkg-mozext/tabmixplus.git
More information about the Pkg-mozext-commits
mailing list