Browse Source

spec: unskip webview.printToPDF (#22122)

Shelley Vohr 5 years ago
parent
commit
80dd16aa78
2 changed files with 24 additions and 5 deletions
  1. 0 2
      shell/browser/api/electron_api_system_preferences.h
  2. 24 3
      spec/webview-spec.js

+ 0 - 2
shell/browser/api/electron_api_system_preferences.h

@@ -99,8 +99,6 @@ class SystemPreferences : public gin_helper::EventEmitter<SystemPreferences>
 
   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<v8::Promise> AskForMediaAccess(v8::Isolate* isolate,

+ 24 - 3
spec/webview-spec.js

@@ -1010,14 +1010,35 @@ describe('<webview> tag', function () {
   })
 
   describe('<webview>.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 })