mirror of
https://github.com/mozilla/gecko-dev.git
synced 2024-12-26 10:10:31 +00:00
Bug 1014484 - Fix 'toString is read-only' errors on B2G. r=froydnj
This commit is contained in:
parent
b4861346eb
commit
43ebf8cc06
@ -1253,6 +1253,7 @@ function OSError(operation, path = "") {
|
||||
this.operation = operation;
|
||||
this.path = path;
|
||||
}
|
||||
OSError.prototype = Object.create(Error.prototype);
|
||||
exports.OSError = OSError;
|
||||
|
||||
|
||||
|
@ -81,7 +81,6 @@ libc.declareLazy(LazyBindings, "strerror",
|
||||
*/
|
||||
let OSError = function OSError(operation = "unknown operation",
|
||||
errno = ctypes.errno, path = "") {
|
||||
operation = operation;
|
||||
SharedAll.OSError.call(this, operation, path);
|
||||
this.unixErrno = errno;
|
||||
};
|
||||
|
@ -5,12 +5,22 @@
|
||||
|
||||
let {utils: Cu, interfaces: Ci} = Components;
|
||||
|
||||
let {OS} = Cu.import("resource://gre/modules/osfile.jsm", {});
|
||||
let {Services} = Cu.import("resource://gre/modules/Services.jsm", {});
|
||||
let {XPCOMUtils} = Cu.import("resource://gre/modules/XPCOMUtils.jsm", {});
|
||||
|
||||
// Bug 1014484 can only be reproduced by loading OS.File first from the
|
||||
// CommonJS loader, so we do not want OS.File to be loaded eagerly for
|
||||
// all the tests in this directory.
|
||||
XPCOMUtils.defineLazyModuleGetter(this, "OS",
|
||||
"resource://gre/modules/osfile.jsm");
|
||||
XPCOMUtils.defineLazyModuleGetter(this, "FileUtils",
|
||||
"resource://gre/modules/FileUtils.jsm");
|
||||
XPCOMUtils.defineLazyModuleGetter(this, "NetUtil",
|
||||
"resource://gre/modules/NetUtil.jsm");
|
||||
XPCOMUtils.defineLazyModuleGetter(this, "Services",
|
||||
"resource://gre/modules/Services.jsm");
|
||||
|
||||
let {Promise} = Cu.import("resource://gre/modules/Promise.jsm", {});
|
||||
let {Task} = Cu.import("resource://gre/modules/Task.jsm", {});
|
||||
let {FileUtils} = Cu.import("resource://gre/modules/FileUtils.jsm", {});
|
||||
let {NetUtil} = Cu.import("resource://gre/modules/NetUtil.jsm", {});
|
||||
|
||||
Services.prefs.setBoolPref("toolkit.osfile.log", true);
|
||||
|
||||
|
37
toolkit/components/osfile/tests/xpcshell/test_loader.js
Normal file
37
toolkit/components/osfile/tests/xpcshell/test_loader.js
Normal file
@ -0,0 +1,37 @@
|
||||
/* Any copyright is dedicated to the Public Domain.
|
||||
* http://creativecommons.org/publicdomain/zero/1.0/ */
|
||||
|
||||
"use strict";
|
||||
|
||||
/**
|
||||
* Test that OS.File can be loaded using the CommonJS loader.
|
||||
*/
|
||||
|
||||
let { Loader } = Components.utils.import('resource://gre/modules/commonjs/toolkit/loader.js', {});
|
||||
|
||||
function run_test() {
|
||||
run_next_test();
|
||||
}
|
||||
|
||||
|
||||
add_task(function*() {
|
||||
let dataDir = Services.io.newFileURI(do_get_file("test_loader/", true)).spec + "/";
|
||||
let loader = Loader.Loader({
|
||||
paths: {'': dataDir }
|
||||
});
|
||||
|
||||
let require = Loader.Require(loader, Loader.Module('module_test_loader', 'foo'));
|
||||
do_print("Require is ready");
|
||||
try {
|
||||
require('module_test_loader');
|
||||
} catch (error) {
|
||||
dump('Bootstrap error: ' +
|
||||
(error.message ? error.message : String(error)) + '\n' +
|
||||
(error.stack || error.fileName + ': ' + error.lineNumber) + '\n');
|
||||
|
||||
throw error;
|
||||
}
|
||||
|
||||
do_print("Require has worked");
|
||||
});
|
||||
|
@ -0,0 +1,9 @@
|
||||
/* Any copyright is dedicated to the Public Domain.
|
||||
* http://creativecommons.org/publicdomain/zero/1.0/ */
|
||||
|
||||
"use strict";
|
||||
|
||||
// Load OS.File from a module loaded with the CommonJS/addon-sdk loader
|
||||
|
||||
let {Cu} = require("chrome");
|
||||
Cu.import('resource://gre/modules/osfile.jsm');
|
@ -2,6 +2,9 @@
|
||||
head = head.js
|
||||
tail =
|
||||
|
||||
support-files =
|
||||
test_loader/module_test_loader.js
|
||||
|
||||
[test_available_free_space.js]
|
||||
[test_osfile_closed.js]
|
||||
[test_path.js]
|
||||
@ -31,4 +34,5 @@ tail =
|
||||
[test_osfile_writeAtomic_backupTo_option.js]
|
||||
[test_osfile_error.js]
|
||||
[test_queue.js]
|
||||
[test_constants.js]
|
||||
[test_loader.js]
|
||||
[test_constants.js]
|
||||
|
Loading…
Reference in New Issue
Block a user