Skip to content

Commit

Permalink
Fix scoping issue when running the DOM tests
Browse files Browse the repository at this point in the history
  • Loading branch information
philc committed May 20, 2022
1 parent 73e4b1e commit 887a023
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 4 deletions.
3 changes: 2 additions & 1 deletion content_scripts/vimium_frontend.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
// This content script must be run prior to domReady so that we perform some operations very early.
//

let root = typeof exports !== 'undefined' && exports !== null ? exports : (window.root != null ? window.root : (window.root = {}));
const root = {};
// On Firefox, sometimes the variables assigned to window are lost (bug 1408996), so we reinstall them.
// NOTE(mrmr1993): This bug leads to catastrophic failure (ie. nothing works and errors abound).
DomUtils.documentReady(function() {
Expand Down Expand Up @@ -207,6 +207,7 @@ const initializePreDomReady = function() {

// Wrapper to install event listeners. Syntactic sugar.
const installListener = (element, event, callback) => element.addEventListener(event, forTrusted(function() {
// TODO(philc): I think this workaround can be removed?
if (typeof global === 'undefined' || global === null) { // See #2800.
Object.assign(window, root);
}
Expand Down
5 changes: 2 additions & 3 deletions tests/dom_tests/chrome.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,7 @@
// Mock the Chrome extension API.
//

let root = window;
root.chromeMessages = [];
window.chromeMessages = [];

document.hasFocus = () => true;

Expand All @@ -13,7 +12,7 @@ const fakeManifest = {
version: "1.51"
};

root.chrome = {
window.chrome = {
runtime: {
connect() {
return {
Expand Down

0 comments on commit 887a023

Please sign in to comment.