forked from mirrors/gecko-dev
		
	Backed out 2 changesets (bug 1877469) for causing Wd failures at context_destroyed.py CLOSED TREE
Backed out changeset 9bda3647e32c (bug 1877469) Backed out changeset 4aa0d79f3e06 (bug 1877469)
This commit is contained in:
		
							parent
							
								
									088e9994b4
								
							
						
					
					
						commit
						f0a3839410
					
				
					 8 changed files with 80 additions and 141 deletions
				
			
		|  | @ -145,9 +145,6 @@ const COMMON_PREFERENCES = new Map([ | ||||||
|   // Do not redirect user when a milstone upgrade of Firefox is detected
 |   // Do not redirect user when a milstone upgrade of Firefox is detected
 | ||||||
|   ["browser.startup.homepage_override.mstone", "ignore"], |   ["browser.startup.homepage_override.mstone", "ignore"], | ||||||
| 
 | 
 | ||||||
|   // Unload the previously selected tab immediately
 |  | ||||||
|   ["browser.tabs.remote.unloadDelayMs", 0], |  | ||||||
| 
 |  | ||||||
|   // Don't unload tabs when available memory is running low
 |   // Don't unload tabs when available memory is running low
 | ||||||
|   ["browser.tabs.unloadOnLowMemory", false], |   ["browser.tabs.unloadOnLowMemory", false], | ||||||
| 
 | 
 | ||||||
|  |  | ||||||
|  | @ -885,7 +885,7 @@ | ||||||
|   { |   { | ||||||
|     "testIdPattern": "[page.spec] Page Page.bringToFront should work", |     "testIdPattern": "[page.spec] Page Page.bringToFront should work", | ||||||
|     "platforms": ["darwin", "linux", "win32"], |     "platforms": ["darwin", "linux", "win32"], | ||||||
|     "parameters": ["chrome", "webDriverBiDi"], |     "parameters": ["webDriverBiDi"], | ||||||
|     "expectations": ["FAIL"] |     "expectations": ["FAIL"] | ||||||
|   }, |   }, | ||||||
|   { |   { | ||||||
|  |  | ||||||
|  | @ -232,25 +232,11 @@ class BrowsingContextModule extends Module { | ||||||
|       ); |       ); | ||||||
|     } |     } | ||||||
| 
 | 
 | ||||||
|     const targetTab = lazy.TabManager.getTabForBrowsingContext(context); |     const tab = lazy.TabManager.getTabForBrowsingContext(context); | ||||||
|     const targetWindow = lazy.TabManager.getWindowForTab(targetTab); |     const window = lazy.TabManager.getWindowForTab(tab); | ||||||
|     const selectedTab = lazy.TabManager.getTabBrowser(targetWindow).selectedTab; |  | ||||||
| 
 | 
 | ||||||
|     const activated = [ |     await lazy.windowManager.focusWindow(window); | ||||||
|       lazy.windowManager.focusWindow(targetWindow), |     await lazy.TabManager.selectTab(tab); | ||||||
|       lazy.TabManager.selectTab(targetTab), |  | ||||||
|     ]; |  | ||||||
| 
 |  | ||||||
|     if (targetTab !== selectedTab) { |  | ||||||
|       // We need to wait until the "document.visibilityState" of the currently
 |  | ||||||
|       // selected tab in the target window is marked as "hidden".
 |  | ||||||
|       const selectedBrowser = lazy.TabManager.getBrowserForTab(selectedTab); |  | ||||||
|       activated.push( |  | ||||||
|         this.#waitForVisibilityChange(selectedBrowser.browsingContext) |  | ||||||
|       ); |  | ||||||
|     } |  | ||||||
| 
 |  | ||||||
|     await Promise.all(activated); |  | ||||||
|   } |   } | ||||||
| 
 | 
 | ||||||
|   /** |   /** | ||||||
|  | @ -561,39 +547,17 @@ class BrowsingContextModule extends Module { | ||||||
|           ); |           ); | ||||||
|         } |         } | ||||||
| 
 | 
 | ||||||
|         // The window to open the new tab in.
 |  | ||||||
|         let window = Services.wm.getMostRecentWindow(null); |  | ||||||
| 
 |  | ||||||
|         let referenceTab; |         let referenceTab; | ||||||
|         if (referenceContext !== null) { |         if (referenceContext !== null) { | ||||||
|           referenceTab = |           referenceTab = | ||||||
|             lazy.TabManager.getTabForBrowsingContext(referenceContext); |             lazy.TabManager.getTabForBrowsingContext(referenceContext); | ||||||
|           window = lazy.TabManager.getWindowForTab(referenceTab); |  | ||||||
|         } |         } | ||||||
| 
 | 
 | ||||||
|         const promises = []; |         const tab = await lazy.TabManager.addTab({ | ||||||
| 
 |           focus: !background, | ||||||
|         if (!background) { |           referenceTab, | ||||||
|           // When opening a new foreground tab we need to wait until the
 |           userContextId: userContext, | ||||||
|           // "document.visibilityState" of the currently selected tab in this
 |         }); | ||||||
|           // window is marked as "hidden".
 |  | ||||||
|           const selectedTab = lazy.TabManager.getTabBrowser(window).selectedTab; |  | ||||||
|           promises.push( |  | ||||||
|             this.#waitForVisibilityChange( |  | ||||||
|               lazy.TabManager.getBrowserForTab(selectedTab).browsingContext |  | ||||||
|             ) |  | ||||||
|           ); |  | ||||||
|         } |  | ||||||
| 
 |  | ||||||
|         promises.unshift( |  | ||||||
|           lazy.TabManager.addTab({ |  | ||||||
|             focus: !background, |  | ||||||
|             referenceTab, |  | ||||||
|             userContextId: userContext, |  | ||||||
|           }) |  | ||||||
|         ); |  | ||||||
| 
 |  | ||||||
|         const [tab] = await Promise.all(promises); |  | ||||||
|         browser = lazy.TabManager.getBrowserForTab(tab); |         browser = lazy.TabManager.getBrowserForTab(tab); | ||||||
|     } |     } | ||||||
| 
 | 
 | ||||||
|  | @ -1954,21 +1918,6 @@ class BrowsingContextModule extends Module { | ||||||
|     } |     } | ||||||
|   } |   } | ||||||
| 
 | 
 | ||||||
|   #waitForVisibilityChange(browsingContext) { |  | ||||||
|     return this.messageHandler.forwardCommand({ |  | ||||||
|       moduleName: "browsingContext", |  | ||||||
|       commandName: "_awaitVisibilityState", |  | ||||||
|       destination: { |  | ||||||
|         type: lazy.WindowGlobalMessageHandler.type, |  | ||||||
|         id: browsingContext.id, |  | ||||||
|       }, |  | ||||||
|       params: { |  | ||||||
|         value: "hidden", |  | ||||||
|       }, |  | ||||||
|       retryOnAbort: true, |  | ||||||
|     }); |  | ||||||
|   } |  | ||||||
| 
 |  | ||||||
|   /** |   /** | ||||||
|    * Internal commands |    * Internal commands | ||||||
|    */ |    */ | ||||||
|  |  | ||||||
|  | @ -17,7 +17,6 @@ ChromeUtils.defineESModuleGetters(lazy, { | ||||||
|     "chrome://remote/content/webdriver-bidi/modules/root/browsingContext.sys.mjs", |     "chrome://remote/content/webdriver-bidi/modules/root/browsingContext.sys.mjs", | ||||||
|   OriginType: |   OriginType: | ||||||
|     "chrome://remote/content/webdriver-bidi/modules/root/browsingContext.sys.mjs", |     "chrome://remote/content/webdriver-bidi/modules/root/browsingContext.sys.mjs", | ||||||
|   PollPromise: "chrome://remote/content/shared/Sync.sys.mjs", |  | ||||||
| }); | }); | ||||||
| 
 | 
 | ||||||
| const DOCUMENT_FRAGMENT_NODE = 11; | const DOCUMENT_FRAGMENT_NODE = 11; | ||||||
|  | @ -357,29 +356,6 @@ class BrowsingContextModule extends WindowGlobalBiDiModule { | ||||||
|     }); |     }); | ||||||
|   } |   } | ||||||
| 
 | 
 | ||||||
|   /** |  | ||||||
|    * Waits until the visibility state of the document has the expected value. |  | ||||||
|    * |  | ||||||
|    * @param {object} options |  | ||||||
|    * @param {number} options.value |  | ||||||
|    *     Expected value of the visibility state. |  | ||||||
|    * |  | ||||||
|    * @returns {Promise} |  | ||||||
|    *     Promise that resolves when the visibility state has the expected value. |  | ||||||
|    */ |  | ||||||
|   async _awaitVisibilityState(options) { |  | ||||||
|     const { value } = options; |  | ||||||
|     const win = this.messageHandler.window; |  | ||||||
| 
 |  | ||||||
|     await lazy.PollPromise((resolve, reject) => { |  | ||||||
|       if (win.document.visibilityState === value) { |  | ||||||
|         resolve(); |  | ||||||
|       } else { |  | ||||||
|         reject(); |  | ||||||
|       } |  | ||||||
|     }); |  | ||||||
|   } |  | ||||||
| 
 |  | ||||||
|   _getBaseURL() { |   _getBaseURL() { | ||||||
|     return this.messageHandler.window.document.baseURI; |     return this.messageHandler.window.document.baseURI; | ||||||
|   } |   } | ||||||
|  |  | ||||||
|  | @ -53,13 +53,6 @@ def assert_browsing_context( | ||||||
|     assert info["userContext"] == user_context |     assert info["userContext"] == user_context | ||||||
| 
 | 
 | ||||||
| 
 | 
 | ||||||
| async def assert_document_status(bidi_session, context, visible, focused): |  | ||||||
|     state = "visible" if visible else "hidden" |  | ||||||
| 
 |  | ||||||
|     assert await get_visibility_state(bidi_session, context) == state |  | ||||||
|     assert await get_document_focus(bidi_session, context) is focused |  | ||||||
| 
 |  | ||||||
| 
 |  | ||||||
| def assert_navigation_info(event, expected_navigation_info): | def assert_navigation_info(event, expected_navigation_info): | ||||||
|     recursive_compare( |     recursive_compare( | ||||||
|         { |         { | ||||||
|  |  | ||||||
|  | @ -3,7 +3,7 @@ from typing import Any, Mapping | ||||||
| from webdriver.bidi.modules.script import ContextTarget | from webdriver.bidi.modules.script import ContextTarget | ||||||
| 
 | 
 | ||||||
| 
 | 
 | ||||||
| async def is_element_focused(bidi_session, context: Mapping[str, Any], selector: str) -> bool: | async def is_selector_focused(bidi_session, context: Mapping[str, Any], selector: str) -> bool: | ||||||
|     result = await bidi_session.script.call_function( |     result = await bidi_session.script.call_function( | ||||||
|         function_declaration="""(selector) => { |         function_declaration="""(selector) => { | ||||||
|         return document.querySelector(selector) === document.activeElement; |         return document.querySelector(selector) === document.activeElement; | ||||||
|  | @ -13,5 +13,4 @@ async def is_element_focused(bidi_session, context: Mapping[str, Any], selector: | ||||||
|         ], |         ], | ||||||
|         target=ContextTarget(context["context"]), |         target=ContextTarget(context["context"]), | ||||||
|         await_promise=False) |         await_promise=False) | ||||||
| 
 |  | ||||||
|     return result["value"] |     return result["value"] | ||||||
|  |  | ||||||
|  | @ -1,62 +1,95 @@ | ||||||
| import pytest | import pytest | ||||||
| 
 | 
 | ||||||
| from webdriver.bidi.modules.script import ContextTarget | from webdriver.bidi.modules.script import ContextTarget | ||||||
| from . import is_element_focused | from . import is_selector_focused | ||||||
| from .. import assert_document_status | from .. import get_document_focus, get_visibility_state | ||||||
| 
 | 
 | ||||||
| pytestmark = pytest.mark.asyncio | pytestmark = pytest.mark.asyncio | ||||||
| 
 | 
 | ||||||
| 
 | 
 | ||||||
| @pytest.mark.parametrize("type_hint", ["tab", "window"]) | async def test_activate(bidi_session, new_tab, top_context): | ||||||
| async def test_switch_between_contexts(bidi_session, top_context, type_hint): |     assert await get_document_focus(bidi_session, top_context) is False | ||||||
|     is_window = type_hint == "window" |  | ||||||
| 
 |  | ||||||
|     new_context = await bidi_session.browsing_context.create(type_hint=type_hint) |  | ||||||
| 
 | 
 | ||||||
|     await bidi_session.browsing_context.activate(context=top_context["context"]) |     await bidi_session.browsing_context.activate(context=top_context["context"]) | ||||||
|     await assert_document_status(bidi_session, top_context, True, True) |  | ||||||
|     await assert_document_status(bidi_session, new_context, is_window, False) |  | ||||||
| 
 | 
 | ||||||
|     await bidi_session.browsing_context.activate(context=new_context["context"]) |     assert await get_visibility_state(bidi_session, top_context) == 'visible' | ||||||
|     await assert_document_status(bidi_session, top_context, is_window, False) |     assert await get_document_focus(bidi_session, top_context) is True | ||||||
|     await assert_document_status(bidi_session, new_context, True, True) |  | ||||||
| 
 | 
 | ||||||
| 
 | 
 | ||||||
| async def test_keeps_element_focused(bidi_session, inline, new_tab, top_context): | async def test_deactivates_other_contexts(bidi_session, new_tab, top_context): | ||||||
|     await bidi_session.browsing_context.navigate( |     await bidi_session.browsing_context.activate(context=top_context["context"]) | ||||||
|         context=new_tab["context"], | 
 | ||||||
|         url=inline("<textarea autofocus></textarea><input>"), |     assert await get_visibility_state(bidi_session, top_context) == 'visible' | ||||||
|         wait="complete") |     assert await get_document_focus(bidi_session, top_context) is True | ||||||
|  | 
 | ||||||
|  |     assert await get_document_focus(bidi_session, new_tab) is False | ||||||
|  | 
 | ||||||
|  |     await bidi_session.browsing_context.activate(context=new_tab["context"]) | ||||||
|  | 
 | ||||||
|  |     assert await get_document_focus(bidi_session, top_context) is False | ||||||
|  | 
 | ||||||
|  |     assert await get_visibility_state(bidi_session, new_tab) == 'visible' | ||||||
|  |     assert await get_document_focus(bidi_session, new_tab) is True | ||||||
|  | 
 | ||||||
|  | 
 | ||||||
|  | async def test_keeps_focused_area(bidi_session, inline, new_tab, top_context): | ||||||
|  |     await bidi_session.browsing_context.activate(context=new_tab["context"]) | ||||||
|  |     assert await get_visibility_state(bidi_session, new_tab) == 'visible' | ||||||
|  |     assert await get_document_focus(bidi_session, new_tab) is True | ||||||
|  | 
 | ||||||
|  |     await bidi_session.browsing_context.navigate(context=new_tab["context"], | ||||||
|  |                                                  url=inline("<textarea autofocus></textarea><input>"), | ||||||
|  |                                                  wait="complete") | ||||||
| 
 | 
 | ||||||
|     await bidi_session.script.evaluate( |     await bidi_session.script.evaluate( | ||||||
|         expression="""document.querySelector("input").focus()""", |         expression="""document.querySelector("input").focus()""", | ||||||
|         target=ContextTarget(new_tab["context"]), |         target=ContextTarget(new_tab["context"]), | ||||||
|         await_promise=False) |         await_promise=False) | ||||||
| 
 | 
 | ||||||
|     assert await is_element_focused(bidi_session, new_tab, "input") |     assert await is_selector_focused(bidi_session, new_tab, "input") | ||||||
| 
 | 
 | ||||||
|     await bidi_session.browsing_context.activate(context=top_context["context"]) |     await bidi_session.browsing_context.activate(context=top_context["context"]) | ||||||
|     assert await is_element_focused(bidi_session, new_tab, "input") |     assert await get_document_focus(bidi_session, new_tab) is False | ||||||
|  |     assert await is_selector_focused(bidi_session, new_tab, "input") | ||||||
| 
 | 
 | ||||||
|     await bidi_session.browsing_context.activate(context=new_tab["context"]) |     await bidi_session.browsing_context.activate(context=new_tab["context"]) | ||||||
|     assert await is_element_focused(bidi_session, new_tab, "input") |     assert await get_visibility_state(bidi_session, new_tab) == 'visible' | ||||||
|  |     assert await get_document_focus(bidi_session, new_tab) is True | ||||||
|  |     assert await is_selector_focused(bidi_session, new_tab, "input") | ||||||
| 
 | 
 | ||||||
| 
 | 
 | ||||||
| async def test_multiple_activation(bidi_session, inline, new_tab): | async def test_double_activation(bidi_session, inline, new_tab): | ||||||
|     await bidi_session.browsing_context.navigate( |     await bidi_session.browsing_context.activate(context=new_tab["context"]) | ||||||
|         context=new_tab["context"], |     assert await get_visibility_state(bidi_session, new_tab) == 'visible' | ||||||
|         url=inline( |     assert await get_document_focus(bidi_session, new_tab) is True | ||||||
|             "<input><script>document.querySelector('input').focus();</script>"), |  | ||||||
|         wait="complete") |  | ||||||
| 
 | 
 | ||||||
|     await assert_document_status(bidi_session, new_tab, True, True) |     await bidi_session.browsing_context.navigate(context=new_tab["context"], | ||||||
|     assert await is_element_focused(bidi_session, new_tab, "input") |                                                  url=inline("<input><script>document.querySelector('input').focus();</script>"), | ||||||
|  |                                                  wait="complete") | ||||||
|  |     assert await is_selector_focused(bidi_session, new_tab, "input") | ||||||
| 
 | 
 | ||||||
|     await bidi_session.browsing_context.activate(context=new_tab["context"]) |     await bidi_session.browsing_context.activate(context=new_tab["context"]) | ||||||
|     await assert_document_status(bidi_session, new_tab, True, True) |     assert await get_visibility_state(bidi_session, new_tab) == 'visible' | ||||||
|     assert await is_element_focused(bidi_session, new_tab, "input") |     assert await get_document_focus(bidi_session, new_tab) is True | ||||||
|  |     assert await is_selector_focused(bidi_session, new_tab, "input") | ||||||
| 
 | 
 | ||||||
|     # Activate again. |     # Activate again. | ||||||
|     await bidi_session.browsing_context.activate(context=new_tab["context"]) |     await bidi_session.browsing_context.activate(context=new_tab["context"]) | ||||||
|     await assert_document_status(bidi_session, new_tab, True, True) |     assert await get_visibility_state(bidi_session, new_tab) == 'visible' | ||||||
|     assert await is_element_focused(bidi_session, new_tab, "input") |     assert await get_document_focus(bidi_session, new_tab) is True | ||||||
|  |     assert await is_selector_focused(bidi_session, new_tab, "input") | ||||||
|  | 
 | ||||||
|  | 
 | ||||||
|  | async def test_activate_window(bidi_session): | ||||||
|  |     new_window_1 = await bidi_session.browsing_context.create(type_hint="window") | ||||||
|  |     new_window_2 = await bidi_session.browsing_context.create(type_hint="window") | ||||||
|  | 
 | ||||||
|  |     assert await get_visibility_state(bidi_session, new_window_2) == 'visible' | ||||||
|  |     assert await get_document_focus(bidi_session, new_window_2) is True | ||||||
|  | 
 | ||||||
|  |     assert await get_document_focus(bidi_session, new_window_1) is False | ||||||
|  | 
 | ||||||
|  |     await bidi_session.browsing_context.activate(context=new_window_1["context"]) | ||||||
|  | 
 | ||||||
|  |     assert await get_visibility_state(bidi_session, new_window_1) == 'visible' | ||||||
|  |     assert await get_document_focus(bidi_session, new_window_1) is True | ||||||
|  |  | ||||||
|  | @ -1,27 +1,19 @@ | ||||||
| import pytest | import pytest | ||||||
| 
 | 
 | ||||||
|  | from .. import assert_browsing_context | ||||||
| from webdriver.bidi.modules.script import ContextTarget | from webdriver.bidi.modules.script import ContextTarget | ||||||
| from .. import assert_browsing_context, assert_document_status |  | ||||||
| 
 |  | ||||||
| 
 | 
 | ||||||
| pytestmark = pytest.mark.asyncio | pytestmark = pytest.mark.asyncio | ||||||
| 
 | 
 | ||||||
| 
 | 
 | ||||||
| @pytest.mark.parametrize("type_hint", ["tab", "window"]) | @pytest.mark.parametrize("value", ["tab", "window"]) | ||||||
| async def test_type(bidi_session, top_context, type_hint): | async def test_type(bidi_session, value): | ||||||
|     is_window = type_hint == "window" |  | ||||||
| 
 |  | ||||||
|     contexts = await bidi_session.browsing_context.get_tree(max_depth=0) |     contexts = await bidi_session.browsing_context.get_tree(max_depth=0) | ||||||
|     assert len(contexts) == 1 |     assert len(contexts) == 1 | ||||||
| 
 | 
 | ||||||
|     await assert_document_status(bidi_session, top_context, True, True) |     new_context = await bidi_session.browsing_context.create(type_hint=value) | ||||||
| 
 |  | ||||||
|     new_context = await bidi_session.browsing_context.create(type_hint=type_hint) |  | ||||||
|     assert contexts[0]["context"] != new_context["context"] |     assert contexts[0]["context"] != new_context["context"] | ||||||
| 
 | 
 | ||||||
|     await assert_document_status(bidi_session, new_context, True, True) |  | ||||||
|     await assert_document_status(bidi_session, top_context, is_window, False) |  | ||||||
| 
 |  | ||||||
|     # Check there is an additional browsing context |     # Check there is an additional browsing context | ||||||
|     contexts = await bidi_session.browsing_context.get_tree(max_depth=0) |     contexts = await bidi_session.browsing_context.get_tree(max_depth=0) | ||||||
|     assert len(contexts) == 2 |     assert len(contexts) == 2 | ||||||
|  |  | ||||||
		Loading…
	
		Reference in a new issue
	
	 Cristina Horotan
						Cristina Horotan