Better OSR tests (#12817)
* Add features.isOffscreenRenderingEnabled() * Use .isOffscreenRenderingEnabled() to determine if OSR is available * Add a helper closeTheWindow() function * Skip OSR tests if they are disabled
This commit is contained in:
parent
0a2dc1efb0
commit
3fd0ec99ae
2 changed files with 22 additions and 13 deletions
|
@ -7,6 +7,14 @@
|
||||||
|
|
||||||
namespace {
|
namespace {
|
||||||
|
|
||||||
|
bool IsOffscreenRenderingEnabled() {
|
||||||
|
#if defined(ENABLE_OSR)
|
||||||
|
return true;
|
||||||
|
#else
|
||||||
|
return false;
|
||||||
|
#endif
|
||||||
|
}
|
||||||
|
|
||||||
bool IsPDFViewerEnabled() {
|
bool IsPDFViewerEnabled() {
|
||||||
#if defined(ENABLE_PDF_VIEWER)
|
#if defined(ENABLE_PDF_VIEWER)
|
||||||
return true;
|
return true;
|
||||||
|
@ -20,6 +28,7 @@ void Initialize(v8::Local<v8::Object> exports,
|
||||||
v8::Local<v8::Context> context,
|
v8::Local<v8::Context> context,
|
||||||
void* priv) {
|
void* priv) {
|
||||||
mate::Dictionary dict(context->GetIsolate(), exports);
|
mate::Dictionary dict(context->GetIsolate(), exports);
|
||||||
|
dict.SetMethod("isOffscreenRenderingEnabled", &IsOffscreenRenderingEnabled);
|
||||||
dict.SetMethod("isPDFViewerEnabled", &IsPDFViewerEnabled);
|
dict.SetMethod("isPDFViewerEnabled", &IsPDFViewerEnabled);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -11,6 +11,8 @@ const {closeWindow} = require('./window-helpers')
|
||||||
const {ipcRenderer, remote, screen} = require('electron')
|
const {ipcRenderer, remote, screen} = require('electron')
|
||||||
const {app, ipcMain, BrowserWindow, BrowserView, protocol, session, webContents} = remote
|
const {app, ipcMain, BrowserWindow, BrowserView, protocol, session, webContents} = remote
|
||||||
|
|
||||||
|
const features = process.atomBinding('features')
|
||||||
|
|
||||||
const isCI = remote.getGlobal('isCi')
|
const isCI = remote.getGlobal('isCi')
|
||||||
const nativeModulesEnabled = remote.getGlobal('nativeModulesEnabled')
|
const nativeModulesEnabled = remote.getGlobal('nativeModulesEnabled')
|
||||||
|
|
||||||
|
@ -21,6 +23,10 @@ describe('BrowserWindow module', () => {
|
||||||
let server
|
let server
|
||||||
let postData
|
let postData
|
||||||
|
|
||||||
|
const closeTheWindow = function () {
|
||||||
|
return closeWindow(w).then(() => { w = null })
|
||||||
|
}
|
||||||
|
|
||||||
before((done) => {
|
before((done) => {
|
||||||
const filePath = path.join(fixtures, 'pages', 'a.html')
|
const filePath = path.join(fixtures, 'pages', 'a.html')
|
||||||
const fileStats = fs.statSync(filePath)
|
const fileStats = fs.statSync(filePath)
|
||||||
|
@ -82,9 +88,7 @@ describe('BrowserWindow module', () => {
|
||||||
})
|
})
|
||||||
})
|
})
|
||||||
|
|
||||||
afterEach(() => {
|
afterEach(closeTheWindow)
|
||||||
return closeWindow(w).then(() => { w = null })
|
|
||||||
})
|
|
||||||
|
|
||||||
describe('BrowserWindow constructor', () => {
|
describe('BrowserWindow constructor', () => {
|
||||||
it('allows passing void 0 as the webContents', () => {
|
it('allows passing void 0 as the webContents', () => {
|
||||||
|
@ -3059,17 +3063,13 @@ describe('BrowserWindow module', () => {
|
||||||
})
|
})
|
||||||
|
|
||||||
describe('offscreen rendering', () => {
|
describe('offscreen rendering', () => {
|
||||||
const isOffscreenRenderingDisabled = () => {
|
beforeEach(function () {
|
||||||
const contents = webContents.create({})
|
if (!features.isOffscreenRenderingEnabled()) {
|
||||||
const disabled = typeof contents.isOffscreen !== 'function'
|
// XXX(alexeykuzmin): "afterEach" hook is not called
|
||||||
contents.destroy()
|
// for skipped tests, we have to close the window manually.
|
||||||
return disabled
|
return closeTheWindow().then(() => { this.skip() })
|
||||||
}
|
}
|
||||||
|
|
||||||
// Offscreen rendering can be disabled in the build
|
|
||||||
if (isOffscreenRenderingDisabled()) return
|
|
||||||
|
|
||||||
beforeEach(() => {
|
|
||||||
if (w != null) w.destroy()
|
if (w != null) w.destroy()
|
||||||
w = new BrowserWindow({
|
w = new BrowserWindow({
|
||||||
width: 100,
|
width: 100,
|
||||||
|
|
Loading…
Reference in a new issue