tor-browser

The Tor Browser
git clone https://git.dasho.dev/tor-browser.git
Log | Files | Refs | README | LICENSE

commit 4fd7ef4e78ac8500530b1a7c594f55079a7853f8
parent 2865881fa7e4d4eefb39837af6dc522db52d00d8
Author: Yoshi Cheng-Hao Huang <allstars.chh@gmail.com>
Date:   Tue, 11 Nov 2025 08:20:48 +0000

Bug 1979050 - Part 2: test. r=arai

Differential Revision: https://phabricator.services.mozilla.com/D271971

Diffstat:
Mdom/base/test/jsmodules/importmaps/chrome.toml | 7+++++++
Adom/base/test/jsmodules/importmaps/module_1979050.mjs | 3+++
Adom/base/test/jsmodules/importmaps/scope1/module_1979050.mjs | 5+++++
Adom/base/test/jsmodules/importmaps/scope1/scope2/module_1979050.mjs | 5+++++
Adom/base/test/jsmodules/importmaps/test_1979050.html | 50++++++++++++++++++++++++++++++++++++++++++++++++++
Adom/base/test/jsmodules/importmaps/test_1979050_2.html | 69+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
6 files changed, 139 insertions(+), 0 deletions(-)

diff --git a/dom/base/test/jsmodules/importmaps/chrome.toml b/dom/base/test/jsmodules/importmaps/chrome.toml @@ -2,18 +2,25 @@ support-files = [ "external_importMap.js", "insert_a_base_element.js", + "module_1979050.mjs", "module_simpleImportMap.mjs", "module_simpleImportMap_dir.mjs", "module_simpleImportMap_remap.mjs", "module_simpleImportMap_remap_https.mjs", "module_simpleExport.mjs", "module_sortedImportMap.mjs", + "scope1/module_1979050.mjs", "scope1/module_simpleExport.mjs", "scope1/module_simpleImportMap.mjs", + "scope1/scope2/module_1979050.mjs", "scope1/scope2/module_simpleExport.mjs", "scope1/scope2/module_simpleImportMap.mjs", ] +["test_1979050.html"] + +["test_1979050_2.html"] + ["test_dynamic_import_reject_importMap.html"] ["test_externalImportMap.html"] diff --git a/dom/base/test/jsmodules/importmaps/module_1979050.mjs b/dom/base/test/jsmodules/importmaps/module_1979050.mjs @@ -0,0 +1,3 @@ +import { x } from "./module_simpleExport.mjs"; + +result = x; diff --git a/dom/base/test/jsmodules/importmaps/scope1/module_1979050.mjs b/dom/base/test/jsmodules/importmaps/scope1/module_1979050.mjs @@ -0,0 +1,5 @@ +import { x } from "./module_simpleExport.mjs"; + +result2 = x; + +export let y = x; diff --git a/dom/base/test/jsmodules/importmaps/scope1/scope2/module_1979050.mjs b/dom/base/test/jsmodules/importmaps/scope1/scope2/module_1979050.mjs @@ -0,0 +1,5 @@ +import { x } from "./module_simpleExport.mjs"; + +result3 = x; + +export let z = x; diff --git a/dom/base/test/jsmodules/importmaps/test_1979050.html b/dom/base/test/jsmodules/importmaps/test_1979050.html @@ -0,0 +1,50 @@ +<!DOCTYPE html> +<meta charset=utf-8> +<title>Test bug 1979050</title> +<script> +Object.prototype.imports = { + "./module_simpleExport.mjs": "./scope1/module_simpleExport.mjs", +}; +Object.prototype.scopes = { + "chrome://mochitests/content/chrome/dom/base/test/jsmodules/importmaps/scope1/": { + "./scope1/module_simpleExport.mjs": "/content/chrome/dom/base/test/jsmodules/importmaps/module_simpleExport.mjs" + } +}; +Object.prototype.integrity = { + "./scope1/scope2/module_simpleExport.mjs": "sha384-oqVuAfXRKap7fdgcCY5uykM6+R9GqQ8K/uxy9rx7HNQlGYl1kPzQho1wx4JwY8wC" +}; + +</script> +<script type="importmap"> +{} +</script> + +<script src="chrome://mochikit/content/tests/SimpleTest/SimpleTest.js"></script> + +<script type="module" src="module_1979050.mjs"></script> +<script type="module" src="./scope1/module_1979050.mjs"></script> +<script type="module" src="./scope1/scope2/module_1979050.mjs"></script> +<script> + var result, result2, result3; + + SimpleTest.waitForExplicitFinish(); + + // eslint-disable-next-line no-unused-vars + function testLoaded() { + ok(result == 42, 'Check static imported value result: ' + result); + ok(result2 == 84, 'Check static imported value result2: ' + result2); + ok(result3 == 126, 'Check static imported value result3: ' + result3); + + import("./module_simpleExport.mjs").then((ns) => { + ok(ns.x == 42, 'Check dynamic imported value result: ' + ns.x); + return import("./scope1/module_1979050.mjs"); + }).then((ns) => { + ok(ns.y == 84, 'Check dynamic imported value ns.y: ' + ns.y); + return import("./scope1/scope2/module_1979050.mjs"); + }).then((ns) => { + ok(ns.z == 126, 'Check dynamic imported value ns.z: ' + ns.z); + SimpleTest.finish(); + }); + } +</script> +<body onload='testLoaded()'></body> diff --git a/dom/base/test/jsmodules/importmaps/test_1979050_2.html b/dom/base/test/jsmodules/importmaps/test_1979050_2.html @@ -0,0 +1,69 @@ +<!DOCTYPE html> +<meta charset=utf-8> +<title>Test bug 1979050</title> +<script src="chrome://mochikit/content/tests/SimpleTest/SimpleTest.js"></script> +<script> +Object.defineProperty(Object.prototype, "imports", + { + get() { + ok(false, "imports getter"); + return { + "./module_simpleExport.mjs": "./scope1/module_simpleExport.mjs", + }; + } + }); + +Object.defineProperty(Object.prototype, "scopes", + { + get() { + ok(false, "scopes getter"); + return { + "chrome://mochitests/content/chrome/dom/base/test/jsmodules/importmaps/scope1/": { + "./scope1/module_simpleExport.mjs": "/content/chrome/dom/base/test/jsmodules/importmaps/module_simpleExport.mjs" + } + }; + } + }); + +Object.defineProperty(Object.prototype, "integrity ", + { + get() { + ok(false, "scopes getter"); + return { + "./scope1/scope2/module_simpleExport.mjs": "sha384-oqVuAfXRKap7fdgcCY5uykM6+R9GqQ8K/uxy9rx7HNQlGYl1kPzQho1wx4JwY8wC" + }; + } + }); + +</script> +<script type="importmap"> +{} +</script> + +<script type="module" src="module_1979050.mjs"></script> +<script type="module" src="./scope1/module_1979050.mjs"></script> +<script type="module" src="./scope1/scope2/module_1979050.mjs"></script> +<script> + var result, result2, result3; + + SimpleTest.waitForExplicitFinish(); + + // eslint-disable-next-line no-unused-vars + function testLoaded() { + ok(result == 42, 'Check static imported value result: ' + result); + ok(result2 == 84, 'Check static imported value result2: ' + result2); + ok(result3 == 126, 'Check static imported value result3: ' + result3); + + import("./module_simpleExport.mjs").then((ns) => { + ok(ns.x == 42, 'Check dynamic imported value result: ' + ns.x); + return import("./scope1/module_1979050.mjs"); + }).then((ns) => { + ok(ns.y == 84, 'Check dynamic imported value ns.y: ' + ns.y); + return import("./scope1/scope2/module_1979050.mjs"); + }).then((ns) => { + ok(ns.z == 126, 'Check dynamic imported value ns.z: ' + ns.z); + SimpleTest.finish(); + }); + } +</script> +<body onload='testLoaded()'></body>