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

feat: promisify webContents.printToPDF() #16795

Merged
merged 1 commit into from Feb 11, 2019

Conversation

Projects
None yet
6 participants
@miniak
Copy link
Contributor

miniak commented Feb 6, 2019

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 a review from codebytere Feb 6, 2019

@miniak miniak requested review from electron/docs as code owners Feb 6, 2019

@miniak miniak force-pushed the miniak/promisify-print-to-pdf branch 3 times, most recently from 9065704 to 8d8fac3 Feb 6, 2019

v8::Exception::Error(error_message), v8::Null(isolate));
}
print_to_pdf_callback_map_.erase(request_id);
v8::MicrotasksScope script_scope(isolate,

This comment has been minimized.

@codebytere

codebytere Feb 6, 2019

Member

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

This comment has been minimized.

@miniak

miniak Feb 6, 2019

Author Contributor

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

This comment has been minimized.

@codebytere

codebytere Feb 6, 2019

Member

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()));
  }

This comment has been minimized.

@miniak

miniak Feb 6, 2019

Author Contributor

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

@miniak miniak force-pushed the miniak/promisify-print-to-pdf branch from 8d8fac3 to a9ac096 Feb 6, 2019

@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 Feb 7, 2019

@deepak1556
Copy link
Member

deepak1556 left a comment

LGTM

@deepak1556

This comment has been minimized.

Copy link
Member

deepak1556 commented Feb 8, 2019

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 Feb 8, 2019

@MarshallOfSound

This comment has been minimized.

Copy link
Member

MarshallOfSound commented Feb 8, 2019

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 Feb 9, 2019

@miniak miniak added target/5-0-x and removed target/5-0-x labels Feb 9, 2019

} else {
console.error('Error: Printing feature is disabled.')
return Promise.reject(new Error('Printing feature is disabled'))

This comment has been minimized.

@alexeykuzmin

alexeykuzmin Feb 11, 2019

Contributor

❤️

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

8 checks passed

Semantic Pull Request ready to be squashed
Details
appveyor: win-ia32-debug AppVeyor build succeeded
Details
appveyor: win-ia32-testing AppVeyor build succeeded
Details
appveyor: win-ia32-testing-pr AppVeyor build succeeded
Details
appveyor: win-x64-debug AppVeyor build succeeded
Details
appveyor: win-x64-testing AppVeyor build succeeded
Details
appveyor: win-x64-testing-pr AppVeyor build succeeded
Details
release-notes Release notes found
@release-clerk

This comment has been minimized.

Copy link

release-clerk bot commented Feb 11, 2019

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 Feb 11, 2019

@miniak

This comment has been minimized.

Copy link
Contributor Author

miniak commented Feb 14, 2019

/trop run backport-to 5-0-x

@trop

This comment has been minimized.

Copy link
Contributor

trop bot commented Feb 14, 2019

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

This comment has been minimized.

Copy link
Contributor

trop bot commented Feb 14, 2019

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment