зеркало из https://github.com/mozilla/gecko-dev.git
Backed out changeset 9a5b9d5e5a20 (bug 1759737
) for causing screenshots failures on browser_permissionPrompts.js. CLOSED TREE
This commit is contained in:
Родитель
a019566c16
Коммит
1ee05bd5b0
|
@ -7,8 +7,6 @@ async function installTrigger(filename) {
|
|||
set: [
|
||||
["extensions.InstallTrigger.enabled", true],
|
||||
["extensions.InstallTriggerImpl.enabled", true],
|
||||
// Relax the user input requirements while running this test.
|
||||
["xpinstall.userActivation.required", false],
|
||||
],
|
||||
});
|
||||
BrowserTestUtils.loadURI(gBrowser.selectedBrowser, INSTALL_PAGE);
|
||||
|
|
|
@ -10,8 +10,6 @@ add_task(async function test_unsigned() {
|
|||
["extensions.install.requireBuiltInCerts", false],
|
||||
["extensions.InstallTrigger.enabled", true],
|
||||
["extensions.InstallTriggerImpl.enabled", true],
|
||||
// Relax the user input requirements while running this test.
|
||||
["xpinstall.userActivation.required", false],
|
||||
],
|
||||
});
|
||||
|
||||
|
|
|
@ -33,15 +33,13 @@ function promisePopupNotificationShown(name) {
|
|||
});
|
||||
}
|
||||
|
||||
add_setup(async function setupTestEnvironment() {
|
||||
add_setup(async function ensureInstallTriggerEnabled() {
|
||||
// Once InstallTrigger is removed, the tests targeting InstallTrigger should
|
||||
// be removed or adapted to don't use InstallTrigger.
|
||||
await SpecialPowers.pushPrefEnv({
|
||||
set: [
|
||||
["extensions.InstallTrigger.enabled", true],
|
||||
["extensions.InstallTriggerImpl.enabled", true],
|
||||
// Relax the user input requirements while running this test.
|
||||
["xpinstall.userActivation.required", false],
|
||||
],
|
||||
});
|
||||
});
|
||||
|
|
|
@ -40,29 +40,10 @@ amContentHandler.prototype = {
|
|||
|
||||
let uri = aRequest.URI;
|
||||
|
||||
// This check will allow a link to an xpi clicked by the user to trigger the
|
||||
// addon install flow, but prevents window.open or window.location from triggering
|
||||
// an addon install even when called from inside a event listener triggered by
|
||||
// user input.
|
||||
if (
|
||||
!aRequest.loadInfo.hasValidUserGestureActivation &&
|
||||
Services.prefs.getBoolPref("xpinstall.userActivation.required", true)
|
||||
) {
|
||||
const error = Components.Exception(
|
||||
`${uri.spec} install cancelled because of missing user gesture activation`,
|
||||
Cr.NS_ERROR_WONT_HANDLE_CONTENT
|
||||
);
|
||||
// Report the error in the BrowserConsole, the error thrown from here doesn't
|
||||
// seem to be visible anywhere.
|
||||
Cu.reportError(error);
|
||||
throw error;
|
||||
}
|
||||
|
||||
aRequest.cancel(Cr.NS_BINDING_ABORTED);
|
||||
|
||||
let { loadInfo } = aRequest;
|
||||
const { triggeringPrincipal } = loadInfo;
|
||||
|
||||
let browsingContext = loadInfo.targetBrowsingContext;
|
||||
|
||||
let sourceHost;
|
||||
|
|
|
@ -128,14 +128,6 @@ InstallTrigger.prototype = {
|
|||
},
|
||||
|
||||
install(installs, callback) {
|
||||
if (Services.prefs.getBoolPref("xpinstall.userActivation.required", true)) {
|
||||
if (!this._window.windowUtils.isHandlingUserInput) {
|
||||
throw new this._window.Error(
|
||||
"InstallTrigger.install can only be called from a user input handler"
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
let keys = Object.keys(installs);
|
||||
if (keys.length > 1) {
|
||||
throw new this._window.Error("Only one XPI may be installed at a time");
|
||||
|
|
|
@ -25,8 +25,6 @@ add_task(async function setup() {
|
|||
["extensions.install.requireBuiltInCerts", false],
|
||||
["extensions.InstallTrigger.enabled", true],
|
||||
["extensions.InstallTriggerImpl.enabled", true],
|
||||
// Relax the user input requirements while running this test.
|
||||
["xpinstall.userActivation.required", false],
|
||||
],
|
||||
});
|
||||
|
||||
|
|
|
@ -29,10 +29,6 @@ function testSubframeInstallOnNavigation({
|
|||
assertFn,
|
||||
}) {
|
||||
return BrowserTestUtils.withNewTab(topFrameURL, async browser => {
|
||||
await SpecialPowers.pushPrefEnv({
|
||||
// Relax the user input requirements while running this test.
|
||||
set: [["xpinstall.userActivation.required", false]],
|
||||
});
|
||||
const extension = ExtensionTestUtils.loadExtension({
|
||||
manifest: {
|
||||
content_scripts: [
|
||||
|
@ -79,7 +75,6 @@ function testSubframeInstallOnNavigation({
|
|||
await assertFn({ browser });
|
||||
|
||||
await extension.unload();
|
||||
await SpecialPowers.popPrefEnv();
|
||||
});
|
||||
}
|
||||
|
||||
|
@ -128,8 +123,6 @@ add_task(async function testInstallTriggerBlockedFromCrossOriginFrame() {
|
|||
set: [
|
||||
["extensions.InstallTrigger.enabled", true],
|
||||
["extensions.InstallTriggerImpl.enabled", true],
|
||||
// Relax the user input requirements while running this test.
|
||||
["xpinstall.userActivation.required", false],
|
||||
],
|
||||
});
|
||||
|
||||
|
@ -193,8 +186,6 @@ add_task(async function testInstallTriggerPromptedFromSameOriginFrame() {
|
|||
set: [
|
||||
["extensions.InstallTrigger.enabled", true],
|
||||
["extensions.InstallTriggerImpl.enabled", true],
|
||||
// Relax the user input requirements while running this test.
|
||||
["xpinstall.userActivation.required", false],
|
||||
],
|
||||
});
|
||||
|
||||
|
|
|
@ -23,14 +23,10 @@ https://bugzilla.mozilla.org/show_bug.cgi?id=887098
|
|||
return;
|
||||
}
|
||||
|
||||
// Bug 1703215: Using SpecialPowers causes about:mozilla to be loaded in the wrong
|
||||
// process, hence we have to flip the pref and don't enforce IPC based Principal Vetting.
|
||||
await SpecialPowers.pushPrefEnv({
|
||||
set: [
|
||||
// Bug 1703215: Using SpecialPowers causes about:mozilla to be loaded in the wrong
|
||||
// process, hence we have to flip the pref and don't enforce IPC based Principal Vetting.
|
||||
["dom.security.enforceIPCBasedPrincipalVetting", false],
|
||||
// Relax the user input requirements while running this test.
|
||||
["xpinstall.userActivation.required", false],
|
||||
],
|
||||
set: [["dom.security.enforceIPCBasedPrincipalVetting", false]],
|
||||
});
|
||||
|
||||
var iwin = $("ifr").contentWindow;
|
||||
|
|
|
@ -28,8 +28,6 @@ add_task(
|
|||
pref_set: [
|
||||
["extensions.InstallTrigger.enabled", true],
|
||||
["extensions.InstallTriggerImpl.enabled", true],
|
||||
// Relax the user input requirements while running this test.
|
||||
["xpinstall.userActivation.required", false],
|
||||
],
|
||||
},
|
||||
async function test_InstallTriggerThrows_on_unsupported_xpi_schemes_blob() {
|
||||
|
@ -51,8 +49,6 @@ add_task(
|
|||
pref_set: [
|
||||
["extensions.InstallTrigger.enabled", true],
|
||||
["extensions.InstallTriggerImpl.enabled", true],
|
||||
// Relax the user input requirements while running this test.
|
||||
["xpinstall.userActivation.required", false],
|
||||
],
|
||||
},
|
||||
async function test_InstallTriggerThrows_on_unsupported_xpi_schemes_data() {
|
||||
|
|
|
@ -101,7 +101,6 @@ https_first_disabled = true # Bug 1737265
|
|||
skip-if = debug # Bug 1541577 - leaks on debug
|
||||
[browser_relative.js]
|
||||
https_first_disabled = true # Bug 1737265
|
||||
[browser_required_useractivation.js]
|
||||
[browser_softwareupdate.js]
|
||||
https_first_disabled = true # Bug 1737265
|
||||
[browser_trigger_redirect.js]
|
||||
|
|
|
@ -13,19 +13,6 @@ AddonTestUtils.initMochitest(this);
|
|||
// ----------------------------------------------------------------------------
|
||||
// Tests installing an unsigned add-on by navigating directly to the url
|
||||
function test() {
|
||||
waitForExplicitFinish();
|
||||
SpecialPowers.pushPrefEnv(
|
||||
{
|
||||
set: [
|
||||
// Relax the user input requirements while running this test.
|
||||
["xpinstall.userActivation.required", false],
|
||||
],
|
||||
},
|
||||
runTest
|
||||
);
|
||||
}
|
||||
|
||||
function runTest() {
|
||||
Harness.installConfirmCallback = confirm_install;
|
||||
Harness.installEndedCallback = install_ended;
|
||||
Harness.installsCompletedCallback = finish_test;
|
||||
|
|
|
@ -31,13 +31,6 @@ function triggerInstall(browser, xpi_url) {
|
|||
});
|
||||
}
|
||||
|
||||
add_setup(async () => {
|
||||
await SpecialPowers.pushPrefEnv({
|
||||
// Relax the user input requirements while running this test.
|
||||
set: [["xpinstall.userActivation.required", false]],
|
||||
});
|
||||
});
|
||||
|
||||
// This tests if addon installation is blocked when requested in fullscreen
|
||||
add_task(async function testFullscreenBlockAddonInstallPrompt() {
|
||||
// Open example.com
|
||||
|
|
|
@ -17,12 +17,7 @@ function test() {
|
|||
|
||||
// prompt prior to download
|
||||
SpecialPowers.pushPrefEnv({
|
||||
set: [
|
||||
["extensions.postDownloadThirdPartyPrompt", false],
|
||||
["extensions.InstallTrigger.requireUserInput", false],
|
||||
// Relax the user input requirements while running this test.
|
||||
["xpinstall.userActivation.required", false],
|
||||
],
|
||||
set: [["extensions.postDownloadThirdPartyPrompt", false]],
|
||||
});
|
||||
|
||||
Harness.installConfirmCallback = confirm_install;
|
||||
|
|
|
@ -28,11 +28,7 @@ function test() {
|
|||
waitForExplicitFinish();
|
||||
SpecialPowers.pushPrefEnv(
|
||||
{
|
||||
set: [
|
||||
["security.data_uri.block_toplevel_data_uri_navigations", false],
|
||||
// Relax the user input requirements while running this test.
|
||||
["xpinstall.userActivation.required", false],
|
||||
],
|
||||
set: [["security.data_uri.block_toplevel_data_uri_navigations", false]],
|
||||
},
|
||||
runTest
|
||||
);
|
||||
|
|
|
@ -1464,8 +1464,6 @@ add_task(async function() {
|
|||
// These tests currently depends on InstallTrigger.install.
|
||||
["extensions.InstallTrigger.enabled", true],
|
||||
["extensions.InstallTriggerImpl.enabled", true],
|
||||
// Relax the user input requirements while running this test.
|
||||
["xpinstall.userActivation.required", false],
|
||||
],
|
||||
});
|
||||
|
||||
|
|
|
@ -5,8 +5,6 @@ add_setup(async function() {
|
|||
set: [
|
||||
["extensions.InstallTrigger.enabled", true],
|
||||
["extensions.InstallTriggerImpl.enabled", true],
|
||||
// Relax the user input requirements while running this test.
|
||||
["xpinstall.userActivation.required", false],
|
||||
],
|
||||
});
|
||||
});
|
||||
|
|
|
@ -1,156 +0,0 @@
|
|||
/* Any copyright is dedicated to the Public Domain.
|
||||
* http://creativecommons.org/publicdomain/zero/1.0/
|
||||
*/
|
||||
|
||||
"use strict";
|
||||
|
||||
const { AddonTestUtils } = ChromeUtils.import(
|
||||
"resource://testing-common/AddonTestUtils.jsm"
|
||||
);
|
||||
|
||||
AddonTestUtils.initMochitest(this);
|
||||
|
||||
const XPI_URL = `${TESTROOT}amosigned.xpi`;
|
||||
|
||||
async function runTestCase(spawnArgs, spawnFn, { expectInstall, clickLink }) {
|
||||
await SpecialPowers.pushPrefEnv({
|
||||
set: [
|
||||
// Make use the user activation requirements is enabled while running this test.
|
||||
["xpinstall.userActivation.required", true],
|
||||
],
|
||||
});
|
||||
await BrowserTestUtils.withNewTab(TESTROOT, async browser => {
|
||||
const expectedError = `${XPI_URL} install cancelled because of missing user gesture activation`;
|
||||
|
||||
let promiseDone;
|
||||
|
||||
if (expectInstall) {
|
||||
promiseDone = TestUtils.topicObserved("addon-install-blocked").then(
|
||||
([subject]) => {
|
||||
// Cancel the pending installation flow.
|
||||
subject.wrappedJSObject.cancel();
|
||||
}
|
||||
);
|
||||
} else {
|
||||
promiseDone = new Promise(resolve => {
|
||||
function messageHandler(msgObj) {
|
||||
if (
|
||||
msgObj instanceof Ci.nsIScriptError &&
|
||||
msgObj.message.includes(expectedError)
|
||||
) {
|
||||
ok(
|
||||
true,
|
||||
"Expect error on triggering navigation to xpi without user gesture activation"
|
||||
);
|
||||
cleanupListener();
|
||||
resolve();
|
||||
}
|
||||
}
|
||||
let listenerCleared = false;
|
||||
function cleanupListener() {
|
||||
if (!listenerCleared) {
|
||||
Services.console.unregisterListener(messageHandler);
|
||||
}
|
||||
listenerCleared = true;
|
||||
}
|
||||
Services.console.registerListener(messageHandler);
|
||||
registerCleanupFunction(cleanupListener);
|
||||
});
|
||||
}
|
||||
|
||||
await SpecialPowers.spawn(browser, spawnArgs, spawnFn);
|
||||
|
||||
if (clickLink) {
|
||||
info("Click link element");
|
||||
// Wait for the install to trigger the third party website doorhanger.
|
||||
// Trigger the link by simulating a mouse click, and expect it to trigger the
|
||||
// install flow instead (the window is still navigated to the xpi url from the
|
||||
// webpage JS code, but doing it while handling a DOM event does make it pass
|
||||
// the user activation check).
|
||||
await BrowserTestUtils.synthesizeMouseAtCenter(
|
||||
"#link-to-xpi-file",
|
||||
{},
|
||||
browser
|
||||
);
|
||||
}
|
||||
|
||||
info("Wait test case to be completed");
|
||||
await promiseDone;
|
||||
ok(true, "Test case run completed");
|
||||
});
|
||||
}
|
||||
|
||||
add_task(async function testSuccessOnUserActivatedLink() {
|
||||
await runTestCase(
|
||||
[XPI_URL],
|
||||
xpiURL => {
|
||||
const { document } = this.content;
|
||||
const link = document.createElement("a");
|
||||
link.id = "link-to-xpi-file";
|
||||
link.setAttribute("href", xpiURL);
|
||||
link.textContent = "Link to XPI File";
|
||||
|
||||
// Empty the test case and add the link, if the link is not visible
|
||||
// without scrolling, BrowserTestUtils.synthesizeMouseAtCenter may
|
||||
// fail to trigger the mouse event.
|
||||
document.body.innerHTML = "";
|
||||
document.body.appendChild(link);
|
||||
},
|
||||
{ expectInstall: true, clickLink: true }
|
||||
);
|
||||
});
|
||||
|
||||
add_task(async function testSuccessOnJSWithUserActivation() {
|
||||
await runTestCase(
|
||||
[XPI_URL],
|
||||
xpiURL => {
|
||||
const { document } = this.content;
|
||||
const link = document.createElement("a");
|
||||
link.id = "link-to-xpi-file";
|
||||
link.setAttribute("href", "#");
|
||||
link.textContent = "Link to XPI File";
|
||||
|
||||
// Empty the test case and add the link, if the link is not visible
|
||||
// without scrolling, BrowserTestUtils.synthesizeMouseAtCenter may
|
||||
// fail to trigger the mouse event.
|
||||
document.body.innerHTML = "";
|
||||
document.body.appendChild(link);
|
||||
|
||||
this.content.eval(`
|
||||
const linkEl = document.querySelector("#link-to-xpi-file");
|
||||
linkEl.onclick = () => {
|
||||
// This is expected to trigger the install flow successfully if handling
|
||||
// a user gesture DOM event, but to fail when triggered outside of it (as
|
||||
// done a few line below).
|
||||
window.location = "${xpiURL}";
|
||||
};
|
||||
`);
|
||||
},
|
||||
{ expectInstall: true, clickLink: true }
|
||||
);
|
||||
});
|
||||
|
||||
add_task(async function testFailureOnJSWithoutUserActivation() {
|
||||
await runTestCase(
|
||||
[XPI_URL],
|
||||
xpiURL => {
|
||||
this.content.eval(`window.location = "${xpiURL}";`);
|
||||
},
|
||||
{ expectInstall: false }
|
||||
);
|
||||
});
|
||||
|
||||
add_task(async function testFailureOnJSWithoutUserActivation() {
|
||||
await runTestCase(
|
||||
[XPI_URL],
|
||||
xpiURL => {
|
||||
this.content.eval(`
|
||||
const frame = document.createElement("iframe");
|
||||
frame.src = "${xpiURL}";
|
||||
document.body.innerHTML = "";
|
||||
document.body.appendChild(frame);
|
||||
`);
|
||||
},
|
||||
{ expectInstall: false }
|
||||
);
|
||||
});
|
|
@ -1,19 +1,6 @@
|
|||
// ----------------------------------------------------------------------------
|
||||
// Tests installing an unsigned add-on by navigating directly to the url
|
||||
function test() {
|
||||
waitForExplicitFinish();
|
||||
SpecialPowers.pushPrefEnv(
|
||||
{
|
||||
set: [
|
||||
// Relax the user input requirements while running this test.
|
||||
["xpinstall.userActivation.required", false],
|
||||
],
|
||||
},
|
||||
runTest
|
||||
);
|
||||
}
|
||||
|
||||
function runTest() {
|
||||
Harness.installConfirmCallback = confirm_install;
|
||||
Harness.installEndedCallback = install_ended;
|
||||
Harness.installsCompletedCallback = finish_test;
|
||||
|
|
|
@ -40,15 +40,12 @@ function extractChromeRoot(path) {
|
|||
function setInstallTriggerPrefs() {
|
||||
Services.prefs.setBoolPref("extensions.InstallTrigger.enabled", true);
|
||||
Services.prefs.setBoolPref("extensions.InstallTriggerImpl.enabled", true);
|
||||
// Relax the user input requirements while running tests that call this test helper.
|
||||
Services.prefs.setBoolPref("xpinstall.userActivation.required", false);
|
||||
registerCleanupFunction(clearInstallTriggerPrefs);
|
||||
}
|
||||
|
||||
function clearInstallTriggerPrefs() {
|
||||
Services.prefs.clearUserPref("extensions.InstallTrigger.enabled");
|
||||
Services.prefs.clearUserPref("extensions.InstallTriggerImpl.enabled");
|
||||
Services.prefs.clearUserPref("xpinstall.userActivation.required");
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
Загрузка…
Ссылка в новой задаче