Skip to content

feat: promisify webContents.printToPDF() - #16795

Merged
jkleinsc merged 1 commit into
masterfrom
miniak/promisify-print-to-pdf
Feb 11, 2019
Merged

jkleinsc merged 1 commit into
masterfrom
miniak/promisify-print-to-pdf

Conversation

@miniak

@miniak miniak commented Feb 6, 2019 •

Copy link
Copy Markdown
Contributor

Description of Change

This PR promisifies webContents.printToPDF()

/cc @codebytere

Checklist

Release Notes

Notes: Converted webContents.printToPDF() to return a Promise instead of taking a callback.

@miniak
miniak requested review from a team and codebytere February 6, 2019 22:21
@miniak
miniak force-pushed the miniak/promisify-print-to-pdf branch 3 times, most recently from 9065704 to 8d8fac3 Compare February 6, 2019 22:29
v8::Exception::Error(error_message), v8::Null(isolate));
}
print_to_pdf_callback_map_.erase(request_id);
v8::MicrotasksScope script_scope(isolate,

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

the util file deals with scoping prior to resolution; this can be removed

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

will remove the script_scope, should I keep the context_scope though?

@codebytere codebytere Feb 6, 2019 •

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

we handle it in the util, so i think you can remove that too!

  v8::Maybe<bool> Resolve() {
    v8::HandleScope handle_scope(isolate());
    v8::MicrotasksScope script_scope(isolate(),
                                     v8::MicrotasksScope::kRunMicrotasks);
    v8::Context::Scope context_scope(
        v8::Local<v8::Context>::New(isolate(), GetContext()));

    return GetInner()->Resolve(GetContext(), v8::Undefined(isolate()));
  }

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

I know, but don't we need that because we are creating the v8::Local<v8::Value> buffer before calling the util?

Comment thread lib/browser/api/web-contents.js Resolved
@miniak
miniak force-pushed the miniak/promisify-print-to-pdf branch from 8d8fac3 to a9ac096 Compare February 6, 2019 22:46
@miniak miniak self-assigned this Feb 7, 2019
@miniak
miniak force-pushed the miniak/promisify-print-to-pdf branch 2 times, most recently from 3490bc6 to 398faec Compare February 7, 2019 09:54

@deepak1556 deepak1556 left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

LGTM

@deepak1556

Copy link
Copy Markdown
Member

Lets rerun the osx test suite, to rule out flakiness before merging. Thanks!

@miniak
miniak force-pushed the miniak/promisify-print-to-pdf branch from 398faec to 0ff629c Compare February 8, 2019 21:16
@MarshallOfSound

Copy link
Copy Markdown
Member

I re-ran the macOS CI and the same test failed 🤔

@miniak
miniak force-pushed the miniak/promisify-print-to-pdf branch from 0ff629c to a9fa543 Compare February 9, 2019 23:22
return this._printToPDF(printingSetting)
} else {
console.error('Error: Printing feature is disabled.')
return Promise.reject(new Error('Printing feature is disabled'))

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

❤️

@jkleinsc
jkleinsc merged commit 36ce3e9 into master Feb 11, 2019
@release-clerk

release-clerk Bot commented Feb 11, 2019

Copy link
Copy Markdown

Release Notes Persisted

Converted webContents.printToPDF() to return a Promise instead of taking a callback.

@jkleinsc
jkleinsc deleted the miniak/promisify-print-to-pdf branch February 11, 2019 19:20
@miniak

miniak commented Feb 14, 2019

Copy link
Copy Markdown
Contributor Author

/trop run backport-to 5-0-x

@trop

trop Bot commented Feb 14, 2019

Copy link
Copy Markdown
Contributor

The backport process for this PR has been manually initiated,
sending your 1's and 0's to "5-0-x" here we go! :D

@trop

trop Bot commented Feb 14, 2019

Copy link
Copy Markdown
Contributor

I was unable to backport this PR to "5-0-x" cleanly;
you will need to perform this backport manually.

javan added a commit to javan/electron that referenced this pull request Dec 16, 2019
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.

6 participants