From 80dd16aa7811e0608c979005f227b40e1d273298 Mon Sep 17 00:00:00 2001 From: Shelley Vohr Date: Tue, 11 Feb 2020 03:35:05 +0000 Subject: [PATCH] spec: unskip webview.printToPDF (#22122) --- .../api/electron_api_system_preferences.h | 2 -- spec/webview-spec.js | 27 ++++++++++++++++--- 2 files changed, 24 insertions(+), 5 deletions(-) diff --git a/shell/browser/api/electron_api_system_preferences.h b/shell/browser/api/electron_api_system_preferences.h index 0b465226b80e..e389082ebe0c 100644 --- a/shell/browser/api/electron_api_system_preferences.h +++ b/shell/browser/api/electron_api_system_preferences.h @@ -99,8 +99,6 @@ class SystemPreferences : public gin_helper::EventEmitter static bool IsTrustedAccessibilityClient(bool prompt); - // TODO(codebytere): Write tests for these methods once we - // are running tests on a Mojave machine std::string GetMediaAccessStatus(const std::string& media_type, gin_helper::Arguments* args); v8::Local AskForMediaAccess(v8::Isolate* isolate, diff --git a/spec/webview-spec.js b/spec/webview-spec.js index 25da1252301c..f3981567824b 100644 --- a/spec/webview-spec.js +++ b/spec/webview-spec.js @@ -1010,14 +1010,35 @@ describe(' tag', function () { }) describe('.printToPDF()', () => { - before(function () { + before(() => { if (!features.isPrintingEnabled()) { this.skip() } }) - // TODO(deepak1556): Fix and enable after upgrade. - it.skip('can print to PDF', async () => { + it('rejects on incorrectly typed parameters', async () => { + const badTypes = { + marginsType: 'terrible', + scaleFactor: 'not-a-number', + landscape: [], + pageRanges: { 'oops': 'im-not-the-right-key' }, + headerFooter: '123', + printSelectionOnly: 1, + printBackground: 2, + pageSize: 'IAmAPageSize' + } + + // These will hard crash in Chromium unless we type-check + for (const [key, value] of Object.entries(badTypes)) { + const param = { [key]: value } + + const src = 'data:text/html,%3Ch1%3EHello%2C%20World!%3C%2Fh1%3E' + await loadWebView(webview, { src }) + await expect(webview.printToPDF(param)).to.eventually.be.rejected() + } + }) + + it('can print to PDF', async () => { const src = 'data:text/html,%3Ch1%3EHello%2C%20World!%3C%2Fh1%3E' await loadWebView(webview, { src })