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

CLI: close tab when we're done with it. #1543

Merged
merged 3 commits into from
Jan 27, 2017
Merged

CLI: close tab when we're done with it. #1543

merged 3 commits into from
Jan 27, 2017

Conversation

paulirish
Copy link
Member

Fixes #1419

resolve(JSON.parse(data));
return;
} catch (e) {
if (data === 'Target is closing') {
Copy link
Member Author

@paulirish paulirish Jan 26, 2017

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The chromium code that handles this says

SendJson(connection_id, net::HTTP_OK, NULL, "Target is closing");

But unfortunately, SendJson doesn't send JSON in this case. It sends this raw string.
Thus, the try/catch on this guy.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Will you add some variant of this as a comment in the code? At least for the string being checked against

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

yup!

this._ws.close();
this._ws = null;
return Promise.resolve();
return this._runJsonCommand(`close/${this._pageId}`).then(_ => {
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Will this close the browser too if it's the last tab left?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It will not. It'll close the "window" but not the application.

return this._runJsonCommand(`close/${this._pageId}`).then(_ => {
this._ws.removeAllListeners();
this._ws.close();
this._ws = null;
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't know when we'd ever reuse a cri connection instance, but since we null out _ws, null out _pageId as well?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

fair. done.

} catch (e) {
if (data === 'Target is closing') {
return resolve({message: data});
}
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Since you have the try/catch now, want to add a return reject(e) here, even though it wasn't caught in the promise chain before?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

sg

@paulirish
Copy link
Member Author

PTAL

@brendankenny
Copy link
Member

brendankenny commented Jan 26, 2017

looks like some of the gather-runner tests failed because fake-driver doesn't return Promise.resolve(); in disconnect so driver.disconnect().catch(...) throws

Copy link
Member

@brendankenny brendankenny left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM 📂➡️📁➡️💥

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants