mirror of
https://github.com/HeyPuter/firefox.git
synced 2026-11-26 04:22:30 -10:00
In a following patch, all DevTools moz.build files will use DevToolsModules to install JS modules at a path that corresponds directly to their source tree location. Here we rewrite all require and import calls to match the new location that these files are installed to.
30 lines
1.1 KiB
JavaScript
30 lines
1.1 KiB
JavaScript
/* -*- js-indent-level: 2; indent-tabs-mode: nil -*- */
|
|
/* Any copyright is dedicated to the Public Domain.
|
|
http://creativecommons.org/publicdomain/zero/1.0/ */
|
|
|
|
// Test devtools.lazyRequireGetter
|
|
|
|
function run_test() {
|
|
const name = "asyncUtils";
|
|
const path = "devtools/shared/async-utils";
|
|
const o = {};
|
|
devtools.lazyRequireGetter(o, name, path);
|
|
const asyncUtils = require(path);
|
|
// XXX: do_check_eq only works on primitive types, so we have this
|
|
// do_check_true of an equality expression.
|
|
do_check_true(o.asyncUtils === asyncUtils);
|
|
|
|
// A non-main loader should get a new object via |lazyRequireGetter|, just
|
|
// as it would via a direct |require|.
|
|
const o2 = {};
|
|
let loader = new DevToolsLoader();
|
|
loader.lazyRequireGetter(o2, name, path);
|
|
do_check_true(o2.asyncUtils !== asyncUtils);
|
|
|
|
// A module required via a non-main loader that then uses |lazyRequireGetter|
|
|
// should also get the same object from that non-main loader.
|
|
let exposeLoader = loader.require("xpcshell-test/exposeLoader");
|
|
const o3 = exposeLoader.exerciseLazyRequire(name, path);
|
|
do_check_true(o3.asyncUtils === o2.asyncUtils);
|
|
}
|