| Left: | ||
| Right: |
| OLD | NEW |
|---|---|
| 1 /* This Source Code Form is subject to the terms of the Mozilla Public | 1 /* This Source Code Form is subject to the terms of the Mozilla Public |
| 2 * License, v. 2.0. If a copy of the MPL was not distributed with this | 2 * License, v. 2.0. If a copy of the MPL was not distributed with this |
| 3 * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ | 3 * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ |
| 4 | 4 |
| 5 const Cc = Components.classes; | 5 const Cc = Components.classes; |
| 6 const Ci = Components.interfaces; | 6 const Ci = Components.interfaces; |
| 7 const Cr = Components.results; | 7 const Cr = Components.results; |
| 8 const Cu = Components.utils; | 8 const Cu = Components.utils; |
| 9 | 9 |
| 10 let {Services} = Cu.import("resource://gre/modules/Services.jsm", {}); | 10 let {Services} = Cu.import("resource://gre/modules/Services.jsm", {}); |
| 11 | 11 |
| 12 Cu.importGlobalProperties(["atob", "btoa", "File", "URL", | 12 Cu.importGlobalProperties(["atob", "btoa", "File", "URL", |
| 13 "TextDecoder", "TextEncoder"]); | 13 "TextDecoder", "TextEncoder", "XMLHttpRequest"]); |
|
Wladimir Palant
2016/10/31 10:06:42
For reference: originally there was no Cu.importGl
| |
| 14 | |
| 15 {%- if hasXMLHttpRequest %} | |
| 16 Cu.importGlobalProperties(["XMLHttpRequest"]); | |
| 17 {%- endif %} | |
| 18 | 14 |
| 19 let addonData = null; | 15 let addonData = null; |
| 20 | 16 |
| 21 function startup(params, reason) | 17 function startup(params, reason) |
| 22 { | 18 { |
| 23 addonData = params; | 19 addonData = params; |
| 24 | 20 |
| 25 {%- if hasChromeRequires %} | 21 {%- if hasChromeRequires %} |
| 26 Services.obs.addObserver(RequireObserver, "{{metadata.get('general', 'basename ')}}-require", true); | 22 Services.obs.addObserver(RequireObserver, "{{metadata.get('general', 'basename ')}}-require", true); |
| 27 onShutdown.add(function() | 23 onShutdown.add(function() |
| (...skipping 110 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 138 applicationVersion: appInfo.version, | 134 applicationVersion: appInfo.version, |
| 139 platform: "gecko", | 135 platform: "gecko", |
| 140 platformVersion: appInfo.platformVersion | 136 platformVersion: appInfo.platformVersion |
| 141 }; | 137 }; |
| 142 } | 138 } |
| 143 else | 139 else |
| 144 { | 140 { |
| 145 {%- endif %} | 141 {%- endif %} |
| 146 let url = addonData.resourceURI.spec + "lib/" + module + ".js"; | 142 let url = addonData.resourceURI.spec + "lib/" + module + ".js"; |
| 147 scopes[module] = { | 143 scopes[module] = { |
| 148 Cc, Ci, Cr, Cu, atob, btoa, File, URL, require, | 144 Cc, Ci, Cr, Cu, atob, btoa, File, URL, TextDecoder, TextEncoder, |
|
Wladimir Palant
2016/10/31 10:06:42
TextDecoder and TextEncoder globals weren't declar
| |
| 145 XMLHttpRequest, require, | |
| 149 {% if hasShutdownHandlers %} | 146 {% if hasShutdownHandlers %} |
| 150 onShutdown, | 147 onShutdown, |
| 151 {% endif %} | 148 {% endif %} |
| 152 {%- if hasXMLHttpRequest %} | |
| 153 XMLHttpRequest, | |
| 154 {% endif %} | |
| 155 exports: {}}; | 149 exports: {}}; |
| 156 {%- if multicompartment %} | 150 {%- if multicompartment %} |
| 157 let principal = Cc["@mozilla.org/systemprincipal;1"].getService(Ci.nsIPrin cipal); | 151 let principal = Cc["@mozilla.org/systemprincipal;1"].getService(Ci.nsIPrin cipal); |
| 158 scopes[module] = new Cu.Sandbox(principal, { | 152 scopes[module] = new Cu.Sandbox(principal, { |
| 159 sandboxName: url, | 153 sandboxName: url, |
| 160 sandboxPrototype: scopes[module], | 154 sandboxPrototype: scopes[module], |
| 161 wantXrays: false | 155 wantXrays: false |
| 162 }); | 156 }); |
| 163 {%- endif %} | 157 {%- endif %} |
| 164 Services.scriptloader.loadSubScript(url, scopes[module]); | 158 Services.scriptloader.loadSubScript(url, scopes[module]); |
| (...skipping 17 matching lines...) Expand all Loading... | |
| 182 { | 176 { |
| 183 if (topic == "{{metadata.get('general', 'basename')}}-require") | 177 if (topic == "{{metadata.get('general', 'basename')}}-require") |
| 184 { | 178 { |
| 185 subject.wrappedJSObject.exports = require(data); | 179 subject.wrappedJSObject.exports = require(data); |
| 186 } | 180 } |
| 187 }, | 181 }, |
| 188 | 182 |
| 189 QueryInterface: XPCOMUtils.generateQI([Ci.nsISupportsWeakReference, Ci.nsIObse rver]) | 183 QueryInterface: XPCOMUtils.generateQI([Ci.nsISupportsWeakReference, Ci.nsIObse rver]) |
| 190 }; | 184 }; |
| 191 {%- endif %} | 185 {%- endif %} |
| OLD | NEW |