mirror of
https://github.com/zen-browser/desktop.git
synced 2026-01-20 11:50:43 +00:00
test: Added tests for https://github.com/zen-browser/desktop/issues/7385, b=(closes #7385), c=tests, vendor
This commit is contained in:
@@ -1 +0,0 @@
|
||||
run.sh
|
||||
@@ -5,3 +5,4 @@ support-files = [
|
||||
]
|
||||
|
||||
["browser_floating_urlbar.js"]
|
||||
["browser_issue_7385.js"]
|
||||
|
||||
31
src/zen/tests/urlbar/browser_issue_7385.js
Normal file
31
src/zen/tests/urlbar/browser_issue_7385.js
Normal file
@@ -0,0 +1,31 @@
|
||||
/* 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_Selection_Remains_Double_Toolbar() {
|
||||
await goToMultipleLayouts(async () => {
|
||||
const untrimmedValue = 'http://example.com';
|
||||
let trimmedValue = UrlbarTestUtils.trimURL(untrimmedValue);
|
||||
gURLBar._setValue(untrimmedValue, {
|
||||
allowTrim: true,
|
||||
valueIsTyped: false,
|
||||
});
|
||||
gURLBar.blur();
|
||||
await SimpleTest.promiseFocus(window);
|
||||
Assert.equal(gURLBar.value, trimmedValue, 'Value has been trimmed');
|
||||
await selectWithMouseDrag(100, 200);
|
||||
|
||||
Assert.greater(gURLBar.selectionStart, 0, 'Selection start is positive.');
|
||||
Assert.greater(gURLBar.selectionEnd, gURLBar.selectionStart, 'Selection is not empty.');
|
||||
|
||||
Assert.equal(gURLBar.value, untrimmedValue, `Value should be untrimmed`);
|
||||
|
||||
gURLBar.handleRevert();
|
||||
gURLBar.view.close();
|
||||
});
|
||||
});
|
||||
@@ -9,3 +9,29 @@ function simulateClick(win = window) {
|
||||
EventUtils.synthesizeMouseAtCenter(target, {});
|
||||
return promise;
|
||||
}
|
||||
|
||||
function selectWithMouseDrag(fromX, toX, win = window) {
|
||||
let target = win.gURLBar.inputField;
|
||||
let rect = target.getBoundingClientRect();
|
||||
let promise = BrowserTestUtils.waitForEvent(target, 'mouseup');
|
||||
EventUtils.synthesizeMouse(target, fromX, rect.height / 2, { type: 'mousemove' }, target.ownerGlobal);
|
||||
EventUtils.synthesizeMouse(target, fromX, rect.height / 2, { type: 'mousedown' }, target.ownerGlobal);
|
||||
EventUtils.synthesizeMouse(target, toX, rect.height / 2, { type: 'mousemove' }, target.ownerGlobal);
|
||||
EventUtils.synthesizeMouse(target, toX, rect.height / 2, { type: 'mouseup' }, target.ownerGlobal);
|
||||
return promise;
|
||||
}
|
||||
|
||||
function goToMultipleLayouts(callback) {
|
||||
return new Promise(async (resolve) => {
|
||||
await SpecialPowers.pushPrefEnv({
|
||||
set: [['zen.view.use-single-toolbar', false]],
|
||||
});
|
||||
setTimeout(async () => {
|
||||
await callback();
|
||||
await SpecialPowers.popPrefEnv();
|
||||
setTimeout(() => {
|
||||
resolve();
|
||||
}, 1000); // Wait for new layout
|
||||
}, 1000); // Wait for new layout
|
||||
});
|
||||
}
|
||||
|
||||
3
src/zen/vendor/motion.min.mjs
vendored
3
src/zen/vendor/motion.min.mjs
vendored
File diff suppressed because one or more lines are too long
Reference in New Issue
Block a user