summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authortoasted-nutbread <toasted-nutbread@users.noreply.github.com>2019-10-15 20:23:25 -0400
committertoasted-nutbread <toasted-nutbread@users.noreply.github.com>2019-10-15 20:23:25 -0400
commit16521fec935845828b7e08baf1668657bb5a7cef (patch)
tree6c965bf0e8962684f08e89f0c87fe595a6727bb2
parent099909287f23bbc9e2deee2e4cd8cf9b17c88618 (diff)
Assign first popup on the search page as a depth of 1
-rw-r--r--ext/bg/js/search-frontend.js2
-rw-r--r--ext/fg/js/frontend.js7
-rw-r--r--ext/fg/js/popup-nested.js2
-rw-r--r--ext/fg/js/popup-proxy-host.js8
4 files changed, 11 insertions, 8 deletions
diff --git a/ext/bg/js/search-frontend.js b/ext/bg/js/search-frontend.js
index f55f06e6..b21dac17 100644
--- a/ext/bg/js/search-frontend.js
+++ b/ext/bg/js/search-frontend.js
@@ -25,6 +25,8 @@ async function searchFrontendSetup() {
const options = await apiOptionsGet(optionsContext);
if (!options.scanning.enableOnSearchPage) { return; }
+ window.frontendInitializationData = {depth: 1, proxy: false};
+
const scriptSrcs = [
'/fg/js/frontend-api-receiver.js',
'/fg/js/popup.js',
diff --git a/ext/fg/js/frontend.js b/ext/fg/js/frontend.js
index 3ddeae78..7ea737d7 100644
--- a/ext/fg/js/frontend.js
+++ b/ext/fg/js/frontend.js
@@ -49,11 +49,10 @@ class Frontend {
}
static create() {
- const initializationData = window.frontendInitializationData;
- const isNested = (initializationData !== null && typeof initializationData === 'object');
- const {id, depth, parentFrameId, ignoreNodes, url} = isNested ? initializationData : {};
+ const data = window.frontendInitializationData || {};
+ const {id, depth=0, parentFrameId, ignoreNodes, url, proxy=false} = data;
- const popup = isNested ? new PopupProxy(depth + 1, id, parentFrameId, url) : PopupProxyHost.instance.createPopup(null);
+ const popup = proxy ? new PopupProxy(depth + 1, id, parentFrameId, url) : PopupProxyHost.instance.createPopup(null, depth);
const frontend = new Frontend(popup, ignoreNodes);
frontend.prepare();
return frontend;
diff --git a/ext/fg/js/popup-nested.js b/ext/fg/js/popup-nested.js
index f7309466..cec95aea 100644
--- a/ext/fg/js/popup-nested.js
+++ b/ext/fg/js/popup-nested.js
@@ -35,7 +35,7 @@ async function popupNestedInitialize(id, depth, parentFrameId, url) {
const ignoreNodes = options.scanning.enableOnPopupExpressions ? [] : [ '.expression', '.expression *' ];
- window.frontendInitializationData = {id, depth, parentFrameId, ignoreNodes, url};
+ window.frontendInitializationData = {id, depth, parentFrameId, ignoreNodes, url, proxy: true};
const scriptSrcs = [
'/fg/js/frontend-api-sender.js',
diff --git a/ext/fg/js/popup-proxy-host.js b/ext/fg/js/popup-proxy-host.js
index bb323f64..f97d44ac 100644
--- a/ext/fg/js/popup-proxy-host.js
+++ b/ext/fg/js/popup-proxy-host.js
@@ -50,10 +50,12 @@ class PopupProxyHost {
});
}
- createPopup(parentId) {
+ createPopup(parentId, depth) {
const parent = (typeof parentId === 'string' && this.popups.hasOwnProperty(parentId) ? this.popups[parentId] : null);
- const depth = (parent !== null ? parent.depth + 1 : 0);
const id = `${this.nextId}`;
+ if (parent !== null) {
+ depth = parent.depth + 1;
+ }
++this.nextId;
const popup = new Popup(id, depth, this.frameIdPromise);
if (parent !== null) {
@@ -65,7 +67,7 @@ class PopupProxyHost {
}
async createNestedPopup(parentId) {
- return this.createPopup(parentId).id;
+ return this.createPopup(parentId, 0).id;
}
getPopup(id) {