/** * Copyright 2017 Google Inc. All rights reserved. * Modifications copyright (c) Microsoft Corporation. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ import { utils } from '../../packages/playwright-core/lib/coreBundle'; import { contextTest as testBase, expect } from '../config/browserTest'; const test = testBase.extend<{ crash: () => void }, { dummy: string }>({ crash: async ({ page, toImpl, browserName }, run) => { await run(() => { if (browserName === 'chromium') page.goto('chrome://crash').catch(e => {}); else if (browserName === 'webkit') toImpl(page).delegate._session.send('Page.crash', {}).catch(e => {}); else if (browserName === 'firefox') toImpl(page).delegate._session.send('Page.crash', {}).catch(e => {}); }); }, // Force a separate worker to avoid messing up with other tests. dummy: ['', { scope: 'worker' }], }); test.beforeEach(({ platform, browserName, channel }) => { test.slow(platform === 'linux' && (browserName === 'webkit'), 'WebKit/Linux tests are consistently slower on some Linux environments. Most likely WebContent process is not getting terminated properly and is causing the slowdown.'); test.fixme(channel === 'webkit-wsl', 'WebKit on WSL is even slower than above ^^ - skipping for now'); test.skip(browserName === 'chromium' && utils.hostPlatform.startsWith('ubuntu24.04'), 'never dispatches the crash event'); }); test('should emit crash event when page crashes', async ({ page, crash }) => { await page.setContent(`