Skip to content

Commit

Permalink
Set 'noopener' when opening windows to avoid sharing event loops
Browse files Browse the repository at this point in the history
Prevents the web UI pausing when an app opened with window.open is paused in the browsers debugger.

Fixes eclipse-theia#5857.
  • Loading branch information
DanTup committed Dec 3, 2019
1 parent 5d24847 commit e7e46aa
Show file tree
Hide file tree
Showing 3 changed files with 5 additions and 8 deletions.
2 changes: 1 addition & 1 deletion packages/core/src/browser/http-open-handler.ts
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ export class HttpOpenHandler implements OpenHandler {
return (uri.scheme.startsWith('http') || uri.scheme.startsWith('mailto')) ? 500 : 0;
}

async open(uri: URI): Promise<Window | undefined> {
async open(uri: URI): Promise<undefined> {
const resolvedUri = await this.externalUriService.resolve(uri);
return this.windowService.openNewWindow(resolvedUri.toString(true), { external: true });
}
Expand Down
9 changes: 3 additions & 6 deletions packages/core/src/browser/window/default-window-service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -41,12 +41,9 @@ export class DefaultWindowService implements WindowService, FrontendApplicationC
});
}

openNewWindow(url: string): Window | undefined {
const newWindow = window.open(url);
if (newWindow === null) {
throw new Error('Cannot open a new window for URL: ' + url);
}
return newWindow;
openNewWindow(url: string): undefined {
window.open(url, undefined, 'noopener');
return undefined;
}

canUnload(): boolean {
Expand Down
2 changes: 1 addition & 1 deletion packages/core/src/browser/window/window-service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ export interface WindowService {
* In a browser, opening a new Theia tab or open a link is the same thing.
* But in Electron, we want to open links in a browser, not in Electron.
*/
openNewWindow(url: string, options?: NewWindowOptions): Window | undefined;
openNewWindow(url: string, options?: NewWindowOptions): undefined;

/**
* Called when the `window` is about to `unload` its resources.
Expand Down

0 comments on commit e7e46aa

Please sign in to comment.