Debian Codegraph @

testing/web-platform/mozilla/tests/webdriver/bidi/browsing_context/navigate/error.py

raw
1 from copy import deepcopy
2
3 import pytest
4 from tests.bidi.browsing_context.navigate import navigate_and_assert
5
6 pytestmark = pytest.mark.asyncio
7
8
9 async def test_insecure_certificate(
10 configuration, url, create_custom_profile, geckodriver
11 ):
12 # Create a fresh profile without any item in the certificate storage so that
13 # loading a HTTPS page will cause an insecure certificate error
14 custom_profile = create_custom_profile(clone=False)
15
16 config = deepcopy(configuration)
17 config["capabilities"]["moz:firefoxOptions"]["args"] = [
18 "--profile",
19 custom_profile.profile,
20 ]
21 # Capability matching not implemented yet for WebDriver BiDi (bug 1713784)
22 config["capabilities"]["acceptInsecureCerts"] = False
23 config["capabilities"]["webSocketUrl"] = True
24
25 driver = geckodriver(config=config)
26 driver.new_session()
27
28 bidi_session = driver.session.bidi_session
29 await bidi_session.start()
30
31 contexts = await bidi_session.browsing_context.get_tree(max_depth=0)
32 await navigate_and_assert(
33 bidi_session,
34 contexts[0],
35 url("/common/blank.html", protocol="https"),
36 expected_error=True,
37 )
38
39 # If the error page hasn't fully loaded yet, running a BiDi command
40 # in most of the cases will trigger an error like:
41 # `AbortError: Actor 'MessageHandlerFrame' destroyed before query`
42 result = await bidi_session.browsing_context.locate_nodes(
43 context=contexts[0]["context"],
44 locator={"type": "css", "value": "body"},
45 )
46 assert len(result["nodes"]) > 0
47
48
49 async def test_invalid_content_encoding(bidi_session, new_tab, inline):
50 await navigate_and_assert(
51 bidi_session,
52 new_tab,
53 f"{inline('<div>foo')}&pipe=header(Content-Encoding,gzip)",
54 expected_error=True,
55 )
56
57 # If the error page hasn't fully loaded yet, running a BiDi command
58 # in most of the cases will trigger an error like:
59 # `AbortError: Actor 'MessageHandlerFrame' destroyed before query`
60 result = await bidi_session.browsing_context.locate_nodes(
61 context=new_tab["context"],
62 locator={"type": "css", "value": "body"},
63 )
64 assert len(result["nodes"]) > 0