summaryrefslogtreecommitdiff
path: root/ext/fg/js/popup.js
diff options
context:
space:
mode:
authortoasted-nutbread <toasted-nutbread@users.noreply.github.com>2020-05-02 13:00:46 -0400
committerGitHub <noreply@github.com>2020-05-02 13:00:46 -0400
commitc4ea9321dcffbda9004461a7b0027cf5c893f3c0 (patch)
treed42693165e657bd038d037ac65d61dbc99d59dcf /ext/fg/js/popup.js
parent51032d1eca04820a80f34dfd511a927c55975c1f (diff)
Validate document nodes before use (#493)
* Validate document.body before use in loadScripts This also fixes an issue where reject wasn't being passed to loadScriptSentinel. * Validate document nodes before use in _getSiteColor * Validate document.body before use in _getViewport * Validate document.body before use in setContentScale * Validate document.body before use in docImposterCreate
Diffstat (limited to 'ext/fg/js/popup.js')
-rw-r--r--ext/fg/js/popup.js12
1 files changed, 9 insertions, 3 deletions
diff --git a/ext/fg/js/popup.js b/ext/fg/js/popup.js
index 2b33b714..f5cb6f77 100644
--- a/ext/fg/js/popup.js
+++ b/ext/fg/js/popup.js
@@ -389,8 +389,13 @@ class Popup {
_getSiteColor() {
const color = [255, 255, 255];
- Popup._addColor(color, Popup._getColorInfo(window.getComputedStyle(document.documentElement).backgroundColor));
- Popup._addColor(color, Popup._getColorInfo(window.getComputedStyle(document.body).backgroundColor));
+ const {documentElement, body} = document;
+ if (documentElement !== null) {
+ Popup._addColor(color, Popup._getColorInfo(window.getComputedStyle(documentElement).backgroundColor));
+ }
+ if (body !== null) {
+ Popup._addColor(color, Popup._getColorInfo(window.getComputedStyle(body).backgroundColor));
+ }
const dark = (color[0] < 128 && color[1] < 128 && color[2] < 128);
return dark ? 'dark' : 'light';
}
@@ -575,10 +580,11 @@ class Popup {
}
}
+ const body = document.body;
return {
left: 0,
top: 0,
- right: document.body.clientWidth,
+ right: (body !== null ? body.clientWidth : 0),
bottom: window.innerHeight
};
}