Skip to content

Commit 1c53c1e

Browse files
committed
Make sure that we can stop the profiling on a privileged page
1 parent f917469 commit 1c53c1e

File tree

1 file changed

+8
-8
lines changed

1 file changed

+8
-8
lines changed

src/background.js

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -13,16 +13,16 @@ import { assertExhaustiveCheck } from "./ts.js";
1313
* onClick listener for the extension toolbar button.
1414
*/
1515
chrome.action.onClicked.addListener(async (tab) => {
16-
if (!isTabAllowedToAttach(tab)) {
17-
return;
18-
}
19-
2016
if (!state.tabId && tab.id !== undefined) {
2117
state.tabId = tab.id;
2218
}
2319

2420
switch (state.recordingState) {
2521
case "idle":
22+
// Only check this when we need to start profiling. We can stop at any time.
23+
if (!isTabAllowedToAttach(tab)) {
24+
return;
25+
}
2626
await startTracing();
2727
break;
2828
case "recording":
@@ -48,10 +48,6 @@ chrome.commands.onCommand.addListener(async (command) => {
4848
return;
4949
}
5050

51-
if (!isTabAllowedToAttach(tab)) {
52-
return;
53-
}
54-
5551
if (!state.tabId && tab.id !== undefined) {
5652
state.tabId = tab.id;
5753
}
@@ -60,6 +56,10 @@ chrome.commands.onCommand.addListener(async (command) => {
6056
case "start-stop-profiler": {
6157
switch (state.recordingState) {
6258
case "idle":
59+
// Only check this when we need to start profiling. We can stop at any time.
60+
if (!isTabAllowedToAttach(tab)) {
61+
return;
62+
}
6363
await startTracing();
6464
break;
6565
case "recording":

0 commit comments

Comments
 (0)