зеркало из https://github.com/mozilla/gecko-dev.git
Bug 1457355 test that primary selection is unaffected by opening new tab r=dao
Differential Revision: https://phabricator.services.mozilla.com/D37354 --HG-- extra : moz-landing-system : lando
This commit is contained in:
Родитель
494375d70f
Коммит
bea6491430
|
@ -72,6 +72,7 @@ skip-if = (os == 'mac' && os_version == '10.14') # bug 1554807
|
|||
tags = clipboard
|
||||
[browser_percent_encoded.js]
|
||||
[browser_populateAfterPushState.js]
|
||||
[browser_primary_selection_safe_on_new_tab.js]
|
||||
[browser_privateBrowsingWindowChange.js]
|
||||
[browser_raceWithTabs.js]
|
||||
skip-if = os == "linux" # Bug 1533807
|
||||
|
|
|
@ -0,0 +1,74 @@
|
|||
/* Any copyright is dedicated to the Public Domain.
|
||||
* http://creativecommons.org/publicdomain/zero/1.0/ */
|
||||
|
||||
/**
|
||||
* Verify that the primary selection is unaffected by opening a new tab.
|
||||
*
|
||||
* The steps here follow STR for regression
|
||||
* https://bugzilla.mozilla.org/show_bug.cgi?id=1457355.
|
||||
*/
|
||||
|
||||
"use strict";
|
||||
|
||||
let tabs = [];
|
||||
let supportsPrimary = Services.clipboard.supportsSelectionClipboard();
|
||||
let ClipboardHelper = Cc["@mozilla.org/widget/clipboardhelper;1"].getService(
|
||||
Ci.nsIClipboardHelper
|
||||
);
|
||||
const NON_EMPTY_URL = "data:text/html,Hello";
|
||||
const TEXT_FOR_PRIMARY = "Text for PRIMARY selection";
|
||||
|
||||
add_task(async function() {
|
||||
tabs.push(
|
||||
await BrowserTestUtils.openNewForegroundTab(gBrowser, NON_EMPTY_URL)
|
||||
);
|
||||
|
||||
// Bug 1457355 reproduced only when the url had a non-empty selection.
|
||||
gURLBar.select();
|
||||
Assert.equal(gURLBar.inputField.selectionStart, 0);
|
||||
Assert.equal(
|
||||
gURLBar.inputField.selectionEnd,
|
||||
gURLBar.inputField.value.length
|
||||
);
|
||||
|
||||
if (supportsPrimary) {
|
||||
ClipboardHelper.copyStringToClipboard(
|
||||
TEXT_FOR_PRIMARY,
|
||||
Services.clipboard.kSelectionClipboard
|
||||
);
|
||||
}
|
||||
|
||||
tabs.push(
|
||||
await BrowserTestUtils.openNewForegroundTab({
|
||||
gBrowser,
|
||||
opening: () => {
|
||||
// Simulate tab open from user input such as keyboard shortcut or new
|
||||
// tab button.
|
||||
let userInput = window.windowUtils.setHandlingUserInput(true);
|
||||
try {
|
||||
BrowserOpenTab();
|
||||
} finally {
|
||||
userInput.destruct();
|
||||
}
|
||||
},
|
||||
waitForLoad: false,
|
||||
})
|
||||
);
|
||||
|
||||
if (!supportsPrimary) {
|
||||
info("Primary selection not supported. Skipping assertion.");
|
||||
return;
|
||||
}
|
||||
|
||||
let primaryAsText = SpecialPowers.getClipboardData(
|
||||
"text/unicode",
|
||||
SpecialPowers.Ci.nsIClipboard.kSelectionClipboard
|
||||
);
|
||||
Assert.equal(primaryAsText, TEXT_FOR_PRIMARY);
|
||||
});
|
||||
|
||||
registerCleanupFunction(() => {
|
||||
for (let tab of tabs) {
|
||||
BrowserTestUtils.removeTab(tab);
|
||||
}
|
||||
});
|
Загрузка…
Ссылка в новой задаче