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 #5857.

Signed-off-by: Danny Tuppeny <danny@tuppeny.com>
  • Loading branch information
DanTup committed Dec 3, 2019
1 parent 5d24847 commit 48691ae
Show file tree
Hide file tree
Showing 4 changed files with 9 additions and 8 deletions.
4 changes: 4 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,10 @@

- [bunyan] removed [`@theia/bunyan`](https://github.com/eclipse-theia/theia/tree/b92a5673de1e9d1bdc85e6200486b92394200579/packages/bunyan) extension [#6651](https://github.com/eclipse-theia/theia/pull/6651)

Breaking changes:

- [core] new browser windows spawned through opener-service have noopener set, preventing them from accessing window.opener and giveing them their own event loop. openNewWindow will no longer return a Window as a result.

## v0.13.0

- [console] added filtering support based on severity [#6486](https://github.com/eclipse-theia/theia/pull/6486)
Expand Down
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 48691ae

Please sign in to comment.