1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132
|
# 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/.
import os
import sys
from marionette_driver import Wait
# add this directory to the path
sys.path.append(os.path.dirname(__file__))
from session_store_test_case import SessionStoreTestCase
def inline(title):
return f"data:text/html;charset=utf-8,<html><head><title>{title}</title></head><body></body></html>"
class TestManualRestoreWithTaskbarTabs(SessionStoreTestCase):
def setUp(self):
super(TestManualRestoreWithTaskbarTabs, self).setUp(
startup_page=1,
include_private=False,
restore_on_demand=False,
taskbartabs_enable=True,
test_windows=set(
[
# Window 1
(
inline("lorem ipsom"),
inline("dolor"),
),
]
),
)
"""
Close all regular windows except for a taskbar tab window. The
session should be over at this point. Opening another regular Firefox
window will open "restore previous session" in the hamburger menu.
And clicking it will restore the correct session.
"""
def test_restore_without_closing_taskbartab(self):
self.wait_for_windows(
self.all_windows, "Not all requested windows have been opened"
)
# See session_store_test_case.py
self.setup_taskbartab_restore_scenario()
# Verify that "restore previous session" button
# is visible in the hamburger menu
self.assertEqual(
self.marionette.execute_script(
"""
let newWindow = BrowserWindowTracker.getTopWindow({ allowTaskbarTabs: false });
return PanelMultiView.getViewNode(
newWindow.document,
"appMenu-restoreSession"
).hasAttribute("disabled");
"""
),
False,
"The restore last session button should be visible",
)
# Simulate clicking "restore previous session"
self.marionette.execute_script(
"""
SessionStore.restoreLastSession();
"""
)
# Wait for the restore to be completed,
# meaning the window we opened should have
# two tabs again.
Wait(self.marionette).until(
lambda mn: mn.execute_script(
"""
let newWindow = BrowserWindowTracker.getTopWindow({ allowTaskbarTabs: false });
return newWindow.gBrowser.tabs.length;
"""
)
== 2
)
class TestAutoRestoreWithTaskbarTabs(SessionStoreTestCase):
def setUp(self):
super(TestAutoRestoreWithTaskbarTabs, self).setUp(
startup_page=3,
include_private=False,
restore_on_demand=False,
taskbartabs_enable=True,
test_windows=set(
[
# Window 1
(
inline("lorem ipsom"),
inline("dolor"),
),
]
),
)
"""
Close all regular windows except for a taskbar tab window. The
session should be over at this point. Opening another regular Firefox
window will open automatically restore the correct session
"""
def test_restore_without_closing_taskbartab(self):
self.wait_for_windows(
self.all_windows, "Not all requested windows have been opened"
)
self.setup_taskbartab_restore_scenario()
# Wait for the auto restore to be completed,
# meaning the window we opened should have
# the original two tabs plus the home page tab.
Wait(self.marionette).until(
lambda mn: mn.execute_script(
"""
let newWindow = BrowserWindowTracker.getTopWindow({ allowTaskbarTabs: false });
return newWindow.gBrowser.tabs.length;
"""
)
== 3
)
|