|
@@ -1281,6 +1281,37 @@ describe('<webview> tag', function () {
|
|
|
})
|
|
|
})
|
|
|
|
|
|
+ describe('<webview>.capturePage()', () => {
|
|
|
+ it('returns a Promise with a NativeImage', async () => {
|
|
|
+ const src = 'data:text/html,%3Ch1%3EHello%2C%20World!%3C%2Fh1%3E'
|
|
|
+ await loadWebView(webview, { src })
|
|
|
+
|
|
|
+ const image = await webview.capturePage()
|
|
|
+ const imgBuffer = image.toPNG()
|
|
|
+
|
|
|
+ // Check the 25th byte in the PNG.
|
|
|
+ // Values can be 0,2,3,4, or 6. We want 6, which is RGB + Alpha
|
|
|
+ expect(imgBuffer[25]).to.equal(6)
|
|
|
+ })
|
|
|
+
|
|
|
+ // TODO(miniak): remove when promisification is complete
|
|
|
+ it('invokes callback with a NativeImage', (done) => {
|
|
|
+ webview.addEventListener('did-finish-load', () => {
|
|
|
+ webview.capturePage(function (image) {
|
|
|
+ const imgBuffer = image.toPNG()
|
|
|
+
|
|
|
+ // Check the 25th byte in the PNG.
|
|
|
+ // Values can be 0,2,3,4, or 6. We want 6, which is RGB + Alpha
|
|
|
+ expect(imgBuffer[25]).to.equal(6)
|
|
|
+ done()
|
|
|
+ })
|
|
|
+ })
|
|
|
+
|
|
|
+ webview.src = 'data:text/html,%3Ch1%3EHello%2C%20World!%3C%2Fh1%3E'
|
|
|
+ document.body.appendChild(webview)
|
|
|
+ })
|
|
|
+ })
|
|
|
+
|
|
|
describe('<webview>.printToPDF()', () => {
|
|
|
before(function () {
|
|
|
if (!features.isPrintingEnabled()) {
|