Rietveld Code Review Tool
Help | Bug tracker | Discussion group | Source code

Unified Diff: lib/child/utils.js

Issue 29329550: Issue 3208 - Move getFrames() function from child/elemHide module into a shared child/utils module (Closed)
Patch Set: Created Oct. 30, 2015, 7:50 p.m.
Use n/p to move between diff chunks; N/P to move between comments.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « lib/child/elemHide.js ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: lib/child/utils.js
===================================================================
new file mode 100644
--- /dev/null
+++ b/lib/child/utils.js
@@ -0,0 +1,49 @@
+/*
+ * This file is part of Adblock Plus <https://adblockplus.org/>,
+ * Copyright (C) 2006-2015 Eyeo GmbH
+ *
+ * Adblock Plus is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License version 3 as
+ * published by the Free Software Foundation.
+ *
+ * Adblock Plus is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with Adblock Plus. If not, see <http://www.gnu.org/licenses/>.
+ */
+
+"use strict";
+
+let {PrivateBrowsingUtils} = Cu.import("resource://gre/modules/PrivateBrowsingUtils.jsm", {});
+
+/**
+ * Retrieves the frame hierarchy for a window. Returns an array containing
+ * the information for all frames, starting with the window itself up to its
+ * top-level window. Each entry has a location and a sitekey entry.
+ * @return {Array}
+ */
+let getFrames = exports.getFrames = function(/**Window*/ window)
+{
+ let frames = [];
+ while (window)
+ {
+ let frame = {
+ location: window.location.href,
+ sitekey: null
+ };
+
+ let documentElement = window.document && window.document.documentElement;
+ if (documentElement)
+ frame.sitekey = documentElement.getAttribute("data-adblockkey")
+
+ if (window == window.parent)
+ frame.privateBrowsing = PrivateBrowsingUtils.isWindowPrivate(window);
+
+ frames.push(frame);
+ window = (window != window.parent ? window.parent : null);
+ }
+ return frames;
+}
« no previous file with comments | « lib/child/elemHide.js ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld