2024-08-07 15:20:12 +02:00
|
|
|
/**
|
|
|
|
|
* Copyright Microsoft Corporation. All rights reserved.
|
|
|
|
|
*
|
|
|
|
|
* 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 { contextTest as test, expect } from '../../config/browserTest';
|
|
|
|
|
|
|
|
|
|
test.use({
|
|
|
|
|
launchOptions: async ({ launchOptions }, use) => {
|
|
|
|
|
await use({ ...launchOptions, ignoreDefaultArgs: ['--disable-back-forward-cache'] });
|
|
|
|
|
}
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
test('bindings should work after restoring from bfcache', async ({ page, server }) => {
|
|
|
|
|
await page.exposeFunction('add', (a, b) => a + b);
|
|
|
|
|
|
|
|
|
|
await page.goto(server.PREFIX + '/cached/bfcached.html');
|
|
|
|
|
expect(await page.evaluate('window.add(1, 2)')).toBe(3);
|
|
|
|
|
|
|
|
|
|
await page.setContent(`<a href='about:blank'}>click me</a>`);
|
|
|
|
|
await page.click('a');
|
chore: make noWaitAfter a default
This changes the last actions, namely `click` and `press`, to not wait
for the ongoing navigations after the action.
Maintaining this behavior becomes tricky, because browsers move away from
guaranteed synchronous navigations to optimized performance. See #34377
for more details.
This is technically a breaking change. Most of the time, this should
not be noticeable, because the next action will auto-wait the navigation
and for any required conditions anyway. However, there are some patterns
revealed by our tests that are affected:
- Calling `goBack/goForward` immediately after an action. This pattern
requires `expect(page).toHaveURL()` or a similar check inbetween.
- Listening for network events during the action, and immediately
asserting after the action. This pattern requires `waitForRequest()`
or a similar promise-based waiter as recommended in best practices.
We maintain the opt-out `env.PLAYWRIGHT_WAIT_AFTER_CLICK` that reverts
to the old behavior for now.
Additionally, previous opt-out option `env.PLAYWRIGHT_SKIP_NAVIGATION_CHECK`
has been removed, because there have been just a single issue with it,
that was immediately addressed in a patch release.
2025-02-04 13:51:03 +01:00
|
|
|
await expect(page).toHaveURL('about:blank');
|
2024-08-07 15:20:12 +02:00
|
|
|
|
|
|
|
|
await page.goBack({ waitUntil: 'commit' });
|
|
|
|
|
await page.evaluate('window.didShow');
|
|
|
|
|
expect(await page.evaluate('window.add(2, 3)')).toBe(5);
|
|
|
|
|
});
|