Backed out 2 changesets (bug 1661495) as req by whimboo . CLOSED TREE

Backed out changeset c5cdfb592493 (bug 1661495)
Backed out changeset 46f9aa946264 (bug 1661495)
This commit is contained in:
Narcis Beleuzu 2020-08-31 21:47:32 +03:00
Родитель d7d4941cf6
Коммит d70f39e819
5 изменённых файлов: 15 добавлений и 84 удалений

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

@ -397,8 +397,6 @@ GeckoDriver.prototype.getBrowsingContext = function(options = {}) {
browsingContext = browsingContext.top;
}
logger.trace(`Using browsing context with id: ${browsingContext.id}`);
return browsingContext;
};
@ -499,6 +497,8 @@ GeckoDriver.prototype.addBrowser = function(win) {
*/
GeckoDriver.prototype.startBrowser = function(window, isNewSession = false) {
this.mainFrame = window;
this.chromeBrowsingContext = this.mainFrame.browsingContext;
this.contentBrowsingContext = null;
this.addBrowser(window);
this.whenBrowserStarted(window, isNewSession);
@ -592,7 +592,8 @@ GeckoDriver.prototype.registerBrowser = function(id, be) {
this.curBrowser.register(id, be);
}
this.wins.set(id, BrowsingContext.get(id).currentWindowGlobal);
this.contentBrowsingContext = BrowsingContext.get(id);
this.wins.set(id, this.contentBrowsingContext.currentWindowGlobal);
return id;
};
@ -866,12 +867,10 @@ GeckoDriver.prototype.newSession = async function(cmd) {
}
if (this.mainFrame) {
this.chromeBrowsingContext = this.mainFrame.browsingContext;
this.mainFrame.focus();
}
if (this.curBrowser.tab) {
this.contentBrowsingContext = this.curBrowser.contentBrowser.browsingContext;
this.curBrowser.contentBrowser.focus();
}
@ -1708,8 +1707,6 @@ GeckoDriver.prototype.setWindowHandle = async function(
this.startBrowser(winProperties.win, false /* isNewSession */);
this.chromeBrowsingContext = this.mainFrame.browsingContext;
if (registerBrowsers && browserListening) {
await registerBrowsers;
const id = await browserListening;
@ -1720,6 +1717,8 @@ GeckoDriver.prototype.setWindowHandle = async function(
this.curBrowser = this.browsers[winProperties.id];
this.mainFrame = this.curBrowser.window;
this.chromeBrowsingContext = this.mainFrame.browsingContext;
// Activate the tab if it's a content window.
let tab = null;
if (winProperties.hasTabBrowser) {
@ -1730,7 +1729,6 @@ GeckoDriver.prototype.setWindowHandle = async function(
);
}
this.chromeBrowsingContext = this.mainFrame.browsingContext;
this.contentBrowsingContext = tab?.linkedBrowser.browsingContext;
}
@ -3539,21 +3537,6 @@ GeckoDriver.prototype.receiveMessage = function(message) {
case "Marionette:ListenersAttached":
if (message.json.frameId === this.curBrowser.curFrameId) {
const browsingContext = BrowsingContext.get(message.json.frameId);
// If the framescript for the current content browsing context
// has been re-attached due to a remoteness change (the browserId is
// always persistent) then track the new browsing context.
if (
browsingContext.browserId == this.contentBrowsingContext?.browserId
) {
logger.trace(
"Detected remoteness change. New browsing context: " +
browsingContext.id
);
this.contentBrowsingContext = browsingContext;
}
this.curBrowser.flushPendingCommands();
}
break;

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

@ -1,3 +1,2 @@
[new_window.py]
disabled:
if os == "android": GeckoView doesn't support opening new windows
disabled: os == "android": Fennec doesn't support opening new windows

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

@ -4,7 +4,6 @@ from webdriver.transport import Response
from tests.support.asserts import assert_error, assert_success
from tests.support.inline import inline
from tests.support.sync import Poll
def execute_script(session, script, args=None):
@ -29,24 +28,6 @@ def test_no_browsing_context(session, closed_window):
assert_error(response, "no such window")
def test_opening_new_window_keeps_current_window_handle(session):
original_handle = session.window_handle
original_handles = session.handles
url = inline("""<a href="javascript:window.open();">open window</a>""")
session.url = url
session.find.css("a", all=False).click()
wait = Poll(
session,
timeout=5,
message="No new window has been opened")
new_handles = wait.until(lambda s: set(s.handles) - set(original_handles))
assert len(new_handles) == 1
assert session.window_handle == original_handle
assert session.url == url
def test_ending_comment(session):
response = execute_script(session, "return 1; // foo")
assert_success(response, 1)

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

@ -1,5 +1,4 @@
from tests.support.asserts import assert_success
from tests.support.inline import inline
from . import opener, window_name
@ -10,7 +9,7 @@ def new_window(session, type_hint=None):
{"type": type_hint})
def test_payload(session):
def test_new_tab(session):
original_handles = session.handles
response = new_window(session, type_hint="tab")
@ -22,31 +21,16 @@ def test_payload(session):
assert value["type"] == "tab"
def test_keeps_current_window_handle(session):
original_handle = session.window_handle
def test_new_tab_opens_about_blank(session):
response = new_window(session, type_hint="tab")
value = assert_success(response)
assert value["type"] == "tab"
assert session.window_handle == original_handle
def test_opens_about_blank_in_new_tab(session):
url = inline("<p>foo")
session.url = url
response = new_window(session, type_hint="tab")
value = assert_success(response)
assert value["type"] == "tab"
assert session.url == url
session.window_handle = value["handle"]
assert session.url == "about:blank"
def test_sets_no_window_name(session):
def test_new_tab_sets_no_window_name(session):
response = new_window(session, type_hint="tab")
value = assert_success(response)
assert value["type"] == "tab"
@ -55,7 +39,7 @@ def test_sets_no_window_name(session):
assert window_name(session) == ""
def test_sets_no_opener(session):
def test_new_tab_sets_no_opener(session):
response = new_window(session, type_hint="tab")
value = assert_success(response)
assert value["type"] == "tab"

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

@ -1,5 +1,4 @@
from tests.support.asserts import assert_success
from tests.support.inline import inline
from . import opener, window_name
@ -10,7 +9,7 @@ def new_window(session, type_hint=None):
{"type": type_hint})
def test_payload(session):
def test_type_with_window(session):
original_handles = session.handles
response = new_window(session, type_hint="window")
@ -22,31 +21,16 @@ def test_payload(session):
assert value["type"] == "window"
def test_keeps_current_window_handle(session):
original_handle = session.window_handle
def test_new_window_opens_about_blank(session):
response = new_window(session, type_hint="window")
value = assert_success(response)
assert value["type"] == "window"
assert session.window_handle == original_handle
def test_opens_about_blank_in_new_window(session):
url = inline("<p>foo")
session.url = url
response = new_window(session, type_hint="window")
value = assert_success(response)
assert value["type"] == "window"
assert session.url == url
session.window_handle = value["handle"]
assert session.url == "about:blank"
def test_sets_no_window_name(session):
def test_new_window_sets_no_window_name(session):
response = new_window(session, type_hint="window")
value = assert_success(response)
assert value["type"] == "window"
@ -55,7 +39,7 @@ def test_sets_no_window_name(session):
assert window_name(session) == ""
def test_sets_no_opener(session):
def test_new_window_sets_no_opener(session):
response = new_window(session, type_hint="window")
value = assert_success(response)
assert value["type"] == "window"