@@ -17,33 +17,32 @@ export async function getCurrentTab() {
1717 return tab ;
1818}
1919
20+ /**
21+ * Return whether the url is privileged or not.
22+ *
23+ * @param {string | undefined } url
24+ */
25+ export function isPrivilegedUrl ( url ) {
26+ return (
27+ ! url ||
28+ url . startsWith ( "chrome://" ) ||
29+ url . startsWith ( "about://" ) ||
30+ url . startsWith ( "https://chromewebstore.google.com/" )
31+ ) ;
32+ }
33+
2034/**
2135 * Check if the tab is allowed to be attached and show a notification if not.
2236 * Chrome privileged pages are not allowed.
2337 *
2438 * @param {chrome.tabs.Tab } tab
2539 */
2640export function isTabAllowedToAttach ( tab ) {
27- if (
28- ! tab . url ?. startsWith ( "chrome://" ) &&
29- ! tab . url ?. startsWith ( "chrome-extension://" ) &&
30- ! tab . url ?. startsWith ( "https://chromewebstore.google.com/" )
31- ) {
32- // It's not a privileged page.
33- return true ;
41+ if ( isPrivilegedUrl ( tab . url ) ) {
42+ // We are not allowed in a privileged page, warn the user and return false.
43+ console . warn ( "Tab is not allowed to trace" ) ;
44+ return false ;
3445 }
3546
36- // We are not allowed in a privileged page, warn the user and return false.
37- console . warn ( "Tab is not allowed to trace" ) ;
38- const notificationId = "firefox-profiler-not-allowed" + Math . random ( ) ;
39- const options = {
40- /** @type {chrome.notifications.TemplateType } */
41- type : "basic" ,
42- iconUrl : chrome . runtime . getURL ( "icons/off/icon128.png" ) ,
43- title : "Firefox Profiler Error" ,
44- message : "Tracing a privileged page is not allowed." ,
45- } ;
46-
47- chrome . notifications . create ( notificationId , options , ( ) => { } ) ;
48- return false ;
47+ return true ;
4948}
0 commit comments