From c30ebdac27c93b57e368c69e9c13055a17229992 Mon Sep 17 00:00:00 2001
From: "Matt A. Tobin" <email@mattatobin.com>
Date: Sun, 22 Apr 2018 11:16:08 -0400
Subject:  Fix for loops in AddonRepository_SQLiteMigrator.jsm (SyntaxError:
 missing ] after element list)

---
 .../mozapps/extensions/internal/AddonRepository_SQLiteMigrator.jsm  | 6 +++++-
 1 file changed, 5 insertions(+), 1 deletion(-)

(limited to 'toolkit/mozapps')

diff --git a/toolkit/mozapps/extensions/internal/AddonRepository_SQLiteMigrator.jsm b/toolkit/mozapps/extensions/internal/AddonRepository_SQLiteMigrator.jsm
index 11944ddf5..66147b9aa 100644
--- a/toolkit/mozapps/extensions/internal/AddonRepository_SQLiteMigrator.jsm
+++ b/toolkit/mozapps/extensions/internal/AddonRepository_SQLiteMigrator.jsm
@@ -60,7 +60,11 @@ this.AddonRepository_SQLiteMigrator = {
 
     this._retrieveStoredData((results) => {
       this._closeConnection();
-      let resultArray = [addon for ([,addon] of Iterator(results))];
+      // Tycho: let resultArray = [addon for ([,addon] of Iterator(results))];
+      let resultArray = [];
+      for (let [,addon] of Iterator(results)) {
+        resultArray.push(addon);
+      }
       logger.debug(resultArray.length + " addons imported.")
       aCallback(resultArray);
     });
-- 
cgit v1.2.3


From be2b3635ad7f21582a5cfd5a25fc4ec41653c1c7 Mon Sep 17 00:00:00 2001
From: JustOff <Off.Just.Off@gmail.com>
Date: Mon, 23 Apr 2018 14:52:50 +0300
Subject: Fix accessing the bootstrap methods when they are declared in the new
 lexical scope

---
 .../mozapps/extensions/internal/XPIProvider.jsm    | 17 ++++++++++++---
 .../test/addons/test_bootstrap_const/bootstrap.js  |  5 +++++
 .../test/addons/test_bootstrap_const/install.rdf   | 24 ++++++++++++++++++++++
 .../test/xpcshell/test_bootstrap_const.js          | 17 +++++++++++++++
 .../extensions/test/xpcshell/xpcshell-shared.ini   |  1 +
 5 files changed, 61 insertions(+), 3 deletions(-)
 create mode 100644 toolkit/mozapps/extensions/test/addons/test_bootstrap_const/bootstrap.js
 create mode 100644 toolkit/mozapps/extensions/test/addons/test_bootstrap_const/install.rdf
 create mode 100644 toolkit/mozapps/extensions/test/xpcshell/test_bootstrap_const.js

(limited to 'toolkit/mozapps')

diff --git a/toolkit/mozapps/extensions/internal/XPIProvider.jsm b/toolkit/mozapps/extensions/internal/XPIProvider.jsm
index 72a460e4a..c43811ba8 100644
--- a/toolkit/mozapps/extensions/internal/XPIProvider.jsm
+++ b/toolkit/mozapps/extensions/internal/XPIProvider.jsm
@@ -4436,7 +4436,18 @@ this.XPIProvider = {
       if (aAddon.type == "locale")
         return;
 
-      if (!(aMethod in this.bootstrapScopes[aAddon.id])) {
+      let method = undefined;
+      try {
+        method = Components.utils.evalInSandbox(`${aMethod};`,
+                                                this.bootstrapScopes[aAddon.id],
+                                                "ECMAv5");
+      }
+      catch (e) {
+        // An exception will be caught if the expected method is not defined.
+        // That will be logged below.
+      }
+
+      if (!method) {
         logger.warn("Add-on " + aAddon.id + " is missing bootstrap method " + aMethod);
         return;
       }
@@ -4455,9 +4466,9 @@ this.XPIProvider = {
       }
 
       logger.debug("Calling bootstrap method " + aMethod + " on " + aAddon.id + " version " +
-          aAddon.version);
+                  aAddon.version);
       try {
-        this.bootstrapScopes[aAddon.id][aMethod](params, aReason);
+        method(params, aReason);
       }
       catch (e) {
         logger.warn("Exception running bootstrap method " + aMethod + " on " + aAddon.id, e);
diff --git a/toolkit/mozapps/extensions/test/addons/test_bootstrap_const/bootstrap.js b/toolkit/mozapps/extensions/test/addons/test_bootstrap_const/bootstrap.js
new file mode 100644
index 000000000..498b76526
--- /dev/null
+++ b/toolkit/mozapps/extensions/test/addons/test_bootstrap_const/bootstrap.js
@@ -0,0 +1,5 @@
+Components.utils.import("resource://gre/modules/Services.jsm");
+
+const install = function() {
+  Services.obs.notifyObservers(null, "addon-install", "");
+}
\ No newline at end of file
diff --git a/toolkit/mozapps/extensions/test/addons/test_bootstrap_const/install.rdf b/toolkit/mozapps/extensions/test/addons/test_bootstrap_const/install.rdf
new file mode 100644
index 000000000..af3a749ce
--- /dev/null
+++ b/toolkit/mozapps/extensions/test/addons/test_bootstrap_const/install.rdf
@@ -0,0 +1,24 @@
+<?xml version="1.0"?>
+
+<RDF xmlns="http://www.w3.org/1999/02/22-rdf-syntax-ns#"
+     xmlns:em="http://www.mozilla.org/2004/em-rdf#">
+
+  <Description about="urn:mozilla:install-manifest">
+    <em:id>bootstrap@tests.mozilla.org</em:id>
+    <em:version>1.0</em:version>
+    <em:bootstrap>true</em:bootstrap>
+
+    <!-- Front End MetaData -->
+    <em:name>Test Bootstrap</em:name>
+    <em:description>Test Description</em:description>
+
+    <em:targetApplication>
+      <Description>
+        <em:id>xpcshell@tests.mozilla.org</em:id>
+        <em:minVersion>1</em:minVersion>
+        <em:maxVersion>1</em:maxVersion>
+      </Description>
+    </em:targetApplication>
+
+  </Description>
+</RDF>
\ No newline at end of file
diff --git a/toolkit/mozapps/extensions/test/xpcshell/test_bootstrap_const.js b/toolkit/mozapps/extensions/test/xpcshell/test_bootstrap_const.js
new file mode 100644
index 000000000..fb02b59be
--- /dev/null
+++ b/toolkit/mozapps/extensions/test/xpcshell/test_bootstrap_const.js
@@ -0,0 +1,17 @@
+/* Any copyright is dedicated to the Public Domain.
+ * http://creativecommons.org/publicdomain/zero/1.0/
+ */
+
+createAppInfo("xpcshell@tests.mozilla.org", "XPCShell", "1", "1");
+startupManager();
+
+add_task(function*() {
+  let sawInstall = false;
+  Services.obs.addObserver(function() {
+    sawInstall = true;
+  }, "addon-install", false);
+
+  yield promiseInstallAllFiles([do_get_addon("test_bootstrap_const")]);
+
+  ok(sawInstall);
+});
\ No newline at end of file
diff --git a/toolkit/mozapps/extensions/test/xpcshell/xpcshell-shared.ini b/toolkit/mozapps/extensions/test/xpcshell/xpcshell-shared.ini
index bab072e83..2a12f147a 100644
--- a/toolkit/mozapps/extensions/test/xpcshell/xpcshell-shared.ini
+++ b/toolkit/mozapps/extensions/test/xpcshell/xpcshell-shared.ini
@@ -29,6 +29,7 @@ skip-if = os == "android"
 [test_bootstrap.js]
 # Bug 676992: test consistently hangs on Android
 skip-if = os == "android"
+[test_bootstrap_const.js]
 [test_bootstrap_resource.js]
 [test_bug299716.js]
 # Bug 676992: test consistently hangs on Android
-- 
cgit v1.2.3