fix: correctly track receiver for methods called via ctx bridge (#39978)
* fix: correctly track receiver for methods called via ctx bridge * spec: test for correct contextBridge passage --------- Co-authored-by: Shelley Vohr <shelley.vohr@gmail.com>
This commit is contained in:
parent
5b105f911f
commit
fd2861117e
5 changed files with 90 additions and 47 deletions
|
@ -2020,25 +2020,34 @@ describe('<webview> tag', function () {
|
|||
|
||||
// TODO(miniak): figure out why this is failing on windows
|
||||
ifdescribe(process.platform !== 'win32')('<webview>.capturePage()', () => {
|
||||
it('returns a Promise with a NativeImage', async () => {
|
||||
it('returns a Promise with a NativeImage', async function () {
|
||||
this.retries(5);
|
||||
|
||||
const src = 'data:text/html,%3Ch1%3EHello%2C%20World!%3C%2Fh1%3E';
|
||||
await loadWebViewAndWaitForEvent(w, { src }, 'did-stop-loading');
|
||||
|
||||
// Retry a few times due to flake.
|
||||
for (let i = 0; i < 5; i++) {
|
||||
try {
|
||||
const image = await w.executeJavaScript('webview.capturePage()');
|
||||
const imgBuffer = image.toPNG();
|
||||
const image = await w.executeJavaScript('webview.capturePage()');
|
||||
expect(image.isEmpty()).to.be.false();
|
||||
|
||||
// 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);
|
||||
return;
|
||||
} catch {
|
||||
/* drop the error */
|
||||
}
|
||||
}
|
||||
expect(false).to.be.true('could not successfully capture the page');
|
||||
// Check the 25th byte in the PNG.
|
||||
// Values can be 0,2,3,4, or 6. We want 6, which is RGB + Alpha
|
||||
const imgBuffer = image.toPNG();
|
||||
expect(imgBuffer[25]).to.equal(6);
|
||||
});
|
||||
|
||||
it('returns a Promise with a NativeImage in the renderer', async function () {
|
||||
this.retries(5);
|
||||
|
||||
const src = 'data:text/html,%3Ch1%3EHello%2C%20World!%3C%2Fh1%3E';
|
||||
await loadWebViewAndWaitForEvent(w, { src }, 'did-stop-loading');
|
||||
|
||||
const byte = await w.executeJavaScript(`new Promise(resolve => {
|
||||
webview.capturePage().then(image => {
|
||||
resolve(image.toPNG()[25])
|
||||
});
|
||||
})`);
|
||||
|
||||
expect(byte).to.equal(6);
|
||||
});
|
||||
});
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue