Bug 1305822 - [marionette] WebDriver:SwitchToWindow should switch back to the top-level browsing context. r=marionette-reviewers,webdriver-reviewers,maja_zf

Differential Revision: https://phabricator.services.mozilla.com/D94709
This commit is contained in:
Henrik Skupin 2020-10-26 16:09:48 +00:00
Родитель d40666da1d
Коммит b19c361d72
2 изменённых файлов: 23 добавлений и 0 удалений

Просмотреть файл

@ -1613,6 +1613,15 @@ GeckoDriver.prototype.switchToWindow = async function(cmd) {
try {
await this.setWindowHandle(found, focus);
selected = true;
// Temporarily inform the framescript of the current browsing context to
// allow sending the correct page load events. This has to be done until
// the framescript is no longer in use (bug 1669172).
if (this.context == Context.Content) {
await this.listener.setBrowsingContextId(
this.contentBrowsingContext.id
);
}
} catch (e) {
logger.error(e);
}

Просмотреть файл

@ -1,6 +1,7 @@
from webdriver.transport import Response
from tests.support.asserts import assert_error, assert_success
from tests.support.inline import iframe, inline
def switch_to_window(session, handle):
@ -51,3 +52,16 @@ def test_no_browsing_context(session, url):
assert_success(response)
assert session.window_handle == new_handle
def test_switch_to_window_sets_top_level_context(session):
session.url = inline(iframe("<p>foo"))
frame = session.find.css("iframe", all=False)
session.switch_frame(frame)
session.find.css("p", all=False)
response = switch_to_window(session, session.window_handle)
assert_success(response)
session.find.css("iframe", all=False)