From 5049986bed5121ee85543a9db7b88da19cf45be1 Mon Sep 17 00:00:00 2001 From: Milan Burda Date: Wed, 30 Aug 2023 17:07:41 +0200 Subject: [PATCH] refactor: generate 'chrome:// pages' specs to remove duplicate code (#39684) --- spec/chromium-spec.ts | 61 ++++++++++++++----------------------------- 1 file changed, 20 insertions(+), 41 deletions(-) diff --git a/spec/chromium-spec.ts b/spec/chromium-spec.ts index fb3907089f2a4..c2b39e43377c7 100644 --- a/spec/chromium-spec.ts +++ b/spec/chromium-spec.ts @@ -2050,48 +2050,27 @@ describe('chromium features', () => { }); }); - describe('chrome://accessibility', () => { - it('loads the page successfully', async () => { - const w = new BrowserWindow({ show: false }); - await w.loadURL('chrome://accessibility'); - const pageExists = await w.webContents.executeJavaScript( - "window.hasOwnProperty('chrome') && window.chrome.hasOwnProperty('send')" - ); - expect(pageExists).to.be.true(); - }); - }); - - describe('chrome://gpu', () => { - it('loads the page successfully', async () => { - const w = new BrowserWindow({ show: false }); - await w.loadURL('chrome://gpu'); - const pageExists = await w.webContents.executeJavaScript( - "window.hasOwnProperty('chrome') && window.chrome.hasOwnProperty('send')" - ); - expect(pageExists).to.be.true(); - }); - }); - - describe('chrome://media-internals', () => { - it('loads the page successfully', async () => { - const w = new BrowserWindow({ show: false }); - await w.loadURL('chrome://media-internals'); - const pageExists = await w.webContents.executeJavaScript( - "window.hasOwnProperty('chrome') && window.chrome.hasOwnProperty('send')" - ); - expect(pageExists).to.be.true(); - }); - }); + describe('chrome:// pages', () => { + const urls = [ + 'chrome://accessibility', + 'chrome://gpu', + 'chrome://media-internals', + 'chrome://tracing', + 'chrome://webrtc-internals' + ]; - describe('chrome://webrtc-internals', () => { - it('loads the page successfully', async () => { - const w = new BrowserWindow({ show: false }); - await w.loadURL('chrome://webrtc-internals'); - const pageExists = await w.webContents.executeJavaScript( - "window.hasOwnProperty('chrome') && window.chrome.hasOwnProperty('send')" - ); - expect(pageExists).to.be.true(); - }); + for (const url of urls) { + describe(url, () => { + it('loads the page successfully', async () => { + const w = new BrowserWindow({ show: false }); + await w.loadURL(url); + const pageExists = await w.webContents.executeJavaScript( + "window.hasOwnProperty('chrome') && window.chrome.hasOwnProperty('send')" + ); + expect(pageExists).to.be.true(); + }); + }); + } }); describe('document.hasFocus', () => {