Skip to content
This repository was archived by the owner on Sep 21, 2021. It is now read-only.

Commit f8063da

Browse files
nchevobbejasonLaster
authored andcommitted
Make inToolbox not throw in m-c (#1090)
1 parent 7f8208e commit f8063da

File tree

2 files changed

+12
-2
lines changed

2 files changed

+12
-2
lines changed

packages/devtools-contextmenu/menu.js

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,12 @@
55
const { Menu, MenuItem } = require("devtools-modules");
66

77
function inToolbox() {
8-
return !window || window.parent.document.documentURI == "about:devtools-toolbox";
8+
try {
9+
return window.parent.document.documentURI == "about:devtools-toolbox";
10+
} catch (e) {
11+
// If `window` is not available, it's very likely that we are in the toolbox.
12+
return true;
13+
}
914
}
1015

1116
if (!inToolbox()) {

packages/devtools-modules/src/menu/index.js

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,12 @@
55
const EventEmitter = require("../utils/event-emitter");
66

77
function inToolbox() {
8-
return !window || window.parent.document.documentURI == "about:devtools-toolbox";
8+
try {
9+
return window.parent.document.documentURI == "about:devtools-toolbox";
10+
} catch (e) {
11+
// If `window` is not available, it's very likely that we are in the toolbox.
12+
return true;
13+
}
914
}
1015

1116
/**

0 commit comments

Comments
 (0)