Rietveld Code Review Tool
Help | Bug tracker | Discussion group | Source code

Side by Side Diff: bootstrap.js.tmpl

Issue 29338608: Issue 3834 - Expose URL constructor to modules (Closed)
Patch Set: Created March 18, 2016, 12:11 p.m.
Left:
Right:
Use n/p to move between diff chunks; N/P to move between comments.
Jump to:
View unified diff | Download patch
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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, atob, btoa, File, TextDecoder, TextEncoder} = Cu.import("resource ://gre/modules/Services.jsm", null); 10 let {Services} = Cu.import("resource://gre/modules/Services.jsm", {});
11
12 Cu.importGlobalProperties(["atob", "btoa", "File", "URL",
13 "TextDecoder", "TextEncoder"]);
11 14
12 {%- if hasXMLHttpRequest %} 15 {%- if hasXMLHttpRequest %}
13 let XMLHttpRequest = Components.Constructor("@mozilla.org/xmlextras/xmlhttpreque st;1", "nsIXMLHttpRequest"); 16 Cu.importGlobalProperties(["XMLHttpRequest"]);
14 {%- endif %} 17 {%- endif %}
15 18
16 let addonData = null; 19 let addonData = null;
17 20
18 function startup(params, reason) 21 function startup(params, reason)
19 { 22 {
20 addonData = params; 23 addonData = params;
21 24
22 {%- if hasChromeRequires %} 25 {%- if hasChromeRequires %}
23 Services.obs.addObserver(RequireObserver, "{{metadata.get('general', 'basename ')}}-require", true); 26 Services.obs.addObserver(RequireObserver, "{{metadata.get('general', 'basename ')}}-require", true);
(...skipping 111 matching lines...) Expand 10 before | Expand all | Expand 10 after
135 applicationVersion: appInfo.version, 138 applicationVersion: appInfo.version,
136 platform: "gecko", 139 platform: "gecko",
137 platformVersion: appInfo.platformVersion 140 platformVersion: appInfo.platformVersion
138 }; 141 };
139 } 142 }
140 else 143 else
141 { 144 {
142 {%- endif %} 145 {%- endif %}
143 let url = addonData.resourceURI.spec + "lib/" + module + ".js"; 146 let url = addonData.resourceURI.spec + "lib/" + module + ".js";
144 scopes[module] = { 147 scopes[module] = {
145 Cc: Cc, 148 Cc, Ci, Cr, Cu, atob, btoa, File, URL, require,
saroyanm 2016/03/18 13:25:44 Why do we need to make this change ?
Wladimir Palant 2016/03/18 13:33:47 I don't but since I am cleaning up already...
146 Ci: Ci,
147 Cr: Cr,
148 Cu: Cu,
149 atob: atob,
150 btoa: btoa,
151 File: File,
152 require: require,
153 {% if hasShutdownHandlers %} 149 {% if hasShutdownHandlers %}
154 onShutdown: onShutdown, 150 onShutdown,
155 {% endif %} 151 {% endif %}
156 {%- if hasXMLHttpRequest %} 152 {%- if hasXMLHttpRequest %}
157 XMLHttpRequest: XMLHttpRequest, 153 XMLHttpRequest,
158 {% endif %} 154 {% endif %}
159 exports: {}}; 155 exports: {}};
160 {%- if multicompartment %} 156 {%- if multicompartment %}
161 let principal = Cc["@mozilla.org/systemprincipal;1"].getService(Ci.nsIPrin cipal); 157 let principal = Cc["@mozilla.org/systemprincipal;1"].getService(Ci.nsIPrin cipal);
162 scopes[module] = new Cu.Sandbox(principal, { 158 scopes[module] = new Cu.Sandbox(principal, {
163 sandboxName: url, 159 sandboxName: url,
164 sandboxPrototype: scopes[module], 160 sandboxPrototype: scopes[module],
165 wantXrays: false 161 wantXrays: false
166 }); 162 });
167 {%- endif %} 163 {%- endif %}
(...skipping 18 matching lines...) Expand all
186 { 182 {
187 if (topic == "{{metadata.get('general', 'basename')}}-require") 183 if (topic == "{{metadata.get('general', 'basename')}}-require")
188 { 184 {
189 subject.wrappedJSObject.exports = require(data); 185 subject.wrappedJSObject.exports = require(data);
190 } 186 }
191 }, 187 },
192 188
193 QueryInterface: XPCOMUtils.generateQI([Ci.nsISupportsWeakReference, Ci.nsIObse rver]) 189 QueryInterface: XPCOMUtils.generateQI([Ci.nsISupportsWeakReference, Ci.nsIObse rver])
194 }; 190 };
195 {%- endif %} 191 {%- endif %}
OLDNEW
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld