Skip to content

Commit e81ad1d

Browse files
committed
firefox: Throwing an error if the addon can't write to a file
1 parent 84a9b38 commit e81ad1d

File tree

1 file changed

+8
-2
lines changed

1 file changed

+8
-2
lines changed

javascript/firefox-driver/js/files.js

+8-2
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,9 @@
2020
goog.provide('fxdriver.files');
2121
goog.provide('fxdriver.files.File');
2222

23+
goog.require('WebDriverError');
24+
goog.require('bot.ErrorCode');
25+
2326
/**
2427
* Creates a temporary text file starting with opt_prefix and ending with
2528
* opt_suffix.
@@ -127,8 +130,11 @@ fxdriver.files.READ_MODE_ = 0x01;
127130
fxdriver.files.File.prototype.append = function(toAppend) {
128131
var ostream = Components.classes['@mozilla.org/network/file-output-stream;1']
129132
.createInstance(Components.interfaces['nsIFileOutputStream']);
130-
ostream.init(this.nsIFile_, fxdriver.files.APPEND_MODE_,
131-
parseInt('666', 8), 0);
133+
try {
134+
ostream.init(this.nsIFile_, fxdriver.files.APPEND_MODE_, parseInt('666', 8), 0);
135+
} catch (e) {
136+
throw new WebDriverError(bot.ErrorCode.UNKNOWN_ERROR, e);
137+
}
132138

133139
var converter =
134140
Components.classes['@mozilla.org/intl/converter-output-stream;1']

0 commit comments

Comments
 (0)