Browse Source

spec: fix conditions for some tests (#23489) (#23494)

(cherry picked from commit dc3de49a085eb9335b6bad80848d0386767742c3)
Alexey Kuzmin 5 years ago
parent
commit
6d75e7aac6
2 changed files with 8 additions and 9 deletions
  1. 7 2
      spec-main/api-browser-window-spec.ts
  2. 1 7
      spec/webview-spec.js

+ 7 - 2
spec-main/api-browser-window-spec.ts

@@ -11,6 +11,7 @@ import { emittedOnce } from './events-helpers';
 import { ifit, ifdescribe } from './spec-helpers';
 import { closeWindow } from './window-helpers';
 
+const features = process.electronBinding('features');
 const fixtures = path.resolve(__dirname, '..', 'spec', 'fixtures');
 
 // Is the display's scale factor possibly causing rounding of pixel coordinate
@@ -703,7 +704,7 @@ describe('BrowserWindow module', () => {
       });
     });
 
-    describe('BrowserWindow.moveAbove(mediaSourceId)', () => {
+    ifdescribe(features.isDesktopCapturerEnabled())('BrowserWindow.moveAbove(mediaSourceId)', () => {
       it('should throw an exception if wrong formatting', async () => {
         const fakeSourceIds = [
           'none', 'screen:0', 'window:fake', 'window:1234', 'foobar:1:2'
@@ -714,6 +715,7 @@ describe('BrowserWindow module', () => {
           }).to.throw(/Invalid media source id/);
         });
       });
+
       it('should throw an exception if wrong type', async () => {
         const fakeSourceIds = [null as any, 123 as any];
         fakeSourceIds.forEach((sourceId) => {
@@ -722,6 +724,7 @@ describe('BrowserWindow module', () => {
           }).to.throw(/Error processing argument at index 0 */);
         });
       });
+
       it('should throw an exception if invalid window', async () => {
         // It is very unlikely that these window id exist.
         const fakeSourceIds = ['window:99999999:0', 'window:123456:1',
@@ -732,6 +735,7 @@ describe('BrowserWindow module', () => {
           }).to.throw(/Invalid media source id/);
         });
       });
+
       it('should not throw an exception', async () => {
         const w2 = new BrowserWindow({ show: false, title: 'window2' });
         const w2Shown = emittedOnce(w2, 'show');
@@ -760,9 +764,11 @@ describe('BrowserWindow module', () => {
 
   describe('sizing', () => {
     let w = null as unknown as BrowserWindow;
+
     beforeEach(() => {
       w = new BrowserWindow({ show: false, width: 400, height: 400 });
     });
+
     afterEach(async () => {
       await closeWindow(w);
       w = null as unknown as BrowserWindow;
@@ -4089,7 +4095,6 @@ describe('BrowserWindow module', () => {
     });
   });
 
-  const features = process.electronBinding('features');
   ifdescribe(features.isOffscreenRenderingEnabled())('offscreen rendering', () => {
     let w: BrowserWindow;
     beforeEach(function () {

+ 1 - 7
spec/webview-spec.js

@@ -1009,13 +1009,7 @@ describe('<webview> tag', function () {
     });
   });
 
-  describe('<webview>.printToPDF()', () => {
-    before(function () {
-      if (!features.isPrintingEnabled()) {
-        this.skip();
-      }
-    });
-
+  ifdescribe(features.isPrintingEnabled())('<webview>.printToPDF()', () => {
     // TODO(deepak1556): Fix and enable after upgrade.
     it.skip('can print to PDF', async () => {
       const src = 'data:text/html,%3Ch1%3EHello%2C%20World!%3C%2Fh1%3E';