-
-
Notifications
You must be signed in to change notification settings - Fork 1.5k
no-bug: added tests for unloading all other workspaces #13100
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from all commits
Commits
Show all changes
8 commits
Select commit
Hold shift + click to select a range
999e6ce
tests: added tests for unloading all other workspaces
AfeefurR f1377e9
removed redundant workspace assignment
AfeefurR 3a10d03
Merge branch 'zen-browser:dev' into unload-spaces-test
AfeefurR 2bf5b75
Merge branch 'dev' into unload-spaces-test
mr-cheffy acd5fdc
no-bug: lint
mr-cheffy f7df42b
use addToEssentials and remove redudant workspace assignment
AfeefurR 21586b7
use removeTab and cleanup
AfeefurR 3b92a0a
Merge branch 'dev' into unload-spaces-test
mr-cheffy File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or 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
This file contains hidden or 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
162 changes: 162 additions & 0 deletions
162
src/zen/tests/spaces/browser_unload_all_other_spaces.js
This file contains hidden or 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,162 @@ | ||
| /* Any copyright is dedicated to the Public Domain. | ||
| https://creativecommons.org/publicdomain/zero/1.0/ */ | ||
|
|
||
| "use strict"; | ||
|
|
||
| add_setup(async function () {}); | ||
|
|
||
| // verify that with only one workspace, regular tabs should remain loaded | ||
| add_task(async function test_UnloadAllOtherWorkspace_oneWorkspace() { | ||
| const workspace = | ||
| await gZenWorkspaces.createAndSaveWorkspace("Test Workspace"); | ||
| const workspaceId = workspace.uuid; | ||
| await gZenWorkspaces.changeWorkspace(workspace); | ||
|
|
||
| const tabs = []; | ||
| for (let i = 0; i < 3; i++) { | ||
| const tab = await BrowserTestUtils.openNewForegroundTab( | ||
| window.gBrowser, | ||
| `data:text/html,<title>Hi! I am regular tab ${i}</title>`, | ||
| true, | ||
| { skipAnimation: true } | ||
| ); | ||
| tabs.push(tab); | ||
| } | ||
|
|
||
| for (const tab of tabs) { | ||
| ok(!tab.hasAttribute("pending"), "Tab should not be pending before unload"); | ||
| ok(tab.linkedPanel, "Tab should have linked panel before unload"); | ||
| } | ||
|
|
||
| await gZenWorkspaces.unloadAllOtherWorkspaces(); | ||
|
|
||
| for (const tab of tabs) { | ||
| ok(!tab.hasAttribute("pending"), "Tab should not be pending after unload"); | ||
| ok(tab.linkedPanel, "Tab should have linked panel after unload"); | ||
| } | ||
|
|
||
| await gZenWorkspaces.removeWorkspace(workspaceId); | ||
| }); | ||
|
|
||
| // with multiple workspaces, only regular tabs in other workspaces should be unloaded | ||
| add_task(async function test_UnloadAllOtherWorkspace_multipleWorkspaces() { | ||
| const inactiveWorkspace = | ||
| await gZenWorkspaces.createAndSaveWorkspace("Inactive Workspace"); | ||
| const activeWorkspace = | ||
| await gZenWorkspaces.createAndSaveWorkspace("Active Workspace"); | ||
|
|
||
| const inactiveWorkspaceId = inactiveWorkspace.uuid; | ||
| const activeWorkspaceId = activeWorkspace.uuid; | ||
|
|
||
| const inactiveWorkspaceTabs = []; | ||
| for (let i = 0; i < 2; i++) { | ||
| const tab = await BrowserTestUtils.openNewForegroundTab( | ||
| gBrowser, | ||
| `data:text/html,<title>Regular Tab ${i} in Inactive</title>`, | ||
| true, | ||
| { skipAnimation: true } | ||
| ); | ||
| tab.setAttribute("zen-workspace-id", inactiveWorkspaceId); | ||
| inactiveWorkspaceTabs.push(tab); | ||
| } | ||
|
|
||
| const activeWorkspaceTabs = []; | ||
| for (let i = 0; i < 2; i++) { | ||
| const tab = await BrowserTestUtils.openNewForegroundTab( | ||
| gBrowser, | ||
| `data:text/html,<title>Regular Tab ${i} in Active</title>`, | ||
| true, | ||
| { skipAnimation: true } | ||
| ); | ||
| tab.setAttribute("zen-workspace-id", activeWorkspaceId); | ||
| activeWorkspaceTabs.push(tab); | ||
| } | ||
|
|
||
| await gZenWorkspaces.unloadAllOtherWorkspaces(); | ||
|
|
||
| for (const tab of activeWorkspaceTabs) { | ||
| ok( | ||
| !tab.hasAttribute("pending"), | ||
| "Tab in active workspace should not be unloaded" | ||
| ); | ||
| ok(tab.linkedPanel, "Tab in active workspace should have linked panel"); | ||
| } | ||
|
|
||
| for (const tab of inactiveWorkspaceTabs) { | ||
| ok( | ||
| tab.hasAttribute("pending"), | ||
| "Tab in inactive workspace should be unloaded" | ||
| ); | ||
| ok( | ||
| !tab.linkedPanel, | ||
| "Tab in inactive workspace should not have linked panel" | ||
| ); | ||
| } | ||
| await gZenWorkspaces.removeWorkspace(inactiveWorkspaceId); | ||
| await gZenWorkspaces.removeWorkspace(activeWorkspaceId); | ||
| }); | ||
|
|
||
| // essentials in any workspace are not unloaded | ||
| add_task(async function test_UnloadAllOtherWorkspace_essentials() { | ||
| const activeWorkspace = | ||
| await gZenWorkspaces.createAndSaveWorkspace("Active Workspace"); | ||
| const inactiveWorkspace = | ||
| await gZenWorkspaces.createAndSaveWorkspace("Inactive Workspace"); | ||
|
|
||
| const activeWorkspaceId = activeWorkspace.uuid; | ||
| const inactiveWorkspaceId = inactiveWorkspace.uuid; | ||
|
|
||
| const activeWorkspaceTabs = []; | ||
| for (let i = 0; i < 2; i++) { | ||
| const tab = await BrowserTestUtils.openNewForegroundTab( | ||
| gBrowser, | ||
| `data:text/html,<title>Essential Tab ${i} in Active</title>`, | ||
| true, | ||
| { skipAnimation: true } | ||
| ); | ||
| tab.setAttribute("zen-workspace-id", activeWorkspaceId); | ||
| tab.setAttribute("zen-essential", "true"); | ||
| activeWorkspaceTabs.push(tab); | ||
| } | ||
|
|
||
| const inactiveWorkspaceTabs = []; | ||
| for (let i = 0; i < 2; i++) { | ||
| const tab = await BrowserTestUtils.openNewForegroundTab( | ||
| gBrowser, | ||
| `data:text/html,<title>Essential Tab ${i} in Inactive</title>`, | ||
| true, | ||
| { skipAnimation: true } | ||
| ); | ||
| gZenPinnedTabManager.addToEssentials(tab); | ||
| inactiveWorkspaceTabs.push(tab); | ||
| } | ||
|
|
||
| await gZenWorkspaces.unloadAllOtherWorkspaces(); | ||
|
|
||
| for (const tab of activeWorkspaceTabs) { | ||
| ok( | ||
| !tab.hasAttribute("pending"), | ||
| "Essential Tab in active workspace should not be unloaded" | ||
| ); | ||
| ok( | ||
| tab.linkedPanel, | ||
| "Essential Tab in active workspace should have linked panel" | ||
| ); | ||
| } | ||
|
|
||
| for (const tab of inactiveWorkspaceTabs) { | ||
| ok( | ||
| !tab.hasAttribute("pending"), | ||
| "Essential Tab in inactive workspace should not be unloaded" | ||
| ); | ||
| ok( | ||
| tab.linkedPanel, | ||
| "Essential Tab in inactive workspace should have linked panel" | ||
| ); | ||
| } | ||
| for (const tab of inactiveWorkspaceTabs) { | ||
| gBrowser.removeTab(tab); | ||
| } | ||
| await gZenWorkspaces.removeWorkspace(inactiveWorkspaceId); | ||
| await gZenWorkspaces.removeWorkspace(activeWorkspaceId); | ||
|
mr-cheffy marked this conversation as resolved.
|
||
| }); | ||
Oops, something went wrong.
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.
Shouldn't you switch to the original space first? Or maybe switch, create the tabs, switch back?
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.
Not sure I'm getting what you mean. Are you saying I should create the tabs in the new
Test Workspace, then switch back to the default one and call unload?