55
66import { session } from 'electron' ;
77import { Disposable , IDisposable , toDisposable } from '../../../base/common/lifecycle.js' ;
8- import { COI , FileAccess , Schemas , CacheControlheaders } from '../../../base/common/network.js' ;
8+ import { COI , FileAccess , Schemas , CacheControlheaders , DocumentPolicyheaders } from '../../../base/common/network.js' ;
99import { basename , extname , normalize } from '../../../base/common/path.js' ;
1010import { isLinux } from '../../../base/common/platform.js' ;
1111import { TernarySearchTree } from '../../../base/common/ternarySearchTree.js' ;
@@ -93,10 +93,10 @@ export class ProtocolMainService extends Disposable implements IProtocolMainServ
9393
9494 private handleResourceRequest ( request : Electron . ProtocolRequest , callback : ProtocolCallback ) : void {
9595 const path = this . requestToNormalizedFilePath ( request ) ;
96+ const pathBasename = basename ( path ) ;
9697
9798 let headers : Record < string , string > | undefined ;
9899 if ( this . environmentService . crossOriginIsolated ) {
99- const pathBasename = basename ( path ) ;
100100 if ( pathBasename === 'workbench.html' || pathBasename === 'workbench-dev.html' ) {
101101 headers = COI . CoopAndCoep ;
102102 } else {
@@ -113,6 +113,16 @@ export class ProtocolMainService extends Disposable implements IProtocolMainServ
113113 } ;
114114 }
115115
116+ // Document-policy header is needed for collecting
117+ // JavaScript callstacks via https://www.electronjs.org/docs/latest/api/web-frame-main#framecollectjavascriptcallstack-experimental
118+ // until https://github.com/electron/electron/issues/45356 is resolved.
119+ if ( pathBasename === 'workbench.html' || pathBasename === 'workbench-dev.html' ) {
120+ headers = {
121+ ...headers ,
122+ ...DocumentPolicyheaders
123+ } ;
124+ }
125+
116126 // first check by validRoots
117127 if ( this . validRoots . findSubstr ( path ) ) {
118128 return callback ( { path, headers } ) ;
0 commit comments