@@ -18,7 +18,12 @@ import {
1818 LOCAL_STORAGE_TRACE_UPDATES_ENABLED_KEY ,
1919} from 'react-devtools-shared/src/constants' ;
2020import { logEvent } from 'react-devtools-shared/src/Logger' ;
21- import { normalizeUrlIfValid } from 'react-devtools-shared/src/utils' ;
21+ import {
22+ getAlwaysOpenInEditor ,
23+ getOpenInEditorURL ,
24+ normalizeUrlIfValid ,
25+ } from 'react-devtools-shared/src/utils' ;
26+ import { checkConditions } from 'react-devtools-shared/src/devtools/views/Editor/utils' ;
2227
2328import {
2429 setBrowserSelectionFromReact ,
@@ -530,3 +535,32 @@ if (__IS_FIREFOX__) {
530535connectExtensionPort ( ) ;
531536
532537mountReactDevToolsWhenReactHasLoaded ( ) ;
538+
539+ // Firefox doesn't support resources handlers yet.
540+ if ( chrome . devtools . panels . setOpenResourceHandler ) {
541+ chrome . devtools . panels . setOpenResourceHandler (
542+ (
543+ resource ,
544+ lineNumber = 1 ,
545+ // The column is a new feature so we have to specify a default if it doesn't exist
546+ columnNumber = 1 ,
547+ ) => {
548+ const alwaysOpenInEditor = getAlwaysOpenInEditor ( ) ;
549+ const editorURL = getOpenInEditorURL ( ) ;
550+ if ( alwaysOpenInEditor && editorURL ) {
551+ const location = [ '' , resource . url , lineNumber , columnNumber ] ;
552+ const { url, shouldDisableButton} = checkConditions ( editorURL , location ) ;
553+ if ( ! shouldDisableButton ) {
554+ window . open ( url ) ;
555+ return ;
556+ }
557+ }
558+ // Otherwise fallback to the built-in behavior.
559+ chrome . devtools . panels . openResource (
560+ resource . url ,
561+ lineNumber - 1 ,
562+ columnNumber - 1 ,
563+ ) ;
564+ } ,
565+ ) ;
566+ }
0 commit comments