mirror of
https://github.com/zen-browser/desktop.git
synced 2025-07-08 01:19:59 +02:00
test: Added some tests, b=(no-bug), c=tests, workspaces
This commit is contained in:
parent
64293af6f7
commit
5a59eb6902
15 changed files with 109 additions and 19 deletions
2
.gitattributes
vendored
2
.gitattributes
vendored
|
@ -1,2 +1,4 @@
|
||||||
*.patch linguist-language=C++
|
*.patch linguist-language=C++
|
||||||
*.d.ts linguist-language=TypeScript
|
*.d.ts linguist-language=TypeScript
|
||||||
|
|
||||||
|
src/zen/tests/*.js linguist-language=Test
|
||||||
|
|
|
@ -1,7 +1,21 @@
|
||||||
diff --git a/testing/mochitest/browser-test.js b/testing/mochitest/browser-test.js
|
diff --git a/testing/mochitest/browser-test.js b/testing/mochitest/browser-test.js
|
||||||
index ef29179988bb37e7ea441aa051b692e3ccc90f21..7eade843ad62e47f90dc06a4a1fb88b6d1c1a583 100644
|
index ef29179988bb37e7ea441aa051b692e3ccc90f21..6c9641ed27722b5febd83f6e121df24d46b00067 100644
|
||||||
--- a/testing/mochitest/browser-test.js
|
--- a/testing/mochitest/browser-test.js
|
||||||
+++ b/testing/mochitest/browser-test.js
|
+++ b/testing/mochitest/browser-test.js
|
||||||
|
@@ -444,11 +444,11 @@ Tester.prototype = {
|
||||||
|
this.currentTest &&
|
||||||
|
window.gBrowser &&
|
||||||
|
AppConstants.MOZ_APP_NAME != "thunderbird" &&
|
||||||
|
- gBrowser.tabs.length > 1
|
||||||
|
+ gBrowser.tabs.length > 2
|
||||||
|
) {
|
||||||
|
let lastURI = "";
|
||||||
|
let lastURIcount = 0;
|
||||||
|
- while (gBrowser.tabs.length > 1) {
|
||||||
|
+ while (gBrowser.tabs.length > 2) {
|
||||||
|
let lastTab = gBrowser.tabs[gBrowser.tabs.length - 1];
|
||||||
|
if (!lastTab.closing) {
|
||||||
|
// Report the stale tab as an error only when they're not closing.
|
||||||
@@ -483,12 +483,12 @@ Tester.prototype = {
|
@@ -483,12 +483,12 @@ Tester.prototype = {
|
||||||
|
|
||||||
// Replace the last tab with a fresh one
|
// Replace the last tab with a fresh one
|
||||||
|
|
|
@ -3,12 +3,8 @@
|
||||||
# License, v. 2.0. If a copy of the MPL was not distributed with this
|
# 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/.
|
# file, You can obtain one at http://mozilla.org/MPL/2.0/.
|
||||||
|
|
||||||
|
|
||||||
BROWSER_CHROME_MANIFESTS += [
|
|
||||||
"tests/browser.toml",
|
|
||||||
]
|
|
||||||
|
|
||||||
DIRS += [
|
DIRS += [
|
||||||
"glance",
|
"glance",
|
||||||
"mods"
|
"mods",
|
||||||
|
"tests",
|
||||||
]
|
]
|
||||||
|
|
1
src/zen/tests/.prettierignore
Normal file
1
src/zen/tests/.prettierignore
Normal file
|
@ -0,0 +1 @@
|
||||||
|
run.sh
|
|
@ -1,2 +0,0 @@
|
||||||
["workspaces/browser_basic_workspaces.js"]
|
|
||||||
["workspaces/browser_container_specific_essentials.js"]
|
|
4
src/zen/tests/container_essentials/browser.toml
Normal file
4
src/zen/tests/container_essentials/browser.toml
Normal file
|
@ -0,0 +1,4 @@
|
||||||
|
[DEFAULT]
|
||||||
|
prefs = ["zen.workspaces.container-specific-essentials-enabled=true"]
|
||||||
|
|
||||||
|
["browser_container_specific_essentials.js"]
|
|
@ -3,10 +3,6 @@
|
||||||
|
|
||||||
'use strict';
|
'use strict';
|
||||||
|
|
||||||
add_setup(async function () {
|
|
||||||
ZenWorkspaces.containerSpecificEssentials = true;
|
|
||||||
});
|
|
||||||
|
|
||||||
add_task(async function test_Check_Creation() {
|
add_task(async function test_Check_Creation() {
|
||||||
await ZenWorkspaces.createAndSaveWorkspace('Container Profile 1', undefined, false, 1);
|
await ZenWorkspaces.createAndSaveWorkspace('Container Profile 1', undefined, false, 1);
|
||||||
const workspaces = await ZenWorkspaces._workspaces();
|
const workspaces = await ZenWorkspaces._workspaces();
|
||||||
|
@ -18,6 +14,10 @@ add_task(async function test_Check_Creation() {
|
||||||
});
|
});
|
||||||
ok(newTab, 'New tab should be opened.');
|
ok(newTab, 'New tab should be opened.');
|
||||||
gZenPinnedTabManager.addToEssentials(newTab);
|
gZenPinnedTabManager.addToEssentials(newTab);
|
||||||
|
ok(
|
||||||
|
newTab.hasAttribute('zen-essential') && newTab.parentNode.getAttribute('container') == '1',
|
||||||
|
'New tab should be marked as essential.'
|
||||||
|
);
|
||||||
ok(
|
ok(
|
||||||
gBrowser.tabs.find((t) => t.hasAttribute('zen-essential') && t.getAttribute('usercontextid') == 1),
|
gBrowser.tabs.find((t) => t.hasAttribute('zen-essential') && t.getAttribute('usercontextid') == 1),
|
||||||
'New tab should be marked as essential.'
|
'New tab should be marked as essential.'
|
6
src/zen/tests/moz.build
Normal file
6
src/zen/tests/moz.build
Normal file
|
@ -0,0 +1,6 @@
|
||||||
|
|
||||||
|
BROWSER_CHROME_MANIFESTS += [
|
||||||
|
"container_essentials/browser.toml",
|
||||||
|
"urlbar/browser.toml",
|
||||||
|
"workspaces/browser.toml",
|
||||||
|
]
|
|
@ -1,13 +1,16 @@
|
||||||
#!/bin/bash
|
#!/bin/bash
|
||||||
|
|
||||||
|
set -e
|
||||||
|
|
||||||
# make sure we are on root
|
# make sure we are on root
|
||||||
if [ ! -f "package.json" ]; then
|
if [ ! -f "package.json" ]; then
|
||||||
echo "Please run this script from the root of the project"
|
echo "Please run this script from the root of the project"
|
||||||
exit 1
|
exit 1
|
||||||
fi
|
fi
|
||||||
|
|
||||||
#npm run build:ui
|
|
||||||
|
|
||||||
cd ./engine
|
cd ./engine
|
||||||
./mach mochitest zen/tests/ $@
|
./mach mochitest $@ \
|
||||||
|
zen/tests/workspaces \
|
||||||
|
zen/tests/container_essentials \
|
||||||
|
zen/tests/urlbar
|
||||||
cd ..
|
cd ..
|
||||||
|
|
7
src/zen/tests/urlbar/browser.toml
Normal file
7
src/zen/tests/urlbar/browser.toml
Normal file
|
@ -0,0 +1,7 @@
|
||||||
|
[DEFAULT]
|
||||||
|
support-files = [
|
||||||
|
"head.js",
|
||||||
|
"!/browser/components/urlbar/tests/browser/head.js",
|
||||||
|
]
|
||||||
|
|
||||||
|
["browser_floating_urlbar.js"]
|
48
src/zen/tests/urlbar/browser_floating_urlbar.js
Normal file
48
src/zen/tests/urlbar/browser_floating_urlbar.js
Normal file
|
@ -0,0 +1,48 @@
|
||||||
|
/* Any copyright is dedicated to the Public Domain.
|
||||||
|
https://creativecommons.org/publicdomain/zero/1.0/ */
|
||||||
|
|
||||||
|
'use strict';
|
||||||
|
|
||||||
|
ChromeUtils.defineESModuleGetters(this, {
|
||||||
|
UrlbarTestUtils: 'resource://testing-common/UrlbarTestUtils.sys.mjs',
|
||||||
|
});
|
||||||
|
|
||||||
|
add_task(async function test_Floating_Urlbar() {
|
||||||
|
gURLBar.blur();
|
||||||
|
|
||||||
|
await SimpleTest.promiseFocus(window);
|
||||||
|
document.getElementById('Browser:OpenLocation').doCommand();
|
||||||
|
await UrlbarTestUtils.promiseAutocompleteResultPopup({
|
||||||
|
window,
|
||||||
|
waitForFocus: SimpleTest.waitForFocus,
|
||||||
|
value: 'http://example.com/',
|
||||||
|
});
|
||||||
|
|
||||||
|
ok(gURLBar.textbox.hasAttribute('zen-floating-urlbar'), 'URL bar should be in floating mode');
|
||||||
|
});
|
||||||
|
|
||||||
|
add_task(async function test_Click_Shoudnt_FLoat_Urlbar() {
|
||||||
|
gURLBar.blur();
|
||||||
|
|
||||||
|
await simulateClick(window);
|
||||||
|
|
||||||
|
await UrlbarTestUtils.promiseAutocompleteResultPopup({
|
||||||
|
window,
|
||||||
|
waitForFocus: SimpleTest.waitForFocus,
|
||||||
|
value: 'http://example.com/',
|
||||||
|
});
|
||||||
|
|
||||||
|
ok(!gURLBar.textbox.hasAttribute('zen-floating-urlbar'), 'URL bar should not be in floating mode');
|
||||||
|
});
|
||||||
|
|
||||||
|
add_task(async function test_Floating_Highlight_Everything() {
|
||||||
|
gURLBar.blur();
|
||||||
|
|
||||||
|
await SimpleTest.promiseFocus(window);
|
||||||
|
await selectWithMouseDrag(2, 5);
|
||||||
|
document.getElementById('Browser:OpenLocation').doCommand();
|
||||||
|
|
||||||
|
// Selection range
|
||||||
|
ok(gURLBar.selectionStart == 0, 'Selection start should be 0');
|
||||||
|
ok(gURLBar.selectionEnd == gURLBar.value.length, 'Selection end should be the length of the value');
|
||||||
|
});
|
11
src/zen/tests/urlbar/head.js
Normal file
11
src/zen/tests/urlbar/head.js
Normal file
|
@ -0,0 +1,11 @@
|
||||||
|
/* Any copyright is dedicated to the Public Domain.
|
||||||
|
https://creativecommons.org/publicdomain/zero/1.0/ */
|
||||||
|
|
||||||
|
'use strict';
|
||||||
|
|
||||||
|
function simulateClick(win = window) {
|
||||||
|
let target = win.gURLBar.inputField;
|
||||||
|
let promise = BrowserTestUtils.waitForEvent(target, 'click');
|
||||||
|
EventUtils.synthesizeMouseAtCenter(target, {});
|
||||||
|
return promise;
|
||||||
|
}
|
1
src/zen/tests/workspaces/browser.toml
Normal file
1
src/zen/tests/workspaces/browser.toml
Normal file
|
@ -0,0 +1 @@
|
||||||
|
["browser_basic_workspaces.js"]
|
|
@ -24,5 +24,4 @@ add_task(async function test_Check_Creation() {
|
||||||
ok(workspacesAfterRemove.workspaces.length === 1, 'One workspace should exist.');
|
ok(workspacesAfterRemove.workspaces.length === 1, 'One workspace should exist.');
|
||||||
ok(workspacesAfterRemove.workspaces[0].uuid === currentWorkspaceUUID, 'The workspace should be the one we started with.');
|
ok(workspacesAfterRemove.workspaces[0].uuid === currentWorkspaceUUID, 'The workspace should be the one we started with.');
|
||||||
ok(gBrowser.tabs.length === 2, 'There should be one tab.');
|
ok(gBrowser.tabs.length === 2, 'There should be one tab.');
|
||||||
BrowserTestUtils.removeTab(gBrowser.selectedTab);
|
|
||||||
});
|
});
|
||||||
|
|
|
@ -825,9 +825,9 @@ var ZenWorkspaces = new (class extends ZenMultiWindowFeature {
|
||||||
delete this._initialTab;
|
delete this._initialTab;
|
||||||
}
|
}
|
||||||
if (this._tabToRemoveForEmpty) {
|
if (this._tabToRemoveForEmpty) {
|
||||||
if (typeof this._tabToSelect === 'number' && this._tabToSelect >= 0) {
|
const tabs = gBrowser.tabs.filter((tab) => !tab.collapsed && !tab.hasAttribute('zen-empty-tab'));
|
||||||
|
if (typeof this._tabToSelect === 'number' && this._tabToSelect >= 0 && tabs[this._tabToSelect]) {
|
||||||
setTimeout(() => {
|
setTimeout(() => {
|
||||||
const tabs = gBrowser.tabs.filter((tab) => !tab.collapsed && !tab.hasAttribute('zen-empty-tab'));
|
|
||||||
this.log(`Found tab to select: ${this._tabToSelect}, ${tabs.length}`);
|
this.log(`Found tab to select: ${this._tabToSelect}, ${tabs.length}`);
|
||||||
gBrowser.selectedTab = tabs[this._tabToSelect];
|
gBrowser.selectedTab = tabs[this._tabToSelect];
|
||||||
this._removedByStartupPage = true;
|
this._removedByStartupPage = true;
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue