From f1d1dfb081709309e6d426728d27650e54669972 Mon Sep 17 00:00:00 2001 From: Dmitry Gozman Date: Fri, 24 Jan 2020 15:56:41 -0800 Subject: [PATCH] fix(webkit): rewrite global object retrieval errors (#640) --- src/webkit/wkExecutionContext.ts | 10 +++++++++- test/screenshot.spec.js | 4 ++-- 2 files changed, 11 insertions(+), 3 deletions(-) diff --git a/src/webkit/wkExecutionContext.ts b/src/webkit/wkExecutionContext.ts index 0af625adbd8a8..69f3f53be035c 100644 --- a/src/webkit/wkExecutionContext.ts +++ b/src/webkit/wkExecutionContext.ts @@ -111,7 +111,15 @@ export class WKExecutionContext implements js.ExecutionContextDelegate { serializableArgs = args; } - const thisObjectId = await this._contextGlobalObjectId(); + let thisObjectId; + try { + thisObjectId = await this._contextGlobalObjectId(); + } catch (error) { + if (error.message.includes('Missing injected script for given')) + throw new Error('Execution context was destroyed, most likely because of a navigation.'); + throw error; + } + let callFunctionOnPromise; try { callFunctionOnPromise = this._session.send('Runtime.callFunctionOn', { diff --git a/test/screenshot.spec.js b/test/screenshot.spec.js index 3d08f687fe6b4..f4c9ae4237e13 100644 --- a/test/screenshot.spec.js +++ b/test/screenshot.spec.js @@ -181,8 +181,8 @@ module.exports.describe = function({testRunner, expect, product, FFOX, CHROMIUM, const screenshot = await page.screenshot(); expect(screenshot).toBeGolden('screenshot-webgl.png'); }); - // firefox and webkit are flaky - it.skip(FFOX || WEBKIT)('should work while navigating', async({page, server}) => { + // firefox is flaky + it.skip(FFOX)('should work while navigating', async({page, server}) => { await page.setViewport({width: 500, height: 500}); await page.goto(server.PREFIX + '/redirectloop1.html'); for (let i = 0; i < 10; i++) {