Skip to content

Commit 897b58f

Browse files
committed
Fixed namespace collision about FileUtils introduced by Firefox 27.
1 parent abbe8cc commit 897b58f

File tree

8 files changed

+47
-47
lines changed

8 files changed

+47
-47
lines changed

seleniumbuilder/chrome/content/html/js/builder/io.js

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -37,14 +37,14 @@ builder.io.addStorageSystem({
3737
"load": function(path, basePath, callback) {
3838
var file = null;
3939
if (basePath) {
40-
var baseFile = bridge.FileUtils.getFile(basePath.path);
40+
var baseFile = bridge.SeFileUtils.getFile(basePath.path);
4141
if (baseFile && baseFile.exists()) {
4242
file = Components.classes['@mozilla.org/file/local;1'].createInstance(Components.interfaces.nsILocalFile);
4343
file.setRelativeDescriptor(baseFile.parent, path.path);
4444
}
4545
}
4646
if (!file || !file.exists()) {
47-
try { file = bridge.FileUtils.getFile(path.path); } catch (e) {}
47+
try { file = bridge.SeFileUtils.getFile(path.path); } catch (e) {}
4848
}
4949
if (file && !file.exists()) { return null; }
5050
var text = null;
@@ -57,7 +57,7 @@ builder.io.addStorageSystem({
5757
callback({ "text": text, "path": { "path": file.path, "where": "local" } });
5858
},
5959
"deriveRelativePath": function(path, basePath) {
60-
var rp = bridge.FileUtils.getFile(path.path).getRelativeDescriptor(bridge.FileUtils.getFile(basePath.path).parent);
60+
var rp = bridge.SeFileUtils.getFile(path.path).getRelativeDescriptor(bridge.SeFileUtils.getFile(basePath.path).parent);
6161
return rp == null ? path : {"path": rp, "where": path.where, "format": path.format};
6262
}
6363
});
@@ -70,14 +70,14 @@ builder.io.loadFile = function(path) {
7070
bridge.Format.TEST_CASE_DIRECTORY_PREF,
7171
function(fp) { return fp.file; });
7272
} else {
73-
file = bridge.FileUtils.getFile(path);
73+
file = bridge.SeFileUtils.getFile(path);
7474
}
7575
return file;
7676
};
7777

7878
builder.io.readFile = function(file) {
79-
var sis = bridge.FileUtils.openFileInputStream(file);
80-
var data = bridge.FileUtils.getUnicodeConverter('UTF-8').ConvertToUnicode(sis.read(sis.available()));
79+
var sis = bridge.SeFileUtils.openFileInputStream(file);
80+
var data = bridge.SeFileUtils.getUnicodeConverter('UTF-8').ConvertToUnicode(sis.read(sis.available()));
8181
sis.close();
8282
return data;
8383
};

seleniumbuilder/chrome/content/html/js/builder/selenium1/adapter.js

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ builder.selenium1.adapter.seleniumAPI = {};
1010
var subScriptLoader = Components.classes["@mozilla.org/moz/jssubscript-loader;1"].getService(Components.interfaces.mozIJSSubScriptLoader);
1111
subScriptLoader.loadSubScript('chrome://seleniumbuilder/content/html/js/selenium-ide/selenium/scripts/selenium-api.js', builder.selenium1.adapter.seleniumAPI);
1212
var parser = new DOMParser();
13-
var apidoc = parser.parseFromString(bridge.FileUtils.readURL("chrome://seleniumbuilder/content/html/js/selenium-ide/selenium/iedoc-core.xml"), "text/xml");
13+
var apidoc = parser.parseFromString(bridge.SeFileUtils.readURL("chrome://seleniumbuilder/content/html/js/selenium-ide/selenium/iedoc-core.xml"), "text/xml");
1414
bridge.Command.apiDocuments = [apidoc];
1515
bridge.Command.prototype.getAPI = function() {
1616
return builder.selenium1.adapter.seleniumAPI;
@@ -88,7 +88,7 @@ builder.selenium1.adapter.saveSuite = function(scripts, path) {
8888
ts.addTestCaseFromContent(tc);
8989
}
9090
if (path) {
91-
ts.file = bridge.FileUtils.getFile(path.path);
91+
ts.file = bridge.SeFileUtils.getFile(path.path);
9292
}
9393
if (ts.save(false)) {
9494
return { 'path': ts.file.path, 'where': 'local', 'format': format };
@@ -278,7 +278,7 @@ builder.selenium1.adapter.convertScriptToTestCase = function(script, useExportNa
278278
}
279279
} else {
280280
if (script.path && script.path.where === "local") {
281-
testCase.file = bridge.FileUtils.getFile(script.path.path);
281+
testCase.file = bridge.SeFileUtils.getFile(script.path.path);
282282
}
283283
if (script.path) {
284284
var title = script.path.path.split("/");

seleniumbuilder/chrome/content/html/js/builder/selenium2/io/io.js

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -41,10 +41,10 @@ builder.selenium2.io.loadScriptJSON = function(path) {
4141
bridge.Format.TEST_CASE_DIRECTORY_PREF,
4242
function(fp) { return fp.file; });
4343
} else {
44-
file = bridge.FileUtils.getFile(path);
44+
file = bridge.SeFileUtils.getFile(path);
4545
}
46-
var sis = bridge.FileUtils.openFileInputStream(file);
47-
var script = JSON.parse(bridge.FileUtils.getUnicodeConverter('UTF-8').ConvertToUnicode(sis.read(sis.available())));
46+
var sis = bridge.SeFileUtils.openFileInputStream(file);
47+
var script = JSON.parse(bridge.SeFileUtils.getUnicodeConverter('UTF-8').ConvertToUnicode(sis.read(sis.available())));
4848
sis.close();
4949
script.path = {
5050
where: "local",
@@ -79,12 +79,12 @@ builder.selenium2.io.saveScriptWithParams = function(script, format, path, param
7979
function(fp) { return fp.file; },
8080
format.extension);
8181
} else {
82-
file = bridge.FileUtils.getFile(path);
82+
file = bridge.SeFileUtils.getFile(path);
8383
}
8484
if (file != null) {
8585
var outputStream = Components.classes["@mozilla.org/network/file-output-stream;1"].createInstance( Components.interfaces.nsIFileOutputStream);
8686
outputStream.init(file, 0x02 | 0x08 | 0x20, 0644, 0);
87-
var converter = bridge.FileUtils.getUnicodeConverter('UTF-8');
87+
var converter = bridge.SeFileUtils.getUnicodeConverter('UTF-8');
8888
var text = converter.ConvertFromUnicode(format.format(script, file.leafName, params));
8989
outputStream.write(text, text.length);
9090
var fin = converter.Finish();
@@ -361,12 +361,12 @@ builder.selenium2.io.saveSuiteAsFormat = function(format, scripts, path) {
361361
function(fp) { return fp.file; },
362362
format.extension);
363363
} else {
364-
file = bridge.FileUtils.getFile(path.path);
364+
file = bridge.SeFileUtils.getFile(path.path);
365365
}
366366
if (file != null) {
367367
var outputStream = Components.classes["@mozilla.org/network/file-output-stream;1"].createInstance( Components.interfaces.nsIFileOutputStream);
368368
outputStream.init(file, 0x02 | 0x08 | 0x20, 0644, 0);
369-
var converter = bridge.FileUtils.getUnicodeConverter('UTF-8');
369+
var converter = bridge.SeFileUtils.getUnicodeConverter('UTF-8');
370370
var path = { 'path': file.path, 'where': 'local', 'format': format };
371371
var text = converter.ConvertFromUnicode(format.format(scripts, path));
372372
outputStream.write(text, text.length);

seleniumbuilder/chrome/content/html/js/selenium-ide/file-utils.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@
1414
* limitations under the License.
1515
*/
1616

17-
var FileUtils = {
17+
var SeFileUtils = {
1818
getProfileDir: function() {
1919
return Components.classes["@mozilla.org/file/directory_service;1"]
2020
.getService(Components.interfaces.nsIProperties)

seleniumbuilder/chrome/content/html/js/selenium-ide/format.js

Lines changed: 20 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,7 @@ function FormatCollection(options) {
4141
FormatCollection.log = FormatCollection.prototype.log = new Log('FormatCollection');
4242

4343
FormatCollection.getFormatDir = function() {
44-
var formatDir = FileUtils.getProfileDir();
44+
var formatDir = SeFileUtils.getProfileDir();
4545
formatDir.append("selenium-ide-scripts");
4646
if (!formatDir.exists()) {
4747
formatDir.create(Components.interfaces.nsIFile.DIRECTORY_TYPE, 0755);
@@ -60,8 +60,8 @@ FormatCollection.loadUserFormats = function(options) {
6060
if (!formatFile.exists()) {
6161
return [];
6262
}
63-
var text = FileUtils.readFile(formatFile);
64-
var conv = FileUtils.getUnicodeConverter('UTF-8');
63+
var text = SeFileUtils.readFile(formatFile);
64+
var conv = SeFileUtils.getUnicodeConverter('UTF-8');
6565
text = conv.ConvertToUnicode(text);
6666
var formats = [];
6767
while (text.length > 0) {
@@ -81,12 +81,12 @@ FormatCollection.saveUserFormats = function(formats) {
8181
for (var i = 0; i < formats.length; i++) {
8282
text += formats[i].id + ',' + formats[i].name + "\n";
8383
}
84-
var conv = FileUtils.getUnicodeConverter('UTF-8');
84+
var conv = SeFileUtils.getUnicodeConverter('UTF-8');
8585
text = conv.ConvertFromUnicode(text);
8686

8787
var formatFile = FormatCollection.getFormatDir();
8888
formatFile.append("index.txt");
89-
var stream = FileUtils.openFileOutputStream(formatFile);
89+
var stream = SeFileUtils.openFileOutputStream(formatFile);
9090
stream.write(text, text.length);
9191
var fin = conv.Finish();
9292
if (fin.length > 0) {
@@ -235,7 +235,7 @@ Format.TEST_CASE_EXPORT_DIRECTORY_PREF = "testCaseExportDirectory";
235235
Format.prototype.log = Format.log = new Log('Format');
236236

237237
Format.prototype.getUnicodeConverter = function() {
238-
return FileUtils.getUnicodeConverter(this.options.encoding);
238+
return SeFileUtils.getUnicodeConverter(this.options.encoding);
239239
}
240240

241241
Format.prototype.getFormatter = function() {
@@ -272,7 +272,7 @@ Format.prototype.saveAs = function(testCase, filename, exportTest) {
272272
function(fp) { return fp.file; },
273273
this.extension);
274274
} else {
275-
file = FileUtils.getFile(filename);
275+
file = SeFileUtils.getFile(filename);
276276
}
277277
if (file != null) {
278278
testCase.file = file;
@@ -325,11 +325,11 @@ Format.prototype.saveSuiteAsNew = function(testSuite, exportTest) {
325325

326326
if (file != null) {
327327
var filepath = [];
328-
filepath = FileUtils.splitPath(file);
328+
filepath = SeFileUtils.splitPath(file);
329329

330330
var filename = filepath[filepath.length -1];
331-
var output = FileUtils.openFileOutputStream(file);
332-
var converter = FileUtils.getUnicodeConverter("UTF-8");
331+
var output = SeFileUtils.openFileOutputStream(file);
332+
var converter = SeFileUtils.getUnicodeConverter("UTF-8");
333333
var text = converter.ConvertFromUnicode(formatter
334334
.formatSuite(testSuite, filename));
335335

@@ -381,9 +381,9 @@ Format.prototype.loadFile = function(file, isURL) {
381381

382382
var sis;
383383
if (isURL) {
384-
sis = FileUtils.openURLInputStream(file);
384+
sis = SeFileUtils.openURLInputStream(file);
385385
} else {
386-
sis = FileUtils.openFileInputStream(file);
386+
sis = SeFileUtils.openFileInputStream(file);
387387
}
388388
var text = this.getUnicodeConverter().ConvertToUnicode(sis.read(sis.available()));
389389
var testCase = new TestCase();
@@ -420,7 +420,7 @@ InternalFormat.prototype.loadFormatter = function() {
420420
}
421421

422422
InternalFormat.prototype.getSource = function() {
423-
return FileUtils.readURL(this.url);
423+
return SeFileUtils.readURL(this.url);
424424
}
425425

426426
InternalFormat.prototype.getFormatURI = function() {
@@ -463,7 +463,7 @@ UserFormat.prototype.saveFormat = function(source) {
463463
}
464464
var formatFile = formatDir.clone();
465465
formatFile.append(this.id + ".js");
466-
var stream = FileUtils.openFileOutputStream(formatFile);
466+
var stream = SeFileUtils.openFileOutputStream(formatFile);
467467
stream.write(source, source.length);
468468
stream.close();
469469

@@ -478,20 +478,20 @@ UserFormat.prototype.getFormatFile = function() {
478478
}
479479

480480
UserFormat.prototype.getFormatURI = function() {
481-
return FileUtils.fileURI(this.getFormatFile());
481+
return SeFileUtils.fileURI(this.getFormatFile());
482482
}
483483

484484
UserFormat.prototype.loadFormatter = function() {
485-
return FormatCollection.loadFormatter(FileUtils.fileURI(this.getFormatFile()));
485+
return FormatCollection.loadFormatter(SeFileUtils.fileURI(this.getFormatFile()));
486486
}
487487

488488
UserFormat.prototype.getSource = function() {
489489
if (this.id) {
490-
return FileUtils.readFile(this.getFormatFile());
490+
return SeFileUtils.readFile(this.getFormatFile());
491491
} else {
492492
// mod
493-
//return FileUtils.readURL('chrome://selenium-ide/content/formats/blank.js');
494-
return FileUtils.readURL('chrome://seleniumbuilder/content/html/js/selenium-ide/formats/blank.js');
493+
//return SeFileUtils.readURL('chrome://selenium-ide/content/formats/blank.js');
494+
return SeFileUtils.readURL('chrome://seleniumbuilder/content/html/js/selenium-ide/formats/blank.js');
495495
}
496496
}
497497

@@ -512,7 +512,7 @@ PluginFormat.prototype.loadFormatter = function() {
512512
}
513513

514514
PluginFormat.prototype.getSource = function() {
515-
return FileUtils.readURL(this.url);
515+
return SeFileUtils.readURL(this.url);
516516
}
517517

518518
PluginFormat.prototype.getFormatURI = function() {

seleniumbuilder/chrome/content/html/js/selenium-ide/testSuite.js

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -28,13 +28,13 @@ TestSuite.load = function() {
2828
}
2929

3030
TestSuite.loadFile = function(file) {
31-
var suite = this.loadInputStream(FileUtils.openFileInputStream(file));
31+
var suite = this.loadInputStream(SeFileUtils.openFileInputStream(file));
3232
suite.file = file;
3333
return suite;
3434
}
3535

3636
TestSuite.loadInputStream = function(input) {
37-
var content = FileUtils.getUnicodeConverter("UTF-8").ConvertToUnicode(input.read(input.available()));
37+
var content = SeFileUtils.getUnicodeConverter("UTF-8").ConvertToUnicode(input.read(input.available()));
3838
input.close();
3939
return this.loadString(content);
4040
}
@@ -106,8 +106,8 @@ TestSuite.prototype = {
106106
},
107107
".html");
108108
}
109-
var output = FileUtils.openFileOutputStream(this.file);
110-
var converter = FileUtils.getUnicodeConverter("UTF-8");
109+
var output = SeFileUtils.openFileOutputStream(this.file);
110+
var converter = SeFileUtils.getUnicodeConverter("UTF-8");
111111
var content = TestSuite.header + this.formatSuiteTable() + TestSuite.footer;
112112
var text = converter.ConvertFromUnicode(content);
113113
output.write(text, text.length);
@@ -163,7 +163,7 @@ TestSuite.TestCase = function(testSuite, filename, title) {
163163
TestSuite.TestCase.prototype = {
164164
getFile: function() {
165165
if (!this.testSuite.file) return null;
166-
var file = FileUtils.getFile(this.testSuite.file.parent.path);
166+
var file = SeFileUtils.getFile(this.testSuite.file.parent.path);
167167
//alert(file + " " + this.filename);
168168
var filename = this.filename;
169169
if (Components.interfaces.nsILocalFileWin &&
@@ -183,8 +183,8 @@ TestSuite.TestCase.prototype = {
183183
},
184184

185185
_computeRelativePath: function(fromFile, toFile) {
186-
var from = FileUtils.splitPath(fromFile.parent);
187-
var to = FileUtils.splitPath(toFile);
186+
var from = SeFileUtils.splitPath(fromFile.parent);
187+
var to = SeFileUtils.splitPath(toFile);
188188
var result = [];
189189
for (var base = 0; base < from.length && base < to.length; base++) {
190190
if (from[base] != to[base]) {

seleniumbuilder/chrome/content/html/js/selenium-ide/tools.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -96,7 +96,7 @@ function showFilePicker(window, title, mode, defaultDirPrefName, handler, defaul
9696
fp.init(window, title, mode);
9797
var defaultDir = Preferences.getString(defaultDirPrefName);
9898
if (defaultDir) {
99-
fp.displayDirectory = FileUtils.getFile(defaultDir);
99+
fp.displayDirectory = SeFileUtils.getFile(defaultDir);
100100
}
101101
//fp.appendFilters(nsIFilePicker.filterHTML | nsIFilePicker.filterAll);
102102
if (defaultFileName) {
@@ -184,7 +184,7 @@ var ExtensionsLoader = {
184184
path = path.replace(/^\s*/, '');
185185
path = path.replace(/\s*$/, '');
186186
if (!path.match(/^(file|chrome):/)) {
187-
path = FileUtils.fileURI(FileUtils.getFile(path));
187+
path = SeFileUtils.fileURI(SeFileUtils.getFile(path));
188188
}
189189
urls.push(path);
190190
});

seleniumbuilder/chrome/content/seleniumBuilder2.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -283,7 +283,7 @@ bridge.setClipboardString = function(dataString) {
283283
};
284284

285285
// Import everything we need from Selenium / IDE.
286-
bridge.FileUtils = FileUtils;
286+
bridge.SeFileUtils = SeFileUtils;
287287
bridge.Command = Command;
288288
bridge.FormatCollection = FormatCollection;
289289
bridge.SeleniumIDE = SeleniumIDE;

0 commit comments

Comments
 (0)