Bug 1759574 - [firefox-ui] Use data URLs in session restore tests and make them more stable. r=webdriver-reviewers,dao,jdescottes

Replace test pages as used by the session restore tests with data URLs.

Further make the tests more stable by waiting for the expected windows
and tabs to be opened. The relevant changes should fix a couple of
intermittent failures that we have seen in the past.

Differential Revision: https://phabricator.services.mozilla.com/D141081
This commit is contained in:
Henrik Skupin 2022-03-21 17:05:26 +00:00
Родитель 7ab54f27f1
Коммит 8c996661f7
10 изменённых файлов: 47 добавлений и 521 удалений

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

@ -1,49 +0,0 @@
<!-- This Source Code Form is subject to the terms of the Mozilla Public
- License, v. 2.0. If a copy of the MPL was not distributed with this
- file, You can obtain one at http://mozilla.org/MPL/2.0/. -->
<!DOCTYPE html>
<html lang="en" dir="ltr">
<head>
<title>Mozilla</title>
<link rel="shortcut icon" type="image/ico" href="../images/mozilla_favicon.ico" />
</head>
<body>
<a href="mozilla.html">
<img id="mozilla_logo" src="../images/mozilla_logo.jpg" />
</a>
<a href="#community">Community</a> |
<a href="#project">Project</a> |
<a href="#organization">Organization</a>
<div id="content">
<h1 id="page-title">
<strong>We believe</strong> that the internet should be public,
open and accessible.
</h1>
<h2><a name="community">Community</a></h2>
<p id="community">
We're a global community of thousands who believe in the power
of technology to enrich people's lives.
<a href="mozilla_community.html">More</a>
</p>
<h2><a name="project">Project</a></h2>
<p id="project">
We're an open source project whose code is used for some of the
Internet's most innovative applications.
<a href="mozilla_projects.html">More</a>
</p>
<h2><a name="organization">Organization</a></h2>
<p id="organization">
We're a public benefit organization dedicated to making the
Internet better for everyone.
<a href="mozilla_mission.html">More</a>
</p>
</div>
</body>
</html>

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

@ -1,61 +0,0 @@
<!-- This Source Code Form is subject to the terms of the Mozilla Public
- License, v. 2.0. If a copy of the MPL was not distributed with this
- file, You can obtain one at http://mozilla.org/MPL/2.0/. -->
<!DOCTYPE html>
<html lang="en" dir="ltr">
<head>
<title>Mozilla Community</title>
<link rel="shortcut icon" type="image/ico" href="../images/seamonkey_favicon.ico" />
</head>
<body>
<a href="mozilla.html">
<img id="mozilla_logo" src="../images/mozilla_logo.jpg" />
</a>
<a href="#history">History</a> |
<a href="#communicate">Communicate</a> |
<a href="#more">More</a>
<div id="content">
<h1 id="page-title" name="page-title">Our Community</h1>
<h2><a name="history">History</a></h2>
<p id="history">
When www.mozilla.org was launched in 1998 all community activity
occurred right here on this site. Since then the community has
grown much bigger and there are now many different sites,
forums, blogs and newsgroups in different places that track
different parts of the project. These pages aim to be a
comprehensive list to all of the different community resources
available. If you know of something that's not on these lists
that should be, please contact us and we'll update these
pages.
</p>
<h2><a name="communicate">Communicate</a></h2>
<p id="communicate">
There are a number of different ways community members
communicate and coordinate (people use mailing lists and
newsgroups, blogs, forums, wikis and they even meet in real
life sometimes too) and all of these options might be
overwhelming at first. Hopefully this set of links will provide
some useful pointers to help you figure out where to go to find
what you're looking for. If you do get lost though and need
some help, feel free to ask for more information.
</p>
<h2><a name="more">More</a></h2>
<p id="more">
Please note that this is intended to be an entry point that
provides a high-level overview of the different community areas.
If you're looking for more detailed information about a specific
topic, please look at our Developer,
<a href="mozilla_contribute.html">Contribute</a> and Support
pages or take a look at the other information referenced
throughout this site.
</p>
</div>
</body>
</html>

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

@ -1,74 +0,0 @@
<!-- This Source Code Form is subject to the terms of the Mozilla Public
- License, v. 2.0. If a copy of the MPL was not distributed with this
- file, You can obtain one at http://mozilla.org/MPL/2.0/. -->
<!DOCTYPE html>
<html lang="en" dir="ltr">
<head>
<title>Mozilla Contribute</title>
<link rel="shortcut icon" type="image/ico" href="../images/thunderbird_favicon.ico" />
</head>
<body>
<a href="mozilla.html">
<img id="mozilla_logo" src="../images/mozilla_logo.jpg" />
</a>
<a href="#summary">Summary</a> |
<a href="#contribute">Contribute</a>
<div id="content">
<h1 id="page-title">Get Involved</h1>
<h2><a name="summary">Summary</a></h2>
<p id="summary">
You can <a href="mozilla_mission.html">build a better Internet</a>
by getting involved with Mozilla. You don't have to be a C++
guru (or even know what that means!) and you don't need to spend
lots of time. Take a look at the opportunities below and feel
free to ask if you have any questions.
</p>
<h2><a name="contribute">Contribute</a></h2>
<p id="contribute">
<h3>Area of Interest</h3>
<i>Browse contribution opportunities by area of interest.</i>
<ul id="areas_of_interest">
<li id="browser_choice">
<h4>Web Browser Choice</h4>
<p>
Mozilla has always believed that the freedom to
make informed choices should be central to making
the Web, and the world, a better place. Tell us
why having a choice of browser is important to you
and help us spread the word about how others can
take control of their online lives.
</p>
</li>
<li id="helping_users">
<h4>Helping Users</h4>
<p>
Interested in helping others get the most out of
using Firefox and other Mozilla projects? Our
support process relies on enthusiastic
contributors like you. Find out more about
supporting Firefox, Thunderbird and other Mozilla
projects.
</p>
</li>
<li id="localization">
<h4>Localization</h4>
<p>
Get involved with Mozilla by making Firefox,
Thunderbird and other projects available in your
language. Also help us tell the world about how
Mozilla is building a better Internet by
translating content on our web sites.
</p>
</li>
</ul>
</p>
</div>
</body>
</html>

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

@ -1,42 +0,0 @@
<!-- This Source Code Form is subject to the terms of the Mozilla Public
- License, v. 2.0. If a copy of the MPL was not distributed with this
- file, You can obtain one at http://mozilla.org/MPL/2.0/. -->
<!DOCTYPE html>
<html lang="en" dir="ltr">
<head>
<title>Mozilla Governance</title>
<link rel="shortcut icon" type="image/ico" href="../images/firefox_favicon.ico" />
</head>
<body>
<a href="mozilla.html">
<img id="mozilla_logo" src="../images/mozilla_logo.jpg" />
</a>
<a href="#summary">Summary</a> |
<a href="#more">More</a>
<div id="content">
<h1 id="page-title">Governance</h1>
<h2><a name="summary">Summary</a></h2>
<p id="summary">
Mozilla is an open source project governed as a meritocracy. Our
community is structured as a virtual organization where
authority is distributed to both volunteer and employed
community members as they show their abilities through
contributions to the project.
</p>
<h2><a name="more">More</a></h2>
<p id="more">
<ul id="list">
<li id="roles">Roles and Responsibilities</li>
<li id="policies">Policies</li>
<li id="discussion">Discussion</li>
</ul>
</p>
</div>
</body>
</html>

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

@ -1,76 +0,0 @@
<!-- This Source Code Form is subject to the terms of the Mozilla Public
- License, v. 2.0. If a copy of the MPL was not distributed with this
- file, You can obtain one at http://mozilla.org/MPL/2.0/. -->
<!DOCTYPE html>
<html lang="en" dir="ltr">
<head>
<title>Mozilla Grants</title>
<link rel="shortcut icon" type="image/ico" href="../images/mozilla_favicon.ico" />
</head>
<body>
<a href="mozilla.html">
<img id="mozilla_logo" src="../images/mozilla_logo.jpg" />
</a>
<a href="#summary">Summary</a> |
<a href="#goals">Goals</a>
<div id="content">
<h1 id="page-title">Mozilla Grants</h1>
<h2><a name="summary">Summary</a></h2>
<p id="summary">
Since 2006, Mozilla has awarded over two million dollars to fund
projects that contribute to the health of the Open Web. The
Mozilla Grants program is jointly funded by the Mozilla
Corporation and the Mozilla Foundation, and awards financial
support to individuals and organizations whose work supports and
enhances the mission and values of the Mozilla Project.
</p>
<h2><a name="goals">Goals</a></h2>
<p id="goals">
Mozilla makes grants to individuals and organizations all over
the world. We mainly fund activity that supports the Mozilla
Grants program's four target areas:
<ul id="goal_list">
<li id="accessibility">
<strong>Accessibility:</strong> Mozilla believes that
the Internet truly is for everyone, and that those with
disabilities should be able to participate on the Web
along with their sighted and hearing peers. As part of
our accessibility strategy, we are funding the
development of free, open source options for those with
visual and auditory impairments.
</li>
<li id="community">
<strong>Community:</strong> Mozilla offers suppport to
the broader free culture and open source community, as
part of Mozilla's general effort to 'give back', aiding
in the creation of technologies and projects that
increase the health of the open Web ecosystem.
</li>
<li id="education">
<strong>Education:</strong> As part of Mozilla's broader
education initiative, we support educational
institutions that are producing the next generation of
innovative creators of software.
</li>
<li id="open_source">
<strong>Open Source:</strong> These grants support the
creation and adoption of Web standards, open source
principles, and the overall principles of transparency,
collaboration, and openness that free and open source
software projects adhere to.
</li>
</ul>
</p>
</div>
</body>
</html>

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

@ -1,55 +0,0 @@
<!-- This Source Code Form is subject to the terms of the Mozilla Public
- License, v. 2.0. If a copy of the MPL was not distributed with this
- file, You can obtain one at http://mozilla.org/MPL/2.0/. -->
<!DOCTYPE html>
<html lang="en" dir="ltr">
<head>
<title>Mozilla Mission</title>
<link rel="shortcut icon" type="image/ico" href="../images/seamonkey_favicon.ico" />
</head>
<body>
<a href="mozilla.html">
<img id="mozilla_logo" src="../images/mozilla_logo.jpg" />
</a>
<a href="#mission">Mission</a> |
<a href="#organization">Organization</a> |
<a href="#goal">Goal</a>
<div id="content" name="content">
<h1 id="page-title" name="page-title">Mission</h1>
<h2><a name="mission">Mission</a></h2>
<p id="mission_statement">
Mozilla's mission is to <strong>promote openness, innovation,
and opportunity on the web</strong>. We do this by creating
great software, like the Firefox browser, and building
movements, like Drumbeat, that give people tools to take control
of their online lives.
</p>
<h2><a name="organization">Organization</a></h2>
<p id="organization">
As a non-profit organization, we define success in terms of
building communities and enriching people's lives instead of
benefiting our shareholders (guess what: we don't even have
shareholders). We believe in the power and potential of the
Internet and want to see it thrive for everyone, everywhere.
</p>
<h2><a name="goal">Goal</a></h2>
<p id="goal">
<strong>
Building a better Internet is an ambitious goal, but we
believe that it is possible
</strong>
when people who share our passion get involved. Coders, artists,
writers, testers, surfers, students, grandparents; anyone who
uses and cares about the web can help make it even better.
<a href="mozilla_contribute.html">Find out how you can help</a>.
</p>
</div>
</body>
</html>

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

@ -1,43 +0,0 @@
<!-- This Source Code Form is subject to the terms of the Mozilla Public
- License, v. 2.0. If a copy of the MPL was not distributed with this
- file, You can obtain one at http://mozilla.org/MPL/2.0/. -->
<!DOCTYPE html>
<html lang="en" dir="ltr">
<head>
<title>Mozilla Organizations</title>
<link rel="shortcut icon" type="image/ico" href="../images/thunderbird_favicon.ico" />
</head>
<body>
<a href="mozilla.html">
<img id="mozilla_logo" src="../images/mozilla_logo.jpg" />
</a>
<a href="#summary">Summary</a> |
<a href="#organization">Organization</a>
<div id="content">
<h1 id="page-title">Mozilla Organizations</h1>
<h2><a name="summary">Summary</a></h2>
<p id="summary">
Mozilla is a global community of people creating a better
Internet. We build public benefit into the Internet by creating
free, open source products and technologies that improve the
online experience for people everywhere.
</p>
<h2><a name="organization">Organization</a></h2>
<p id="organization">
There are several organizations that support the Mozilla
community and Mozilla's principles. They include the non-profit
Mozilla Foundation as well as two wholly owned taxable
subsidiaries, the Mozilla Corporation and Mozilla Messaging.
Mozilla considers itself a hybrid organization, combining non-
profit and market strategies to ensure the Internet remains a
shared public resource.
</p>
</div>
</body>
</html>

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

@ -1,64 +0,0 @@
<!-- This Source Code Form is subject to the terms of the Mozilla Public
- License, v. 2.0. If a copy of the MPL was not distributed with this
- file, You can obtain one at http://mozilla.org/MPL/2.0/. -->
<!DOCTYPE html>
<html lang="en" dir="ltr">
<head>
<title>Mozilla Projects</title>
<link rel="shortcut icon" type="image/ico" href="../images/firefox_favicon.ico" />
</head>
<body>
<a href="mozilla.html">
<img id="mozilla_logo" src="../images/mozilla_logo.jpg" />
</a>
<a href="#summary">Summary</a> |
<a href="#applications">Applications</a>
<div id="content">
<h1 id="page-title">Our Projects</h1>
<h2><a name="summary">Summary</a></h2>
<p id="summary">
The Mozilla community produces a lot of great software and acts
as an incubator for innovative ideas as a way to advance our
<a href="mozilla_mission.html">mission</a> of building a better
Internet.
</p>
<h2><a name="applications">Applications</a></h2>
<p id="applications">
<p>
These applications are developed by the Mozilla community
and their code is hosted on mozilla.org.
</p>
<ul id="product_list">
<li id="bugzilla">
<h3><strong>Bugzilla</strong></h3>
Bugzilla is a bug tracking system designed to help teams
manage software development. Hundreds of organizations
across the globe are using this powerful tool to get
organized and communicate effectively.
</li>
<li id="camino">
<h3><strong>Camino</strong></h3>
Camino is a Web browser optimized for Mac OS X with a
Cocoa user interface, and powerful Gecko layout engine.
It's the simple, secure, and fast browser for Mac OS X.
</li>
<li id="firefox">
<h3><strong>Firefox for Desktop</strong></h3>
The award-winning Firefox Web browser has security,
speed and new features that will change the way you use
the Web. Dont settle for anything less.
</li>
</ul>
</p>
</div>
</body>
</html>

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

@ -4,10 +4,17 @@
from __future__ import absolute_import
from urllib.parse import quote
from marionette_driver import errors, Wait
from marionette_driver.keys import Keys
from marionette_harness import MarionetteTestCase, WindowManagerMixin
def inline(doc):
return "data:text/html;charset=utf-8,{}".format(quote(doc))
class SessionStoreTestCase(WindowManagerMixin, MarionetteTestCase):
def setUp(
self,
@ -26,18 +33,18 @@ class SessionStoreTestCase(WindowManagerMixin, MarionetteTestCase):
# some testing URL
self.test_windows = set(
[
# Window 1. Note the comma after the absolute_url call -
# Window 1. Note the comma after the inline call -
# this is Python's way of declaring a 1 item tuple.
(self.marionette.absolute_url("layout/mozilla.html"),),
(inline("""<div">Lorem</div>"""),),
# Window 2
(
self.marionette.absolute_url("layout/mozilla_organizations.html"),
self.marionette.absolute_url("layout/mozilla_community.html"),
inline("""<div">ipsum</div>"""),
inline("""<div">dolor</div>"""),
),
# Window 3
(
self.marionette.absolute_url("layout/mozilla_governance.html"),
self.marionette.absolute_url("layout/mozilla_grants.html"),
inline("""<div">sit</div>"""),
inline("""<div">amet</div>"""),
),
]
)
@ -45,12 +52,12 @@ class SessionStoreTestCase(WindowManagerMixin, MarionetteTestCase):
self.private_windows = set(
[
(
self.marionette.absolute_url("layout/mozilla_mission.html"),
self.marionette.absolute_url("layout/mozilla_organizations.html"),
inline("""<div">consectetur</div>"""),
inline("""<div">ipsum</div>"""),
),
(
self.marionette.absolute_url("layout/mozilla_projects.html"),
self.marionette.absolute_url("layout/mozilla_mission.html"),
inline("""<div">adipiscing</div>"""),
inline("""<div">consectetur</div>"""),
),
]
)
@ -151,6 +158,24 @@ class SessionStoreTestCase(WindowManagerMixin, MarionetteTestCase):
self.marionette.switch_to_window(tab)
self.marionette.navigate(url)
def wait_for_windows(self, expected_windows, message, timeout=5):
current_windows = None
def check(_):
nonlocal current_windows
current_windows = self.convert_open_windows_to_set()
return current_windows == expected_windows
try:
wait = Wait(self.marionette, timeout=timeout, interval=0.1)
wait.until(check, message=message)
except errors.TimeoutException as e:
# Update the message to include the most recent list of windows
message = (
f"{e.message}. Expected {expected_windows}, got {current_windows}."
)
raise errors.TimeoutException(message)
def get_urls_for_window(self, win):
orig_handle = self.marionette.current_chrome_window_handle
@ -376,16 +401,10 @@ class SessionStoreTestCase(WindowManagerMixin, MarionetteTestCase):
finally:
self.marionette.instance.app_args = saved_args
current_windows_set = self.convert_open_windows_to_set()
if expect_restore:
self.assertEqual(
current_windows_set,
self.wait_for_windows(
self.test_windows,
msg="""Non private browsing windows should have
been restored. Expected {}, got {}.
""".format(
self.test_windows, current_windows_set
),
"Non private browsing windows should have been restored",
)
else:
self.assertEqual(

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

@ -30,28 +30,16 @@ class TestSessionStoreEnabledAllWindows(SessionStoreTestCase):
the browser, and then ensures that the standard tabs have been
restored, and that the private ones have not.
"""
current_windows_set = self.convert_open_windows_to_set()
self.assertEqual(
current_windows_set,
self.all_windows,
msg="Not all requested windows have been opened. Expected {}, got {}.".format(
self.all_windows, current_windows_set
),
self.wait_for_windows(
self.all_windows, "Not all requested windows have been opened"
)
self.marionette.quit(in_app=True)
self.marionette.start_session()
self.marionette.set_context("chrome")
current_windows_set = self.convert_open_windows_to_set()
self.assertEqual(
current_windows_set,
self.test_windows,
msg="""Non private browsing windows should have
been restored. Expected {}, got {}.
""".format(
self.test_windows, current_windows_set
),
self.wait_for_windows(
self.test_windows, "Non private browsing windows should have been restored"
)
@ -64,13 +52,8 @@ class TestSessionStoreEnabledNoPrivateWindows(TestSessionStoreEnabledAllWindows)
class TestSessionStoreDisabled(SessionStoreTestCase):
def test_no_restore_with_quit(self):
current_windows_set = self.convert_open_windows_to_set()
self.assertEqual(
current_windows_set,
self.all_windows,
msg="Not all requested windows have been opened. Expected {}, got {}.".format(
self.all_windows, current_windows_set
),
self.wait_for_windows(
self.all_windows, "Not all requested windows have been opened"
)
self.marionette.quit(in_app=True)
@ -89,24 +72,12 @@ class TestSessionStoreDisabled(SessionStoreTestCase):
)
def test_restore_with_restart(self):
current_windows_set = self.convert_open_windows_to_set()
self.assertEqual(
current_windows_set,
self.all_windows,
msg="Not all requested windows have been opened. Expected {}, got {}.".format(
self.all_windows, current_windows_set
),
self.wait_for_windows(
self.all_windows, "Not all requested windows have been opened"
)
self.marionette.restart(in_app=True)
current_windows_set = self.convert_open_windows_to_set()
self.assertEqual(
current_windows_set,
self.test_windows,
msg="""Non private browsing windows should have
been restored. Expected {}, got {}.
""".format(
self.test_windows, current_windows_set
),
self.wait_for_windows(
self.test_windows, "Non private browsing windows should have been restored"
)