Skip to content

Commit 3aecfcf

Browse files
authored
fix: context.request timeout (#3032)
1 parent 47a5d35 commit 3aecfcf

File tree

2 files changed

+37
-0
lines changed

2 files changed

+37
-0
lines changed

playwright/_impl/_browser_context.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -124,6 +124,7 @@ def __init__(
124124
self._tracing = cast(Tracing, from_channel(initializer["tracing"]))
125125
self._har_recorders: Dict[str, HarRecordingMetadata] = {}
126126
self._request: APIRequestContext = from_channel(initializer["requestContext"])
127+
self._request._timeout_settings = self._timeout_settings
127128
self._clock = Clock(self)
128129
self._channel.on(
129130
"bindingCall",
Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
1+
# Copyright (c) Microsoft Corporation.
2+
#
3+
# Licensed under the Apache License, Version 2.0 (the "License");
4+
# you may not use this file except in compliance with the License.
5+
# You may obtain a copy of the License at
6+
#
7+
# http://www.apache.org/licenses/LICENSE-2.0
8+
#
9+
# Unless required by applicable law or agreed to in writing, software
10+
# distributed under the License is distributed on an "AS IS" BASIS,
11+
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12+
# See the License for the specific language governing permissions and
13+
# limitations under the License.
14+
15+
import pytest
16+
17+
from playwright.sync_api import BrowserContext, Error, Page
18+
from tests.server import Server
19+
20+
21+
def test_context_request_should_support_timeout_option(
22+
page: Page, context: BrowserContext, server: Server
23+
) -> None:
24+
# https://github.com/microsoft/playwright/issues/39220
25+
26+
server.set_route("/", lambda req: None)
27+
with pytest.raises(Error, match="Timeout 123ms exceeded"):
28+
page.request.get(server.PREFIX, timeout=123)
29+
with pytest.raises(Error, match="Timeout 123ms exceeded"):
30+
context.request.get(server.PREFIX, timeout=123)
31+
32+
context.set_default_timeout(123)
33+
with pytest.raises(Error, match="Timeout 123ms exceeded"):
34+
page.request.get(server.PREFIX)
35+
with pytest.raises(Error, match="Timeout 123ms exceeded"):
36+
context.request.get(server.PREFIX)

0 commit comments

Comments
 (0)