Bug 1456391 - Part 8: Use mapFrameTree in Fennec. r=esawin

This brings us in line with Desktop's session store, in that we can now collect
data for arbitrarily nested frame structures.

At the same time, this also means that we no longer collect data for dynamically
added frames, so the corresponding mochitest needs to be adapted accordingly.

MozReview-Commit-ID: DfJ3C2ccUne

--HG--
extra : rebase_source : bbb2181d5596d21254d2f7394c1383a3979dcef4
This commit is contained in:
Jan Henning 2018-04-25 22:21:41 +02:00
Родитель 2b764766f6
Коммит 5ec5f23aab
2 изменённых файлов: 11 добавлений и 55 удалений

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

@ -11,13 +11,14 @@ XPCOMUtils.defineLazyModuleGetters(this, {
EventDispatcher: "resource://gre/modules/Messaging.jsm",
FormData: "resource://gre/modules/FormData.jsm",
OS: "resource://gre/modules/osfile.jsm",
PrivacyLevel: "resource://gre/modules/sessionstore/PrivacyLevel.jsm",
PrivacyFilter: "resource://gre/modules/sessionstore/PrivacyFilter.jsm",
PrivateBrowsingUtils: "resource://gre/modules/PrivateBrowsingUtils.jsm",
ScrollPosition: "resource://gre/modules/ScrollPosition.jsm",
SessionHistory: "resource://gre/modules/sessionstore/SessionHistory.jsm",
SharedPreferences: "resource://gre/modules/SharedPreferences.jsm",
Task: "resource://gre/modules/Task.jsm",
TelemetryStopwatch: "resource://gre/modules/TelemetryStopwatch.jsm",
Utils: "resource://gre/modules/sessionstore/Utils.jsm",
});
XPCOMUtils.defineLazyModuleGetter(this, "Log", "resource://gre/modules/AndroidLog.jsm", "AndroidLog");
@ -890,41 +891,13 @@ SessionStore.prototype = {
return;
}
// Start with storing the main content
// Store the form data.
let content = aBrowser.contentWindow;
// If the main content document has an associated URL that we are not
// allowed to store data for, bail out. We explicitly discard data for any
// children as well even if storing data for those frames would be allowed.
if (!PrivacyLevel.check(content.document.documentURI)) {
sendEvent(aBrowser, "SSTabInputCaptured");
return;
}
// Store the main content
let formdata = FormData.collect(content) || {};
// Loop over direct child frames, and store the text data
let children = [];
for (let i = 0; i < content.frames.length; i++) {
let frame = content.frames[i];
if (!PrivacyLevel.check(frame.document.documentURI)) {
continue;
}
let result = FormData.collect(frame);
if (result && Object.keys(result).length) {
children[i] = result;
}
}
// If any frame had text data, add it to the main form data
if (children.length) {
formdata.children = children;
}
let [formdata] = Utils.mapFrameTree(content, FormData.collect);
formdata = PrivacyFilter.filterFormData(formdata || {});
// If we found any form data, main content or frames, let's save it
if (Object.keys(formdata).length) {
if (formdata && Object.keys(formdata).length) {
data.formdata = formdata;
log("onTabInput() ran for tab " + aWindow.BrowserApp.getTabForBrowser(aBrowser).id);
this.saveStateDelayed();
@ -957,27 +930,10 @@ SessionStore.prototype = {
return;
}
// Start with storing the main content.
// Save the scroll position itself.
let content = aBrowser.contentWindow;
// Store the main content.
let scrolldata = ScrollPosition.collect(content) || {};
// Loop over direct child frames, and store the scroll positions.
let children = [];
for (let i = 0; i < content.frames.length; i++) {
let frame = content.frames[i];
let result = ScrollPosition.collect(frame);
if (result && Object.keys(result).length) {
children[i] = result;
}
}
// If any frame had scroll positions, add them to the main scroll data.
if (children.length) {
scrolldata.children = children;
}
let [scrolldata] = Utils.mapFrameTree(content, ScrollPosition.collect);
scrolldata = scrolldata || {};
// Save the current document resolution.
let zoom = { value: 1 };

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

@ -6,14 +6,14 @@
</head>
<body>
<input id="txt" />
<iframe id="iframe"></iframe>
<script type="text/javascript">
let isOuter = window == window.top;
if (isOuter) {
let iframe = document.createElement("iframe");
let iframe = document.getElementById("iframe");
iframe.setAttribute("src", "https://example.com" + location.pathname);
document.body.appendChild(iframe);
}
</script>
</body>