-
Notifications
You must be signed in to change notification settings - Fork 1.2k
chore: roll to 1.55.0 #2956
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
chore: roll to 1.55.0 #2956
Changes from 3 commits
Commits
Show all changes
9 commits
Select commit
Hold shift + click to select a range
d9f4c0c
chore: roll to 1.55.0-alpha-1755516433000
Skn0tt 8b47044
drop isVisible from the other
Skn0tt 2b0de14
chore: roll to 1.55
Skn0tt 44157e4
add sync extension tests
Skn0tt 1894441
adapt to async tests
Skn0tt 7d36a41
add message test
Skn0tt 42418dd
poll
Skn0tt 0ff53cd
unflake and type
Skn0tt 21064a2
sleep with playwright
Skn0tt File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,2 @@ | ||
| console.log('hey from the content-script'); | ||
| self.thisIsTheContentScript = true; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,2 @@ | ||
| // Mock script for background extension | ||
| globalThis.MAGIC = 42; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,14 @@ | ||
| { | ||
| "name": "Simple extension", | ||
| "version": "0.1", | ||
| "background": { | ||
| "service_worker": "index.js" | ||
| }, | ||
| "content_scripts": [{ | ||
| "matches": ["<all_urls>"], | ||
| "css": [], | ||
| "js": ["content-script.js"] | ||
| }], | ||
| "permissions": ["background", "activeTab"], | ||
| "manifest_version": 3 | ||
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,5 @@ | ||
| console.log("Service worker script loaded"); | ||
|
|
||
| chrome.runtime.onInstalled.addListener(() => { | ||
| console.log("Extension installed"); | ||
| }); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1 @@ | ||
| console.log("Test console log from a third-party execution context"); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,17 @@ | ||
| { | ||
| "manifest_version": 3, | ||
| "name": "Console Log Extension", | ||
| "version": "1.0", | ||
| "background": { | ||
| "service_worker": "background.js" | ||
| }, | ||
| "permissions": [ | ||
| "tabs" | ||
| ], | ||
| "content_scripts": [ | ||
| { | ||
| "matches": ["<all_urls>"], | ||
| "js": ["content.js"] | ||
| } | ||
| ] | ||
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,117 @@ | ||
| # 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. | ||
|
|
||
| import asyncio | ||
| from pathlib import Path | ||
| from typing import Any, Awaitable, Callable, Dict, Generator, Optional | ||
|
|
||
| import pytest | ||
|
|
||
| from playwright.async_api import BrowserContext, BrowserType | ||
|
|
||
| from ..server import Server | ||
|
|
||
|
|
||
| @pytest.fixture() | ||
| def launch_persistent_context( | ||
| browser_type: BrowserType, | ||
| browser_channel: Optional[str], | ||
| tmp_path: Path, | ||
| launch_arguments: Dict[str, Any], | ||
| is_headless_shell: bool, | ||
| ) -> Generator[Callable[[str], Awaitable[BrowserContext]], None, None]: | ||
| if browser_channel and browser_channel.startswith("chrome"): | ||
| pytest.skip( | ||
| "--load-extension is not supported in Chrome anymore. https://groups.google.com/a/chromium.org/g/chromium-extensions/c/1-g8EFx2BBY/m/S0ET5wPjCAAJ" | ||
| ) | ||
| if is_headless_shell: | ||
| pytest.skip("Headless Shell has no support for extensions") | ||
|
|
||
| async def launch(extension_path: str, **kwargs: Any) -> BrowserContext: | ||
| context = await browser_type.launch_persistent_context( | ||
| str(tmp_path), | ||
| **launch_arguments, | ||
| **kwargs, | ||
| args=[ | ||
| f"--disable-extensions-except={extension_path}", | ||
| f"--load-extension={extension_path}", | ||
| ], | ||
| ) | ||
| return context | ||
|
|
||
| yield launch | ||
|
|
||
|
|
||
| @pytest.mark.only_browser("chromium") | ||
| async def test_should_give_access_to_the_service_worker( | ||
| launch_persistent_context: Any, | ||
|
mxschmitt marked this conversation as resolved.
Outdated
|
||
| assetdir: Path, | ||
| ) -> None: | ||
| extension_path = str(assetdir / "extension-mv3-simple") | ||
| context: BrowserContext = await launch_persistent_context(extension_path) | ||
|
mxschmitt marked this conversation as resolved.
Outdated
|
||
| service_workers = context.service_workers | ||
| service_worker = ( | ||
| service_workers[0] | ||
| if len(service_workers) | ||
| else await context.wait_for_event("backgroundpage") | ||
| ) | ||
| assert service_worker | ||
| assert service_worker in context.service_workers | ||
| assert await service_worker.evaluate("globalThis.MAGIC") == 42 | ||
| await context.close() | ||
| assert len(context.background_pages) == 0 | ||
|
|
||
|
|
||
| @pytest.mark.only_browser("chromium") | ||
| async def test_should_give_access_to_the_service_worker_when_recording_video( | ||
| launch_persistent_context: Any, | ||
|
mxschmitt marked this conversation as resolved.
Outdated
|
||
| tmp_path: Path, | ||
| assetdir: Path, | ||
| ) -> None: | ||
| extension_path = str(assetdir / "extension-mv3-simple") | ||
| context: BrowserContext = await launch_persistent_context( | ||
|
mxschmitt marked this conversation as resolved.
Outdated
|
||
| extension_path, record_video_dir=(tmp_path / "videos") | ||
| ) | ||
| service_workers = context.service_workers | ||
| service_worker = ( | ||
| service_workers[0] | ||
| if len(service_workers) | ||
| else await context.wait_for_event("backgroundpage") | ||
| ) | ||
| assert service_worker | ||
| assert service_worker in context.service_workers | ||
| assert await service_worker.evaluate("globalThis.MAGIC") == 42 | ||
| await context.close() | ||
| assert len(context.background_pages) == 0 | ||
|
|
||
|
|
||
| # https://github.com/microsoft/playwright/issues/32762 | ||
| @pytest.mark.only_browser("chromium") | ||
| async def test_should_report_console_messages_from_content_script( | ||
| launch_persistent_context: Any, | ||
|
mxschmitt marked this conversation as resolved.
Outdated
|
||
| assetdir: Path, | ||
| server: Server, | ||
| ) -> None: | ||
| extension_path = str(assetdir / "extension-mv3-with-logging") | ||
| context: BrowserContext = await launch_persistent_context(extension_path) | ||
|
mxschmitt marked this conversation as resolved.
Outdated
|
||
| page = await context.new_page() | ||
| [message, _] = await asyncio.gather( | ||
| page.context.wait_for_event( | ||
| "console", | ||
| lambda e: "Test console log from a third-party execution context" in e.text, | ||
| ), | ||
| page.goto(server.EMPTY_PAGE), | ||
| ) | ||
| assert "Test console log from a third-party execution context" in message.text | ||
| await context.close() | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,93 @@ | ||
| # 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. | ||
|
|
||
| from pathlib import Path | ||
| from typing import Any, Callable, Dict, Generator, Optional | ||
|
|
||
| import pytest | ||
|
|
||
| from playwright.sync_api import BrowserContext, BrowserType | ||
|
|
||
|
|
||
| @pytest.fixture() | ||
| def launch_persistent_context( | ||
| browser_type: BrowserType, | ||
| browser_channel: Optional[str], | ||
| tmp_path: Path, | ||
| launch_arguments: Dict[str, Any], | ||
| is_headless_shell: bool, | ||
| ) -> Generator[Callable[[str], BrowserContext], None, None]: | ||
| if browser_channel and browser_channel.startswith("chrome"): | ||
| pytest.skip( | ||
| "--load-extension is not supported in Chrome anymore. https://groups.google.com/a/chromium.org/g/chromium-extensions/c/1-g8EFx2BBY/m/S0ET5wPjCAAJ" | ||
| ) | ||
| if is_headless_shell: | ||
| pytest.skip("Headless Shell has no support for extensions") | ||
|
|
||
| def launch(extension_path: str, **kwargs: Any) -> BrowserContext: | ||
| context = browser_type.launch_persistent_context( | ||
| str(tmp_path), | ||
| **launch_arguments, | ||
| **kwargs, | ||
| args=[ | ||
| f"--disable-extensions-except={extension_path}", | ||
| f"--load-extension={extension_path}", | ||
| ], | ||
| ) | ||
| return context | ||
|
|
||
| yield launch | ||
|
|
||
|
|
||
| @pytest.mark.only_browser("chromium") | ||
| def test_should_give_access_to_the_service_worker( | ||
| launch_persistent_context: Any, | ||
| assetdir: Path, | ||
| ) -> None: | ||
| extension_path = str(assetdir / "extension-mv3-simple") | ||
| context: BrowserContext = launch_persistent_context(extension_path) | ||
| service_workers = context.service_workers | ||
| service_worker = ( | ||
| service_workers[0] | ||
| if len(service_workers) | ||
| else context.wait_for_event("backgroundpage") | ||
| ) | ||
| assert service_worker | ||
| assert service_worker in context.service_workers | ||
| assert service_worker.evaluate("globalThis.MAGIC") == 42 | ||
| context.close() | ||
| assert len(context.background_pages) == 0 | ||
|
|
||
|
|
||
| @pytest.mark.only_browser("chromium") | ||
| def test_should_give_access_to_the_service_worker_when_recording_video( | ||
| launch_persistent_context: Any, | ||
| tmp_path: Path, | ||
| assetdir: Path, | ||
| ) -> None: | ||
| extension_path = str(assetdir / "extension-mv3-simple") | ||
| context: BrowserContext = launch_persistent_context( | ||
| extension_path, record_video_dir=(tmp_path / "videos") | ||
| ) | ||
| service_workers = context.service_workers | ||
| service_worker = ( | ||
| service_workers[0] | ||
| if len(service_workers) | ||
| else context.wait_for_event("backgroundpage") | ||
| ) | ||
| assert service_worker | ||
| assert service_worker in context.service_workers | ||
| assert service_worker.evaluate("globalThis.MAGIC") == 42 | ||
| context.close() | ||
| assert len(context.background_pages) == 0 |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.