Bug 1368526 - Wait for the page to be loaded in a newly opened tab/window. r=ato

If a web page gets opened in a new tab or window, there is no way for
the navigate command to check the current page load status. Instead
we have to wait until the correct URL is getting reported.

MozReview-Commit-ID: JQhPXRgh5Ae

--HG--
extra : rebase_source : 9b60d62af5d4cec2c1a693e152510807165755ba
This commit is contained in:
Henrik Skupin 2017-05-30 11:25:21 +02:00
Родитель 0edcecb78f
Коммит 37b8ffef76
1 изменённых файлов: 13 добавлений и 5 удалений

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

@ -4,7 +4,7 @@
import types
from marionette_driver import By, errors
from marionette_driver import By, errors, Wait
from marionette_harness import MarionetteTestCase, WindowManagerMixin
@ -79,7 +79,9 @@ class TestWindowHandles(WindowManagerMixin, MarionetteTestCase):
self.assert_window_handles()
self.assertEqual(self.marionette.current_chrome_window_handle, new_win)
with self.marionette.using_context("content"):
self.assertEqual(self.marionette.get_url(), self.empty_page)
Wait(self.marionette, timeout=self.marionette.timeout.page_load).until(
lambda mn: mn.get_url() == self.empty_page,
message="{} did not load after opening a new tab".format(self.empty_page))
# Ensure navigate works in our current window
other_page = self.marionette.absolute_url("test.html")
@ -113,7 +115,9 @@ class TestWindowHandles(WindowManagerMixin, MarionetteTestCase):
self.assert_window_handles()
self.assertEqual(self.marionette.current_window_handle, new_tab)
with self.marionette.using_context("content"):
self.assertEqual(self.marionette.get_url(), self.empty_page)
Wait(self.marionette, timeout=self.marionette.timeout.page_load).until(
lambda mn: mn.get_url() == self.empty_page,
message="{} did not load after opening a new tab".format(self.empty_page))
# Ensure navigate works in our current tab
other_page = self.marionette.absolute_url("test.html")
@ -152,7 +156,9 @@ class TestWindowHandles(WindowManagerMixin, MarionetteTestCase):
self.assert_window_handles()
self.assertEqual(self.marionette.current_window_handle, new_tab)
with self.marionette.using_context("content"):
self.assertEqual(self.marionette.get_url(), self.empty_page)
Wait(self.marionette, timeout=self.marionette.timeout.page_load).until(
lambda mn: mn.get_url() == self.empty_page,
message="{} did not load after opening a new tab".format(self.empty_page))
# Ensure navigate works in our current window
other_page = self.marionette.absolute_url("test.html")
@ -190,7 +196,9 @@ class TestWindowHandles(WindowManagerMixin, MarionetteTestCase):
self.assert_window_handles()
self.assertEqual(self.marionette.current_window_handle, new_tab)
with self.marionette.using_context("content"):
self.assertEqual(self.marionette.get_url(), self.empty_page)
Wait(self.marionette, timeout=self.marionette.timeout.page_load).until(
lambda mn: mn.get_url() == self.empty_page,
message="{} did not load after opening a new tab".format(self.empty_page))
def test_window_handles_no_switch(self):
"""Regression test for bug 1294456.