Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Set 'noopener' when opening windows to avoid sharing event loops #6683

Merged
merged 1 commit into from
Dec 3, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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