Skip to content

Commit

Permalink
Bug 1383215: Part 5 - Update tests that relied on loading the same JS…
Browse files Browse the repository at this point in the history
…M from multiple URLs.

MozReview-Commit-ID: KEXGiMrauH7
  • Loading branch information
kmaglione committed Jul 22, 2017
1 parent ac19479 commit 0680265
Show file tree
Hide file tree
Showing 13 changed files with 20 additions and 27 deletions.
7 changes: 6 additions & 1 deletion addon-sdk/source/test/fixtures/native-addon-test/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,12 @@ exports.dummyModule = require('./dir/dummy');
exports.eventCore = require('sdk/event/core');
exports.promise = require('sdk/core/promise');

exports.localJSM = require('./dir/test.jsm');
if (module.uri.startsWith("file:"))
// We can't load the same file multiple times with different URLs, so
// skip this one.
exports.localJSM = { test: "this is a jsm" };
else
exports.localJSM = require('./dir/test.jsm');
exports.promisejsm = require('modules/Promise.jsm').Promise;
exports.require = require;

Expand Down
6 changes: 3 additions & 3 deletions js/xpconnect/loader/XPCOMUtils.jsm
Original file line number Diff line number Diff line change
Expand Up @@ -457,9 +457,9 @@ this.XPCOMUtils = {
if (!("__URI__" in that))
throw Error("importRelative may only be used from a JSM, and its first argument "+
"must be that JSM's global object (hint: use this)");
let uri = that.__URI__;
let i = uri.lastIndexOf("/");
Components.utils.import(uri.substring(0, i+1) + path, scope || that);

Cu.importGlobalProperties(["URL"]);
Components.utils.import(new URL(path, that.__URI__).href, scope || that);
},

/**
Expand Down
2 changes: 1 addition & 1 deletion js/xpconnect/tests/components/js/xpctest_attributes.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
/* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
Components.utils.import("resource:///modules/XPCOMUtils.jsm");
Components.utils.import("resource://gre/modules/XPCOMUtils.jsm");

function TestObjectReadWrite() {}
TestObjectReadWrite.prototype = {
Expand Down
2 changes: 1 addition & 1 deletion js/xpconnect/tests/components/js/xpctest_bug809674.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
/* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
Components.utils.import("resource:///modules/XPCOMUtils.jsm");
Components.utils.import("resource://gre/modules/XPCOMUtils.jsm");

function TestBug809674() {}
TestBug809674.prototype = {
Expand Down
2 changes: 1 addition & 1 deletion js/xpconnect/tests/components/js/xpctest_interfaces.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
/* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
Components.utils.import("resource:///modules/XPCOMUtils.jsm");
Components.utils.import("resource://gre/modules/XPCOMUtils.jsm");

function TestInterfaceA() {}
TestInterfaceA.prototype = {
Expand Down
2 changes: 1 addition & 1 deletion js/xpconnect/tests/components/js/xpctest_params.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
/* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
Components.utils.import("resource:///modules/XPCOMUtils.jsm");
Components.utils.import("resource://gre/modules/XPCOMUtils.jsm");

function TestParams() {
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
const {interfaces: Ci, classes: Cc, utils: Cu, results: Cr} = Components;
Cu.import("resource:///modules/XPCOMUtils.jsm");
Cu.import("resource://gre/modules/XPCOMUtils.jsm");

function TestReturnCodeChild() {}
TestReturnCodeChild.prototype = {
Expand Down
2 changes: 1 addition & 1 deletion js/xpconnect/tests/components/js/xpctest_utils.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */

Components.utils.import("resource:///modules/XPCOMUtils.jsm");
Components.utils.import("resource://gre/modules/XPCOMUtils.jsm");

function TestUtils() {}
TestUtils.prototype = {
Expand Down
7 changes: 2 additions & 5 deletions js/xpconnect/tests/unit/test_import.js
Original file line number Diff line number Diff line change
Expand Up @@ -39,11 +39,8 @@ function run_test() {
dump("resURI: " + resURI + "\n");
var filePath = res.resolveURI(resURI);
var scope3 = {};
Components.utils.import(filePath, scope3);
do_check_eq(typeof(scope3.XPCOMUtils), "object");
do_check_eq(typeof(scope3.XPCOMUtils.generateNSGetFactory), "function");

do_check_true(scope3.XPCOMUtils == scope.XPCOMUtils);
Assert.throws(() => Components.utils.import(filePath, scope3),
/NS_ERROR_UNEXPECTED/);

// make sure we throw when the second arg is bogus
var didThrow = false;
Expand Down
9 changes: 0 additions & 9 deletions js/xpconnect/tests/unit/test_isModuleLoaded.js
Original file line number Diff line number Diff line change
Expand Up @@ -21,13 +21,4 @@ function run_test() {
} catch (ex) {}
do_check_true(!Cu.isModuleLoaded("resource://gre/modules/ISO8601DateUtils1.jsm"),
"isModuleLoaded returned correct value for non-loaded module");

// incorrect url
try {
Cu.isModuleLoaded("resource://modules/ISO8601DateUtils1.jsm");
do_check_true(false,
"Should have thrown while trying to load a non existing file");
} catch (ex) {
do_check_true(true, "isModuleLoaded threw an exception while loading incorrect uri");
}
}
2 changes: 1 addition & 1 deletion js/xpconnect/tests/unit/test_returncode.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@

const {interfaces: Ci, classes: Cc, utils: Cu, manager: Cm, results: Cr} = Components;

Cu.import("resource:///modules/XPCOMUtils.jsm");
Cu.import("resource://gre/modules/XPCOMUtils.jsm");

function getConsoleMessages() {
let consoleService = Cc["@mozilla.org/consoleservice;1"].getService(Ci.nsIConsoleService);
Expand Down
2 changes: 1 addition & 1 deletion xpcom/tests/unit/data/main_process_directive_service.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
/* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
Components.utils.import("resource:///modules/XPCOMUtils.jsm");
Components.utils.import("resource://gre/modules/XPCOMUtils.jsm");

function TestProcessDirective() {}
TestProcessDirective.prototype = {
Expand Down
2 changes: 1 addition & 1 deletion xpcom/tests/unit/test_process_directives.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
var Ci = Components.interfaces;
var Cc = Components.classes;

Components.utils.import("resource:///modules/Services.jsm");
Components.utils.import("resource://gre/modules/Services.jsm");

function run_test()
{
Expand Down

0 comments on commit 0680265

Please sign in to comment.