From 2681e769a66bad94718424be5a14492778ce674d Mon Sep 17 00:00:00 2001 From: Birunthan Mohanathas Date: Thu, 15 Mar 2018 09:15:56 +0200 Subject: [PATCH] Document BrowserView.{destroy,isDestroyed} (#12274) --- docs/api/browser-view.md | 10 ++++++++++ spec/api-browser-view-spec.js | 16 ++++++++++++++++ 2 files changed, 26 insertions(+) diff --git a/docs/api/browser-view.md b/docs/api/browser-view.md index 4ed007b794..ee1780942d 100644 --- a/docs/api/browser-view.md +++ b/docs/api/browser-view.md @@ -73,6 +73,16 @@ A `Integer` representing the unique ID of the view. Objects created with `new BrowserView` have the following instance methods: +#### `view.destroy()` + +Force closing the view, the `unload` and `beforeunload` events won't be emitted +for the web page. After you're done with a view, call this function in order to +free memory and other resources as soon as possible. + +#### `view.isDestroyed()` + +Returns `Boolean` - Whether the view is destroyed. + #### `view.setAutoResize(options)` _Experimental_ * `options` Object diff --git a/spec/api-browser-view-spec.js b/spec/api-browser-view-spec.js index ab96021ebf..df239a8914 100644 --- a/spec/api-browser-view-spec.js +++ b/spec/api-browser-view-spec.js @@ -30,6 +30,22 @@ describe('BrowserView module', () => { return closeWindow(w).then(() => { w = null }) }) + describe('BrowserView.destroy()', () => { + it('does not throw', () => { + view = new BrowserView() + view.destroy() + }) + }) + + describe('BrowserView.isDestroyed()', () => { + it('returns correct value', () => { + view = new BrowserView() + assert.ok(!view.isDestroyed()) + view.destroy() + assert.ok(view.isDestroyed()) + }) + }) + describe('BrowserView.setBackgroundColor()', () => { it('does not throw for valid args', () => { view = new BrowserView()