Bug 1581243 - Follow-up: Improve bustage fix for WebExtensions schema warnings-as-errors (bug 1570715); r=mkmelin
authorGeoff Lankow <geoff@darktrojan.net>
Mon, 16 Sep 2019 22:40:26 +1200
changeset 36829 f44f040f0192d8a54d760c949d9933811677cc92
parent 36828 08374e5b0ac07d8356cb6fdfb6fb0a26d8362087
child 36830 9f6f738a416e29068af7f230c04b932911df6553
push id395
push userclokep@gmail.com
push dateMon, 02 Dec 2019 19:38:57 +0000
reviewersmkmelin
bugs1581243, 1570715
Bug 1581243 - Follow-up: Improve bustage fix for WebExtensions schema warnings-as-errors (bug 1570715); r=mkmelin
mail/components/extensions/test/browser/browser_ext_commands_onCommand.js
mail/components/extensions/test/browser/browser_ext_quickFilter.js
mail/components/extensions/test/xpcshell/test_ext_alias.js
mail/components/extensions/test/xpcshell/test_ext_cloudFile.js
--- a/mail/components/extensions/test/browser/browser_ext_commands_onCommand.js
+++ b/mail/components/extensions/test/browser/browser_ext_commands_onCommand.js
@@ -1,17 +1,12 @@
 /* -*- Mode: indent-tabs-mode: nil; js-indent-level: 2 -*- */
 /* vim: set sts=2 sw=2 et tw=80: */
 "use strict";
 
-Services.prefs.setBoolPref(
-  "extensions.webextensions.warnings-as-errors",
-  false
-);
-
 add_task(async function test_user_defined_commands() {
   const testCommands = [
     // Ctrl Shortcuts
     {
       name: "toggle-ctrl-a",
       shortcut: "Ctrl+A",
       key: "A",
       modifiers: {
@@ -232,17 +227,20 @@ add_task(async function test_user_define
   let waitForConsole = new Promise(resolve => {
     SimpleTest.monitorConsole(resolve, [
       {
         message: /Reading manifest: Warning processing commands.*.unrecognized_property: An unexpected property was found/,
       },
     ]);
   });
 
+  // Unrecognized_property in manifest triggers warning.
+  ExtensionTestUtils.failOnSchemaWarnings(false);
   await extension.startup();
+  ExtensionTestUtils.failOnSchemaWarnings(true);
   await extension.awaitMessage("ready");
 
   async function runTest(window) {
     for (let testCommand of testCommands) {
       if (testCommand.shortcutMac && !testCommand.shortcut && !isMac) {
         continue;
       }
       EventUtils.synthesizeKey(testCommand.key, testCommand.modifiers, window);
--- a/mail/components/extensions/test/browser/browser_ext_quickFilter.js
+++ b/mail/components/extensions/test/browser/browser_ext_quickFilter.js
@@ -1,19 +1,14 @@
 /* This Source Code Form is subject to the terms of the Mozilla Public
  * 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/. */
 
 let account, rootFolder, subFolders;
 
-Services.prefs.setBoolPref(
-  "extensions.webextensions.warnings-as-errors",
-  false
-);
-
 add_task(async () => {
   account = createAccount();
   rootFolder = account.incomingServer.rootFolder;
   subFolders = [...rootFolder.subFolders];
   createMessages(subFolders[0], 10);
 
   window.gFolderTreeView.selectFolder(rootFolder);
   await new Promise(resolve => executeSoon(resolve));
@@ -139,14 +134,18 @@ add_task(async () => {
     Ci.nsIAbCard
   );
   card.setProperty("FirstName", author[0]);
   card.setProperty("LastName", author[1]);
   card.setProperty("DisplayName", `${author[0]} ${author[1]}`);
   card.setProperty("PrimaryEmail", author[2]);
   MailServices.ab.directories.getNext().addCard(card);
 
+  // Deprecated "starred" property. See bug 1581498 for removal.
+  ExtensionTestUtils.failOnSchemaWarnings(false);
+
   await extension.startup();
   await extension.awaitFinish("quickFilter");
   await extension.unload();
 
   window.gFolderTreeView.selectFolder(rootFolder);
+  ExtensionTestUtils.failOnSchemaWarnings(true);
 });
--- a/mail/components/extensions/test/xpcshell/test_ext_alias.js
+++ b/mail/components/extensions/test/xpcshell/test_ext_alias.js
@@ -17,21 +17,16 @@ const server = createHttpServer({ hosts:
 server.registerPathHandler("/dummy", (request, response) => {
   response.setStatusLine(request.httpVersion, 200, "OK");
   response.setHeader("Content-Type", "text/html", false);
   response.write(
     "<!DOCTYPE html><html><head><meta charset='utf8'></head><body></body></html>"
   );
 });
 
-Services.prefs.setBoolPref(
-  "extensions.webextensions.warnings-as-errors",
-  false
-);
-
 add_task(async function test_alias() {
   let extension = ExtensionTestUtils.loadExtension({
     background: async () => {
       let pending = new Set(["contentscript", "proxyscript", "webscript"]);
 
       browser.runtime.onMessage.addListener(message => {
         if (message == "error-no-messenger") {
           browser.test.fail("Proxy script has messenger object");
@@ -135,17 +130,21 @@ add_task(async function test_alias() {
           "Web accessible script can access manifest"
         );
 
         browser.runtime.sendMessage("webscript");
       `,
     },
   });
 
+  // Deprecated proxy functions and events. This test will fail once
+  // bug 1545811 is fixed, and the proxy parts should be removed then.
+  // ExtensionTestUtils.failOnSchemaWarnings(false);
   await extension.startup();
+  ExtensionTestUtils.failOnSchemaWarnings(true);
 
   const contentPage = await ExtensionTestUtils.loadContentPage(
     "http://example.com/dummy"
   );
   await extension.awaitFinish("ext_alias");
 
   await contentPage.close();
   await extension.unload();
--- a/mail/components/extensions/test/xpcshell/test_ext_cloudFile.js
+++ b/mail/components/extensions/test/xpcshell/test_ext_cloudFile.js
@@ -8,21 +8,16 @@ var { cloudFileAccounts } = ChromeUtils.
   "resource:///modules/cloudFileAccounts.jsm"
 );
 var { ExtensionTestUtils } = ChromeUtils.import(
   "resource://testing-common/ExtensionXPCShellUtils.jsm"
 );
 
 ExtensionTestUtils.init(this);
 
-Services.prefs.setBoolPref(
-  "extensions.webextensions.warnings-as-errors",
-  false
-);
-
 add_task(async () => {
   async function background() {
     function createCloudfileAccount() {
       return new Promise(resolve => {
         function accountListener(account) {
           browser.cloudFile.onAccountAdded.removeListener(accountListener);
           resolve(account);
         }
@@ -269,19 +264,24 @@ add_task(async () => {
     account.cancelFileUpload(testFiles.cloudFile2);
   });
 
   extension.onMessage("deleteFile", id => {
     let account = cloudFileAccounts.getAccount(id);
     account.deleteFile(uploads.cloudFile1.id);
   });
 
+  // Deprecated property "settings_url". See bug 1581496 for removal.
+  ExtensionTestUtils.failOnSchemaWarnings(false);
+
   Assert.ok(!cloudFileAccounts.getProviderForType("ext-cloudfile@xpcshell"));
   await extension.startup();
   Assert.ok(cloudFileAccounts.getProviderForType("ext-cloudfile@xpcshell"));
   Assert.equal(cloudFileAccounts.accounts.length, 1);
 
   await extension.awaitFinish("cloudFile");
   await extension.unload();
 
   Assert.ok(!cloudFileAccounts.getProviderForType("ext-cloudfile@xpcshell"));
   Assert.equal(cloudFileAccounts.accounts.length, 0);
+
+  ExtensionTestUtils.failOnSchemaWarnings(true);
 });