Skip to content

Commit e65a566

Browse files
gineadaigkatsev
authored andcommitted
Delete deprecated template literals (#510)
1 parent 83d11a4 commit e65a566

File tree

9 files changed

+4
-572
lines changed

9 files changed

+4
-572
lines changed

common/components/protocols.js

100644100755
Lines changed: 1 addition & 116 deletions
Original file line numberDiff line numberDiff line change
@@ -16,11 +16,6 @@ const { classes: Cc, interfaces: Ci, utils: Cu } = Components;
1616

1717
Cu.import("resource://gre/modules/Services.jsm");
1818
Cu.import("resource://gre/modules/XPCOMUtils.jsm");
19-
XPCOMUtils.defineLazyGetter(this, "convert", function () {
20-
var obj = new Object;
21-
Cu.import("resource://liberator/template.js", obj);
22-
return obj.convert;
23-
});
2419

2520
const NS_BINDING_ABORTED = 0x804b0002;
2621
const nsIProtocolHandler = Ci.nsIProtocolHandler;
@@ -51,17 +46,6 @@ function redirect(to, orig) {
5146
let html = '<html><head><meta http-equiv="Refresh" content="' + ("0;" + to).replace(/"/g, "&quot;") + '"/></head></html>';
5247
return makeChannel(dataURL('text/html', html), ioService.newURI(to, null, null));
5348
}
54-
XPCOMUtils.defineLazyGetter(this, "cache", function () {
55-
var dir = Cc["@mozilla.org/file/directory_service;1"].getService(Ci.nsIProperties).get("ProfD", Ci.nsIFile);
56-
dir.append("liberatorCache");
57-
if (!dir.exists()) {
58-
dir.create(dir.DIRECTORY_TYPE, -1);
59-
}
60-
return dir;
61-
});
62-
XPCOMUtils.defineLazyGetter(this, "version", function () {
63-
return Services.appinfo.version;
64-
});
6549

6650
function ChromeData() {}
6751
ChromeData.prototype = {
@@ -148,110 +132,11 @@ Liberator.prototype = {
148132
.QueryInterface(Ci.nsIURI);
149133
uri.init(uri.URLTYPE_STANDARD, this.defaultPort, spec, charset, baseURI);
150134

151-
if (uri.host !== "template") return uri;
152-
153-
try {
154-
spec = uri.spec;
155-
//uri.init(uri.URLTYPE_STANDARD, this.defaultPort, uri.path.substr(1), charset, null);
156-
// xxx:
157-
uri = ioService.newURI(uri.path.replace(new RegExp("^/+"), ""), charset, null);
158-
// recursible when override
159-
while (uri.scheme === "chrome") {
160-
uri = Cc["@mozilla.org/chrome/chrome-registry;1"]
161-
.getService(Ci.nsIChromeRegistry)
162-
.convertChromeURL(uri);
163-
}
164-
165-
var nest = Cc["@mozilla.org/network/util;1"].getService(Ci.nsINetUtil).newSimpleNestedURI(uri);
166-
nest.spec = spec;
167-
} catch (ex) { Cu.reportError(ex); }
168-
return nest;
135+
return uri;
169136
},
170137

171138
newChannel: function (uri) {
172139
try {
173-
if ((uri instanceof Ci.nsINestedURI)) {
174-
var m = (new RegExp("^/{2,}([^/]+)/([^?]+)")).exec(uri.path);
175-
if (m) {
176-
var host = m[1];
177-
var path = m[2];
178-
179-
switch (host) {
180-
case "template":
181-
try {
182-
var nest = ioService.newURI(path, uri.charset, null);
183-
var channel = ioService.newChannelFromURI(nest);
184-
185-
// xxx: support template
186-
if (0) return channel;
187-
188-
// xxx: NG: Firefox 16, 17
189-
// NG: Cu.import
190-
if (parseFloat(version) < 17) {
191-
var stream = Cc["@mozilla.org/scriptableinputstream;1"]
192-
.createInstance(Ci.nsIScriptableInputStream);
193-
var cstream = channel.open();
194-
stream.init(cstream);
195-
var text = stream.read(-1);
196-
stream.close();
197-
cstream.close();
198-
199-
stream = Cc["@mozilla.org/io/string-input-stream;1"].createInstance(Ci.nsIStringInputStream);
200-
stream.setData(convert(text), -1);
201-
var channel = Cc["@mozilla.org/network/input-stream-channel;1"]
202-
.createInstance(Ci.nsIInputStreamChannel);
203-
channel.contentStream = stream;
204-
channel.QueryInterface(Ci.nsIChannel);
205-
channel.setURI(uri);
206-
return channel;
207-
}
208-
209-
var innerURI = uri.innerURI;
210-
var temp = cache.clone();
211-
var path = nest.spec.replace(/[:\/]/g, "_");
212-
var lastModifiedTime;
213-
if (innerURI.scheme === "resource") {
214-
innerURI = Cc["@mozilla.org/network/protocol;1?name=resource"]
215-
.getService(Ci.nsIResProtocolHandler).resolveURI(innerURI);
216-
innerURI = ioService.newURI(innerURI, null, null);
217-
}
218-
if (innerURI.scheme === "jar") {
219-
innerURI = innerURI.QueryInterface(Ci.nsIJARURI).JARFile;
220-
}
221-
if (innerURI.scheme === "file") {
222-
lastModifiedTime = innerURI.QueryInterface(Ci.nsIFileURL).file.lastModifiedTime;
223-
} else {
224-
Cu.reportError("do not support:" + innerURI.spec);
225-
}
226-
227-
temp.append(path);
228-
if (!temp.exists()
229-
|| temp.lastModifiedTime !== lastModifiedTime) {
230-
231-
var stream = Cc["@mozilla.org/scriptableinputstream;1"]
232-
.createInstance(Ci.nsIScriptableInputStream);
233-
var cstream = channel.open();
234-
stream.init(cstream);
235-
var text = stream.read(-1);
236-
stream.close();
237-
cstream.close();
238-
239-
text = convert(text);
240-
241-
var stream = Cc["@mozilla.org/network/file-output-stream;1"].createInstance(Ci.nsIFileOutputStream);
242-
Services.console.logStringMessage("create:" + temp.leafName);
243-
stream.init(temp, 0x2 | 0x8 | 0x20, 0644, 0);
244-
stream.write(text, text.length);
245-
stream.close();
246-
temp.lastModifiedTime = lastModifiedTime;
247-
} else { Services.console.logStringMessage("use cache:" + uri.spec); }
248-
return ioService.newChannelFromURI(ioService.newFileURI(temp));
249-
} catch (ex) { Cu.reportError(ex); }
250-
}
251-
}
252-
return fakeChannel(uri);
253-
}
254-
255140
let url;
256141
switch(uri.host) {
257142
case "help":

common/content/javascript.js

Lines changed: 0 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -637,12 +637,5 @@ const JavaScript = Module("javascript", {
637637
options.add(["inspectcontentobjects"],
638638
"Allow completion of JavaScript objects coming from web content. POSSIBLY INSECURE!",
639639
"boolean", false);
640-
641-
// TODO: delete me when minVersion is greater than 34
642-
if (!liberator.has("template")) {
643-
options.add(["expandtemplate"],
644-
"Expand TemplateLiteral",
645-
"boolean", !("XMLList" in window));
646-
}
647640
}
648641
})

common/content/liberator-overlay.js

Lines changed: 3 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -5,10 +5,7 @@
55

66
(function () {
77
const modules = {};
8-
// TODO: FIXME when minVersion is greater than 34
9-
var {isSupport: TemplateIsSupport} = Components.utils.import("resource://liberator/CheckTemplate.jsm", {});
10-
const BASE = TemplateIsSupport ?
11-
"chrome://liberator/content/" : "liberator://template/chrome://liberator/content/";
8+
const BASE = "chrome://liberator/content/";
129

1310
modules.modules = modules;
1411

@@ -33,9 +30,8 @@
3330

3431
let prefix = [BASE];
3532

36-
// TODO: FIXME when minVersion is greater than 34
37-
Components.utils.import("resource://liberator/template-tag" + (TemplateIsSupport ? ".js" : "-old.js"), modules);
38-
33+
Components.utils.import("resource://liberator/template-tag.js", modules);
34+
3935
// TODO: This list is much too long, we should try to minimize
4036
// the number of required components for easier porting to new applications
4137
["base.js",

common/content/liberator.js

Lines changed: 0 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -358,27 +358,13 @@ const Liberator = Module("liberator", {
358358
* should be loaded.
359359
*/
360360
loadScript: function (uri, context) {
361-
// TODO: delete me when minVersion is greater than 34
362-
if (options.expandtemplate) {
363-
var prefix = "liberator://template/";
364-
if (uri.lastIndexOf(prefix, 0) === -1)
365-
uri = prefix + uri;
366-
}
367361
services.get("scriptloader").loadSubScript(uri, context, "UTF-8");
368362
},
369363

370364
eval: function (str, context) {
371365
try {
372366
if (!context)
373367
context = userContext;
374-
375-
// TODO: delete me when minVersion is greater than 34
376-
if (options.expandtemplate) {
377-
var obj = new Object;
378-
Cu.import("resource://liberator/template.js", obj);
379-
str = obj.convert(str);
380-
}
381-
382368
context[EVAL_ERROR] = null;
383369
context[EVAL_STRING] = str;
384370
context[EVAL_RESULT] = null;

common/modules/CheckTemplate.jsm

Lines changed: 0 additions & 11 deletions
This file was deleted.

common/modules/template-tag-old.js

Lines changed: 0 additions & 19 deletions
This file was deleted.

0 commit comments

Comments
 (0)