This repository has been archived by the owner on Jan 20, 2022. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 37
Bug 1228120 - [WIP] Add SessionStore tests for restarting. r?whimboo #292
Closed
mikeconley
wants to merge
1
commit into
mozilla:mozilla-central
from
mikeconley:sessionstore-restart
Closed
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
[DEFAULT] | ||
tags = local | ||
|
||
[test_restore_windows_after_restart.py] |
94 changes: 94 additions & 0 deletions
94
firefox_ui_tests/functional/sessionstore/test_restore_windows_after_restart.py
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,94 @@ | ||
# 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/. | ||
|
||
from marionette_driver import Wait | ||
|
||
import time | ||
|
||
from firefox_puppeteer.testcases import FirefoxTestCase | ||
|
||
|
||
class TestRestoreWindowsAfterRestart(FirefoxTestCase): | ||
|
||
def setUp(self): | ||
FirefoxTestCase.setUp(self) | ||
|
||
# Each list element represents a window of tabs loaded at | ||
# some testing URL | ||
self.test_windows = [ | ||
# Window 1 | ||
[self.marionette.absolute_url('layout/mozilla.html'), | ||
self.marionette.absolute_url('layout/mozilla_community.html')], | ||
|
||
# Window 2 | ||
[self.marionette.absolute_url('layout/mozilla_governance.html'), | ||
self.marionette.absolute_url('layout/mozilla_grants.html')], | ||
|
||
# Window 3 | ||
[self.marionette.absolute_url('layout/mozilla.html')], | ||
] | ||
|
||
self.private_windows = [ | ||
[self.marionette.absolute_url('layout/mozilla_mission.html'), | ||
self.marionette.absolute_url('layout/mozilla_organizations.html')], | ||
|
||
[self.marionette.absolute_url('layout/mozilla_projects.html'), | ||
self.marionette.absolute_url('layout/mozilla_mission.html')], | ||
] | ||
|
||
# Set browser to restore previous session | ||
self.prefs.set_pref('browser.startup.page', 3) | ||
|
||
|
||
def tearDown(self): | ||
try: | ||
self.windows.close_all([self.browser.tabbar.tabs[0]]) | ||
finally: | ||
FirefoxTestCase.tearDown(self) | ||
|
||
def test_with_variety(self): | ||
self.open_windows(self.test_windows) | ||
self.open_windows(self.private_windows, is_private=True) | ||
|
||
self.restart() | ||
|
||
windows = self.windows.all | ||
# We should have only restored the test_windows, and none of | ||
# the private_windows... | ||
self.assertEqual(len(windows), 3) | ||
|
||
for win in windows: | ||
print "Saw a window with %s tabs" % len(win.tabbar.tabs) | ||
for tab in win.tabbar.tabs: | ||
print "Got a tab" | ||
print "Saw a tab: %s" % tab.location | ||
|
||
def open_windows(self, urlLists, is_private=False): | ||
if (is_private): | ||
win = self.browser.open_browser(is_private=True) | ||
win.switch_to() | ||
else: | ||
win = self.browser | ||
|
||
self.open_tabs(win, urlLists[0]) | ||
|
||
for urls in urlLists[1:]: | ||
print "Opening a new window" | ||
win = self.browser.open_browser(is_private=is_private) | ||
win.switch_to() | ||
self.open_tabs(win, urls) | ||
|
||
|
||
def open_tabs(self, win, urls): | ||
print "Opening %s for initial tab" % urls[0] | ||
# Send the initial tab to the first URL... | ||
with self.marionette.using_context('content'): | ||
self.marionette.navigate(urls[0]) | ||
# If there are any remaining URLs for this window, | ||
# open some new tabs and navigate to them. | ||
for url in urls[1:]: | ||
print "Opening url: %s in new tab" % url | ||
newtab = win.tabbar.open_tab() | ||
with self.marionette.using_context('content'): | ||
self.marionette.navigate(url) |
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Please note that you have to use
self.browser
here. Otherwise Marionette will hang. Also close all additional tabs you opened to not get the leak handle exception.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hey, sorry whimboo - just getting back to this now. Where should I be using self.browser? Should I be doing self.browser.windows.close_all instead?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
No, with
self.browser
I meant the entry in the exclusion list (parameter) of the function call. As of now you are trying to close all windows, except the first tab of the browser window. By using that Marionette will also close the initial browser window, and will hang until the global timeout.