2020-08-03 23:41:48 +03:00
|
|
|
/**
|
|
|
|
* Copyright 2018 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.
|
|
|
|
*/
|
|
|
|
|
2020-09-27 02:05:58 +03:00
|
|
|
import { it, expect } from './fixtures';
|
2020-08-03 23:41:48 +03:00
|
|
|
|
2020-11-21 02:19:39 +03:00
|
|
|
it('should avoid side effects after timeout', (test, { mode }) => {
|
|
|
|
test.skip(mode !== 'default');
|
2020-08-28 23:53:47 +03:00
|
|
|
}, async ({page, server}) => {
|
2020-08-03 23:41:48 +03:00
|
|
|
await page.goto(server.PREFIX + '/input/button.html');
|
2020-08-07 21:19:15 +03:00
|
|
|
const error = await page.click('button', { timeout: 2000, __testHookBeforePointerAction: () => new Promise(f => setTimeout(f, 2500))} as any).catch(e => e);
|
2020-08-03 23:41:48 +03:00
|
|
|
await page.waitForTimeout(5000); // Give it some time to click after the test hook is done waiting.
|
2020-08-07 21:19:15 +03:00
|
|
|
expect(await page.evaluate('result')).toBe('Was not clicked');
|
2020-08-03 23:41:48 +03:00
|
|
|
expect(error.message).toContain('page.click: Timeout 2000ms exceeded.');
|
|
|
|
});
|
|
|
|
|
2020-08-28 14:20:29 +03:00
|
|
|
it('should timeout waiting for button to be enabled', async ({page, server}) => {
|
2020-08-03 23:41:48 +03:00
|
|
|
await page.setContent('<button onclick="javascript:window.__CLICKED=true;" disabled><span>Click target</span></button>');
|
|
|
|
const error = await page.click('text=Click target', { timeout: 3000 }).catch(e => e);
|
2020-08-07 21:19:15 +03:00
|
|
|
expect(await page.evaluate('window.__CLICKED')).toBe(undefined);
|
2020-08-03 23:41:48 +03:00
|
|
|
expect(error.message).toContain('page.click: Timeout 3000ms exceeded.');
|
|
|
|
expect(error.message).toContain('element is disabled - waiting');
|
|
|
|
});
|