Bug 1754441 - Add an explicit deprecation warning on InstallTrigger. r=mixedpuppy,emilio

Differential Revision: https://phabricator.services.mozilla.com/D138302
This commit is contained in:
Luca Greco 2022-03-18 20:02:54 +00:00
Родитель b1709f7b82
Коммит e87787c7a6
6 изменённых файлов: 128 добавлений и 1 удалений

Просмотреть файл

@ -19,6 +19,8 @@ DEPRECATED_OPERATION(UseOfReleaseEvents)
DEPRECATED_OPERATION(SyncXMLHttpRequest)
DEPRECATED_OPERATION(Window_Cc_ontrollers)
DEPRECATED_OPERATION(ImportXULIntoContent)
DEPRECATED_OPERATION(InstallTriggerDeprecated)
DEPRECATED_OPERATION(InstallTriggerInstallDeprecated)
DEPRECATED_OPERATION(NavigatorGetUserMedia)
DEPRECATED_OPERATION(WebrtcDeprecatedPrefix)
DEPRECATED_OPERATION(RTCPeerConnectionGetStreams)

Просмотреть файл

@ -437,3 +437,8 @@ OffscreenCanvasToBlobWarning=OffscreenCanvas.toBlob() is deprecated. Use Offscre
IDBDatabaseCreateMutableFileWarning=IDBDatabase.createMutableFile() is deprecated. If this API gets standardized, it will likely do so under the Origin Private File System effort at https://bugzil.la/1748667.
# LOCALIZATION NOTE: Do not translate "IDBMutableFile.open()"
IDBMutableFileOpenWarning=IDBMutableFile.open() is deprecated. If this API gets standardized, it will likely do so under the Origin Private File System effort at https://bugzil.la/1748667.
# LOCALIZATION NOTE: Do not translate "InstallTrigger"
InstallTriggerDeprecatedWarning=InstallTrigger is deprecated and will be removed in the future.
# LOCALIZATION NOTE: Do not translate "InstallTrigger.install()"
InstallTriggerInstallDeprecatedWarning=InstallTrigger.install() is deprecated and will be removed in the future. For more help https://extensionworkshop.com/documentation/publish/self-distribution/

Просмотреть файл

@ -58,6 +58,7 @@ interface InstallTriggerImpl {
* A callback to call as each installation succeeds or fails
* @return true if the installations were successfully started
*/
[Deprecated="InstallTriggerInstallDeprecated"]
boolean install(record<DOMString, (DOMString or InstallTriggerData)> installs,
optional InstallTriggerCallback callback);
@ -74,6 +75,7 @@ interface InstallTriggerImpl {
* Unused, retained for backwards compatibility
* @return true if the installation was successfully started
*/
[Deprecated="InstallTriggerInstallDeprecated"]
boolean installChrome(unsigned short type, DOMString url, DOMString skin);
/**
@ -87,5 +89,6 @@ interface InstallTriggerImpl {
* Unused, retained for backwards compatibility
* @return true if the installation was successfully started
*/
[Deprecated="InstallTriggerInstallDeprecated"]
boolean startSoftwareUpdate(DOMString url, optional unsigned short flags);
};

Просмотреть файл

@ -543,7 +543,7 @@ partial interface Window {
* be something like a WebIDL namespace, but we don't support
* JS-implemented static things yet. See bug 863952.
*/
[Replaceable]
[Replaceable, Deprecated="InstallTriggerDeprecated"]
readonly attribute InstallTriggerImpl? InstallTrigger;
/**

Просмотреть файл

@ -0,0 +1,116 @@
/* Any copyright is dedicated to the Public Domain.
* http://creativecommons.org/publicdomain/zero/1.0/
*/
const testserver = createHttpServer({ hosts: ["example.com"] });
function createTestPage(body) {
return `<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
</head>
<body>
${body}
</body>
</html>
`;
}
testserver.registerPathHandler(
"/installtrigger_ua_detection.html",
(request, response) => {
response.write(
createTestPage(`
<button/>
<script>
document.querySelector("button").onclick = () => {
typeof InstallTrigger;
};
</script>
`)
);
}
);
testserver.registerPathHandler(
"/installtrigger_install.html",
(request, response) => {
response.write(
createTestPage(`
<button/>
<script>
const install = InstallTrigger.install.bind(InstallTrigger);
document.querySelector("button").onclick = () => {
install({ fakeextensionurl: "http://example.com/fakeextensionurl.xpi" });
};
</script>
`)
);
}
);
async function testDeprecationWarning(testPageURL, expectedDeprecationWarning) {
const page = await ExtensionTestUtils.loadContentPage(testPageURL);
const { message, messageInnerWindowID, pageInnerWindowID } = await page.spawn(
[expectedDeprecationWarning],
expectedWarning => {
return new Promise(resolve => {
const consoleListener = consoleMsg => {
if (
consoleMsg instanceof Ci.nsIScriptError &&
consoleMsg.message?.includes(expectedWarning)
) {
Services.console.unregisterListener(consoleListener);
resolve({
message: consoleMsg.message,
messageInnerWindowID: consoleMsg.innerWindowID,
pageInnerWindowID: this.content.windowGlobalChild.innerWindowId,
});
}
};
Services.console.registerListener(consoleListener);
this.content.document.querySelector("button").click();
});
}
);
equal(
typeof messageInnerWindowID,
"number",
`Warning message should be associated to an innerWindowID`
);
equal(
messageInnerWindowID,
pageInnerWindowID,
`Deprecation warning "${message}" has been logged and associated to the expected window`
);
await page.close();
return message;
}
add_task(function testDeprecationWarningsOnUADetection() {
return testDeprecationWarning(
"http://example.com/installtrigger_ua_detection.html",
"InstallTrigger is deprecated and will be removed in the future."
);
});
add_task(async function testDeprecationWarningsOnInstallTriggerInstall() {
const message = await testDeprecationWarning(
"http://example.com/installtrigger_install.html",
"InstallTrigger.install() is deprecated and will be removed in the future."
);
const moreInfoURL =
"https://extensionworkshop.com/documentation/publish/self-distribution/";
ok(
message.includes(moreInfoURL),
"Deprecation warning should include an url to self-distribution documentation"
);
});

Просмотреть файл

@ -55,6 +55,7 @@ skip-if = appname != "firefox" || (os == "win" && processor == "aarch64") # bug
[test_install_cancel.js]
[test_install_icons.js]
[test_installtrigger_schemes.js]
[test_installtrigger_deprecation.js]
[test_isDebuggable.js]
[test_isReady.js]
[test_loadManifest_isPrivileged.js]