Bug 1456391 - Part 3: Use new mapFrameTree version on Desktop. r?mikedeboer
MozReview-Commit-ID: AUQXLPnO1CH
--- a/browser/components/sessionstore/content/content-sessionStore.js
+++ b/browser/components/sessionstore/content/content-sessionStore.js
@@ -28,16 +28,18 @@ ChromeUtils.defineModuleGetter(this, "Se
"resource://gre/modules/sessionstore/SessionHistory.jsm");
ChromeUtils.defineModuleGetter(this, "SessionStorage",
"resource:///modules/sessionstore/SessionStorage.jsm");
ChromeUtils.import("resource:///modules/sessionstore/ContentRestore.jsm", this);
XPCOMUtils.defineLazyGetter(this, "gContentRestore",
() => { return new ContentRestore(this); });
+ChromeUtils.defineModuleGetter(this, "Utils",
+ "resource://gre/modules/sessionstore/Utils.jsm");
const ssu = Cc["@mozilla.org/browser/sessionstore/utils;1"]
.getService(Ci.nsISessionStoreUtils);
// The current epoch.
var gCurrentEpoch = 0;
// A bound to the size of data to store for DOM Storage.
const DOM_STORAGE_LIMIT_PREF = "browser.sessionstore.dom_storage_limit";
@@ -50,39 +52,22 @@ const PREF_INTERVAL = "browser.sessionst
const kNoIndex = Number.MAX_SAFE_INTEGER;
const kLastIndex = Number.MAX_SAFE_INTEGER - 1;
// Grab our global so we can access it in functions below.
const global = this;
/**
- * A function that will recursively call |cb| to collected data for all
+ * A function that will recursively call |cb| to collect data for all
* non-dynamic frames in the current frame/docShell tree.
*/
function mapFrameTree(callback) {
- return (function map(frame, cb) {
- // Collect data for the current frame.
- let obj = cb(frame) || {};
- let children = [];
-
- // Recurse into child frames.
- ssu.forEachNonDynamicChildFrame(frame, (subframe, index) => {
- let result = map(subframe, cb);
- if (result && Object.keys(result).length) {
- children[index] = result;
- }
- });
-
- if (children.length) {
- obj.children = children;
- }
-
- return Object.keys(obj).length ? obj : null;
- })(content, callback);
+ let [data] = Utils.mapFrameTree(content, callback);
+ return data;
}
/**
* Listens for state change notifcations from webProgress and notifies each
* registered observer for either the start of a page load, or its completion.
*/
var StateChangeNotifier = {