Skip to content

Commit 7d36a41

Browse files
committed
add message test
1 parent 1894441 commit 7d36a41

File tree

1 file changed

+24
-0
lines changed

1 file changed

+24
-0
lines changed

tests/async/test_extension.py

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,13 +12,16 @@
1212
# See the License for the specific language governing permissions and
1313
# limitations under the License.
1414

15+
import asyncio
1516
from pathlib import Path
1617
from typing import Any, Awaitable, Callable, Dict, Generator, Optional
1718

1819
import pytest
1920

2021
from playwright.async_api import BrowserContext, BrowserType
2122

23+
from ..server import Server
24+
2225

2326
@pytest.fixture()
2427
def launch_persistent_context(
@@ -91,3 +94,24 @@ async def test_should_give_access_to_the_service_worker_when_recording_video(
9194
assert await service_worker.evaluate("globalThis.MAGIC") == 42
9295
await context.close()
9396
assert len(context.background_pages) == 0
97+
98+
99+
# https://github.com/microsoft/playwright/issues/32762
100+
@pytest.mark.only_browser("chromium")
101+
async def test_should_report_console_messages_from_content_script(
102+
launch_persistent_context: Any,
103+
assetdir: Path,
104+
server: Server,
105+
) -> None:
106+
extension_path = str(assetdir / "extension-mv3-with-logging")
107+
context: BrowserContext = await launch_persistent_context(extension_path)
108+
page = await context.new_page()
109+
[message, _] = await asyncio.gather(
110+
page.context.wait_for_event(
111+
"console",
112+
lambda e: "Test console log from a third-party execution context" in e.text,
113+
),
114+
page.goto(server.EMPTY_PAGE),
115+
)
116+
assert "Test console log from a third-party execution context" in message.text
117+
await context.close()

0 commit comments

Comments
 (0)