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
|
||||
["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
|
||||
["browser.tabs.unloadOnLowMemory", false],
|
||||
|
||||
|
|
|
|||
|
|
@ -885,7 +885,7 @@
|
|||
{
|
||||
"testIdPattern": "[page.spec] Page Page.bringToFront should work",
|
||||
"platforms": ["darwin", "linux", "win32"],
|
||||
"parameters": ["chrome", "webDriverBiDi"],
|
||||
"parameters": ["webDriverBiDi"],
|
||||
"expectations": ["FAIL"]
|
||||
},
|
||||
{
|
||||
|
|
|
|||
|
|
@ -232,25 +232,11 @@ class BrowsingContextModule extends Module {
|
|||
);
|
||||
}
|
||||
|
||||
const targetTab = lazy.TabManager.getTabForBrowsingContext(context);
|
||||
const targetWindow = lazy.TabManager.getWindowForTab(targetTab);
|
||||
const selectedTab = lazy.TabManager.getTabBrowser(targetWindow).selectedTab;
|
||||
const tab = lazy.TabManager.getTabForBrowsingContext(context);
|
||||
const window = lazy.TabManager.getWindowForTab(tab);
|
||||
|
||||
const activated = [
|
||||
lazy.windowManager.focusWindow(targetWindow),
|
||||
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);
|
||||
await lazy.windowManager.focusWindow(window);
|
||||
await lazy.TabManager.selectTab(tab);
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
@ -561,39 +547,17 @@ class BrowsingContextModule extends Module {
|
|||
);
|
||||
}
|
||||
|
||||
// The window to open the new tab in.
|
||||
let window = Services.wm.getMostRecentWindow(null);
|
||||
|
||||
let referenceTab;
|
||||
if (referenceContext !== null) {
|
||||
referenceTab =
|
||||
lazy.TabManager.getTabForBrowsingContext(referenceContext);
|
||||
window = lazy.TabManager.getWindowForTab(referenceTab);
|
||||
}
|
||||
|
||||
const promises = [];
|
||||
|
||||
if (!background) {
|
||||
// When opening a new foreground tab we need to wait until the
|
||||
// "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);
|
||||
const tab = await lazy.TabManager.addTab({
|
||||
focus: !background,
|
||||
referenceTab,
|
||||
userContextId: userContext,
|
||||
});
|
||||
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
|
||||
*/
|
||||
|
|
|
|||
|
|
@ -17,7 +17,6 @@ ChromeUtils.defineESModuleGetters(lazy, {
|
|||
"chrome://remote/content/webdriver-bidi/modules/root/browsingContext.sys.mjs",
|
||||
OriginType:
|
||||
"chrome://remote/content/webdriver-bidi/modules/root/browsingContext.sys.mjs",
|
||||
PollPromise: "chrome://remote/content/shared/Sync.sys.mjs",
|
||||
});
|
||||
|
||||
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() {
|
||||
return this.messageHandler.window.document.baseURI;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -53,13 +53,6 @@ def assert_browsing_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):
|
||||
recursive_compare(
|
||||
{
|
||||
|
|
|
|||
|
|
@ -3,7 +3,7 @@ from typing import Any, Mapping
|
|||
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(
|
||||
function_declaration="""(selector) => {
|
||||
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"]),
|
||||
await_promise=False)
|
||||
|
||||
return result["value"]
|
||||
|
|
|
|||
|
|
@ -1,62 +1,95 @@
|
|||
import pytest
|
||||
|
||||
from webdriver.bidi.modules.script import ContextTarget
|
||||
from . import is_element_focused
|
||||
from .. import assert_document_status
|
||||
from . import is_selector_focused
|
||||
from .. import get_document_focus, get_visibility_state
|
||||
|
||||
pytestmark = pytest.mark.asyncio
|
||||
|
||||
|
||||
@pytest.mark.parametrize("type_hint", ["tab", "window"])
|
||||
async def test_switch_between_contexts(bidi_session, top_context, type_hint):
|
||||
is_window = type_hint == "window"
|
||||
|
||||
new_context = await bidi_session.browsing_context.create(type_hint=type_hint)
|
||||
async def test_activate(bidi_session, new_tab, top_context):
|
||||
assert await get_document_focus(bidi_session, top_context) is False
|
||||
|
||||
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"])
|
||||
await assert_document_status(bidi_session, top_context, is_window, False)
|
||||
await assert_document_status(bidi_session, new_context, True, True)
|
||||
assert await get_visibility_state(bidi_session, top_context) == 'visible'
|
||||
assert await get_document_focus(bidi_session, top_context) is True
|
||||
|
||||
|
||||
async def test_keeps_element_focused(bidi_session, inline, new_tab, top_context):
|
||||
await bidi_session.browsing_context.navigate(
|
||||
context=new_tab["context"],
|
||||
url=inline("<textarea autofocus></textarea><input>"),
|
||||
wait="complete")
|
||||
async def test_deactivates_other_contexts(bidi_session, new_tab, top_context):
|
||||
await bidi_session.browsing_context.activate(context=top_context["context"])
|
||||
|
||||
assert await get_visibility_state(bidi_session, top_context) == 'visible'
|
||||
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(
|
||||
expression="""document.querySelector("input").focus()""",
|
||||
target=ContextTarget(new_tab["context"]),
|
||||
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"])
|
||||
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"])
|
||||
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):
|
||||
await bidi_session.browsing_context.navigate(
|
||||
context=new_tab["context"],
|
||||
url=inline(
|
||||
"<input><script>document.querySelector('input').focus();</script>"),
|
||||
wait="complete")
|
||||
async def test_double_activation(bidi_session, inline, new_tab):
|
||||
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 assert_document_status(bidi_session, new_tab, True, True)
|
||||
assert await is_element_focused(bidi_session, new_tab, "input")
|
||||
await bidi_session.browsing_context.navigate(context=new_tab["context"],
|
||||
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 assert_document_status(bidi_session, new_tab, True, True)
|
||||
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")
|
||||
|
||||
# Activate again.
|
||||
await bidi_session.browsing_context.activate(context=new_tab["context"])
|
||||
await assert_document_status(bidi_session, new_tab, True, True)
|
||||
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_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
|
||||
|
||||
from .. import assert_browsing_context
|
||||
from webdriver.bidi.modules.script import ContextTarget
|
||||
from .. import assert_browsing_context, assert_document_status
|
||||
|
||||
|
||||
pytestmark = pytest.mark.asyncio
|
||||
|
||||
|
||||
@pytest.mark.parametrize("type_hint", ["tab", "window"])
|
||||
async def test_type(bidi_session, top_context, type_hint):
|
||||
is_window = type_hint == "window"
|
||||
|
||||
@pytest.mark.parametrize("value", ["tab", "window"])
|
||||
async def test_type(bidi_session, value):
|
||||
contexts = await bidi_session.browsing_context.get_tree(max_depth=0)
|
||||
assert len(contexts) == 1
|
||||
|
||||
await assert_document_status(bidi_session, top_context, True, True)
|
||||
|
||||
new_context = await bidi_session.browsing_context.create(type_hint=type_hint)
|
||||
new_context = await bidi_session.browsing_context.create(type_hint=value)
|
||||
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
|
||||
contexts = await bidi_session.browsing_context.get_tree(max_depth=0)
|
||||
assert len(contexts) == 2
|
||||
|
|
|
|||
Loading…
Reference in a new issue